Skip to content

Commit

Permalink
Start on a component for the WorkPackage HoverCard
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger committed Oct 4, 2024
1 parent 92a09fc commit 301641a
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/components/_index.sass
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@import "shares/invite_user_form_component"
@import "work_packages/details/tab_component"
@import "work_packages/progress/modal_body_component"
@import "work_packages/hover_card_component"
@import "work_packages/split_view_component"
@import "open_project/common/attribute_component"
@import "open_project/common/submenu_component"
Expand Down
16 changes: 16 additions & 0 deletions app/components/work_packages/highlighted_type_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

class WorkPackages::HighlightedTypeComponent < ApplicationComponent
include OpPrimer::ComponentHelpers

def initialize(work_package:, **system_arguments)
super

@type = work_package.type
@system_arguments = system_arguments
end

def call
render(Primer::Beta::Text.new(classes: "__hl_inline_type_#{@type.id}"), **@system_arguments) { @type.name.upcase }
end
end
36 changes: 36 additions & 0 deletions app/components/work_packages/hover_card_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<%= if @work_package.present?
grid_layout('op-wp-hover-card', tag: :div) do |grid|
grid.with_area(:status, tag: :div, color: :muted) do
render WorkPackages::StatusButtonComponent.new(work_package: @work_package, button_arguments: { size: :small })
end

grid.with_area(:id, tag: :div, color: :muted) do
render(Primer::Beta::Text.new(font_size: :small)) { "##{@work_package.id}" }
end

grid.with_area(:project, tag: :div, color: :muted) do
render(Primer::Beta::Text.new(font_size: :small)) { "- #{@work_package.project.name}" }
end

grid.with_area(:type, tag: :div) do
render(WorkPackages::HighlightedTypeComponent.new(work_package: @work_package))
end

grid.with_area(:subject, tag: :div) do
render(Primer::Beta::Text.new(font_weight: :semibold)) { @work_package.subject }
end

if @assignee.present?
grid.with_area(:assignee, tag: :div) do
render(Users::AvatarComponent.new(user: @assignee, show_name: false, size: :medium))
end
end
end
else

render Primer::Beta::Blankslate.new(border: false, narrow: true) do |component|
component.with_visual_icon(icon: "x-circle")
component.with_heading(tag: :h3).with_content(I18n.t("api_v3.errors.not_found.work_package"))
end

end %>
13 changes: 13 additions & 0 deletions app/components/work_packages/hover_card_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class WorkPackages::HoverCardComponent < ApplicationComponent
include OpPrimer::ComponentHelpers

def initialize(id:)
super

@id = id
@work_package = WorkPackage.visible.find_by(id:)
@assignee = @work_package.present? ? @work_package.assigned_to : nil
end
end
13 changes: 13 additions & 0 deletions app/components/work_packages/hover_card_component.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.op-wp-hover-card
display: grid
align-items: center
grid-template-columns: max-content max-content max-content auto auto 1fr
grid-template-rows: max-content 1fr auto
grid-row-gap: 5px
grid-column-gap: 5px
grid-template-areas: "status status id project project project" "type subject subject subject subject subject" "assignee assignee . . . ."
overflow: hidden

&--type,
&--subject
align-self: flex-start
11 changes: 11 additions & 0 deletions app/components/work_packages/status_button_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%=
render(Primer::Alpha::ActionMenu.new(**@menu_arguments)) do |menu|
menu.with_show_button(**@button_arguments) do |button|
button.with_trailing_action_icon(icon: "triangle-down")
'Placeholder Status'
end

menu.with_item { "OPTION 1"}
menu.with_item { "OPTION 2"}
end
%>
15 changes: 15 additions & 0 deletions app/components/work_packages/status_button_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

class WorkPackages::StatusButtonComponent < ApplicationComponent
include OpPrimer::ComponentHelpers

def initialize(work_package:, button_arguments: {}, menu_arguments: {})
super

@work_package = work_package
@status = work_package.status
@menu_arguments = menu_arguments

@button_arguments = button_arguments.merge({classes: "__hl_background_status_#{@status.id}"})

Check notice on line 13 in app/components/work_packages/status_button_component.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] app/components/work_packages/status_button_component.rb#L13 <Layout/SpaceInsideHashLiteralBraces>

Space inside { missing.
Raw output
app/components/work_packages/status_button_component.rb:13:48: C: Layout/SpaceInsideHashLiteralBraces: Space inside { missing.

Check notice on line 13 in app/components/work_packages/status_button_component.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] app/components/work_packages/status_button_component.rb#L13 <Layout/SpaceInsideHashLiteralBraces>

Space inside } missing.
Raw output
app/components/work_packages/status_button_component.rb:13:96: C: Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
end
end
2 changes: 1 addition & 1 deletion app/views/work_packages/hover_card/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<turbo-frame id="op-hover-card-body">
Hallo WELT
<%= render WorkPackages::HoverCardComponent.new(id: @id) %>
</turbo-frame>
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
hostDirectives: [WorkPackageIsolatedQuerySpaceDirective],
})
export class HoverCardComponent extends OpModalComponent implements OnInit {
// TODO
@Input() public turboFrameSrc:string = "/work_packages/50/hover_card";

Check failure on line 64 in frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts

View workflow job for this annotation

GitHub Actions / eslint

[eslint] frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts#L64 <@typescript-eslint/quotes>(https://typescript-eslint.io/rules/quotes)

Strings must use singlequote.
Raw output
{"ruleId":"@typescript-eslint/quotes","severity":2,"message":"Strings must use singlequote.","line":64,"column":42,"nodeType":"Literal","messageId":"wrongQuotes","endLine":64,"endColumn":72,"fix":{"range":[2307,2337],"text":"'/work_packages/50/hover_card'"}}

@Input() public alignment?:Placement = 'bottom-end';
Expand Down

0 comments on commit 301641a

Please sign in to comment.