-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start on a component for the WorkPackage HoverCard
- Loading branch information
Showing
9 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/components/work_packages/highlighted_type_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
36
app/components/work_packages/hover_card_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
app/components/work_packages/status_button_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / rubocop[rubocop] app/components/work_packages/status_button_component.rb#L13 <Layout/SpaceInsideHashLiteralBraces>
Raw output
Check notice on line 13 in app/components/work_packages/status_button_component.rb GitHub Actions / rubocop[rubocop] app/components/work_packages/status_button_component.rb#L13 <Layout/SpaceInsideHashLiteralBraces>
Raw output
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters