[73968, 73089] Extend and improve design of WorkPackageCardComponent#23175
[73968, 73089] Extend and improve design of WorkPackageCardComponent#23175HDinger wants to merge 1 commit into
Conversation
25d8a87 to
add05fb
Compare
add05fb to
91de331
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the shared work package card component with richer metadata, footer support, status styling variants, and Lookbook documentation/previews, then applies the enhanced card presentation to Backlogs.
Changes:
- Adds card options for assignee, priority, drag handle, parent footer link, bottom-line slot, custom metric/menu placement, and status scheme.
- Updates Backlogs to render the enhanced card with assignee, priority, parent link, and secondary status style.
- Adds Lookbook documentation/previews and supporting locale/style updates.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
app/components/open_project/common/work_package_card_component.rb |
Adds new card options and bottom-line slot. |
app/components/open_project/common/work_package_card_component.html.erb |
Renders the new metadata/action/footer layout. |
app/components/open_project/common/work_package_card_component.sass |
Updates grid layout, responsive behavior, and action/footer styling. |
app/components/open_project/common/work_package_card_component/menu.html.erb |
Makes the menu button small. |
app/components/work_packages/info_line_component.rb |
Adds a status scheme option. |
app/components/work_packages/info_line_component.html.erb |
Passes the status scheme to the status badge. |
app/components/work_packages/status_badge_component.rb |
Adjusts highlight-class behavior when a Primer label scheme is provided. |
modules/backlogs/app/components/backlogs/work_package_card_component.rb |
Enables enhanced card metadata/footer options for Backlogs. |
frontend/src/global_styles/layout/_colors.sass |
Adds a small inline highlight dot variant. |
config/locales/en.yml |
Adds card labels for drag handle and parent. |
lookbook/docs/components/work-packages/card.md.erb |
Adds WorkPackageCard documentation. |
lookbook/previews/open_project/common/work_package_card_component_preview.rb |
Adds and updates component previews. |
lookbook/previews/open_project/common/work_package_card_component_preview/playground.html.erb |
Adds interactive playground rendering. |
lookbook/previews/open_project/common/work_package_card_component_preview/with_bottom_line.html.erb |
Adds bottom-line slot preview rendering. |
| if @show_status | ||
| flex.with_column(ml: 2) do | ||
| render WorkPackages::StatusBadgeComponent.new(status: @work_package.status) | ||
| render WorkPackages::StatusBadgeComponent.new(status: @work_package.status, scheme: @status_scheme) |
| <% if show_parent_link && work_package.parent.present? %> | ||
| <% flex.with_row do %> | ||
| <%= render( | ||
| Primer::Beta::Link.new( | ||
| href: work_package_path(work_package.parent), | ||
| underline: false, | ||
| color: :default | ||
| ) | ||
| ) do %> | ||
| <%= render(Primer::Beta::Text.new(color: :subtle)) { "#{t('.parent')}: " } %> | ||
| <%= work_package.parent.subject %> |
There was a problem hiding this comment.
True (I think).. I missed this one.
| show_assignee: true, | ||
| show_priority: true, | ||
| show_parent_link: true, |
| ) do |grid| %> | ||
| <% if show_drag_handle %> | ||
| <% grid.with_area(:drag_handle) do %> | ||
| <%= render(Primer::Beta::Octicon.new(icon: :grabber, "aria-label": t(".drag_handle.label"))) %> |
|
|
||
| <% grid.with_area(:subject) do %> | ||
| <%= render(Primer::Beta::Text.new(font_weight: :semibold)) { work_package.subject } %> | ||
| <%= render(Primer::Beta::Link.new(href: work_package_path(work_package), font_weight: :semibold)) { work_package.subject } %> |
There was a problem hiding this comment.
Can this link be optional?
I'm not sure what is specified, but for the Backlogs use case (i.e. where the whole card is draggable), I would not want to make the subject a link.
myabc
left a comment
There was a problem hiding this comment.
This looks good overall. It's definitely a massive improvement on the Backlogs page. 💯
I've left lots of comments in line. Most important things IMO to address before merging:
- menu sizes
- CSS and slot naming: I'm still working on better suggestions.
additional_detailsmight be better thanbottom_linehowever. - making subject linking optional
"Nice to haves" would be:
- a
PriorityBadgeComponentrather than inline styling. - Lookbook or Yarddocs for
InfoLineComponentitself.
| <% end %> | ||
| <% end %> | ||
|
|
||
| <% grid.with_area(:menu) do %> |
There was a problem hiding this comment.
To make the as intutitve as possible, I'd like to keep to try to keep the slot names aligned with BorderBoxComponent (#23074). There we have a separate actions and menu slot. If we conflate them, we should do so in both components.
That said, I quite like keeping the menu separate. #23218 now hides the menu slot before generating a drag preview (using a hidden-for-drag-preview class).
hide-when-print might also make sense here.
There was a problem hiding this comment.
I realise now that was mixing up slot naming and grid area naming. 🤦🏻 .. However, we should probably still try to keep things aligned if possible.
| } | ||
| ) do |grid| %> | ||
| <% if show_drag_handle %> | ||
| <% grid.with_area(:drag_handle) do %> |
There was a problem hiding this comment.
| <% grid.with_area(:drag_handle) do %> | |
| <% grid.with_area(:drag_handle, classes: "hide-when-print") do %> |
| show_project: false, | ||
| show_subject: false, | ||
| show_status: true, | ||
| status_scheme: :default, |
There was a problem hiding this comment.
Won't this break existing callers? We should document this option on InfoLineComponent too.
| "aria-label": button_aria_label || t(".label_actions"), | ||
| tooltip_direction: :se | ||
| tooltip_direction: :se, | ||
| size: :small |
There was a problem hiding this comment.
I'm not against doing this in principle, but this will break alignment with BorderBoxListComponent headers.. so we should discuss and/or allow callers to customise size.
| <% if show_parent_link && work_package.parent.present? %> | ||
| <% flex.with_row do %> | ||
| <%= render( | ||
| Primer::Beta::Link.new( | ||
| href: work_package_path(work_package.parent), | ||
| underline: false, | ||
| color: :default | ||
| ) | ||
| ) do %> | ||
| <%= render(Primer::Beta::Text.new(color: :subtle)) { "#{t('.parent')}: " } %> | ||
| <%= work_package.parent.subject %> |
There was a problem hiding this comment.
True (I think).. I missed this one.
| show_assignee: true, | ||
| show_priority: true, | ||
| show_parent_link: true, |
| <%= render( | ||
| Primer::Beta::Link.new( | ||
| href: work_package_path(work_package.parent), | ||
| underline: false, | ||
| color: :default | ||
| ) | ||
| ) do %> | ||
| <%= render(Primer::Beta::Text.new(color: :subtle)) { "#{t('.parent')}: " } %> | ||
| <%= work_package.parent.subject %> | ||
| <% end %> |
There was a problem hiding this comment.
- The font size should be
:small/ 14px here. - The "Parent: " label should be "muted" colour.
- I personally think it looks better if we don't link the "Parent: " label.
| <%= render( | |
| Primer::Beta::Link.new( | |
| href: work_package_path(work_package.parent), | |
| underline: false, | |
| color: :default | |
| ) | |
| ) do %> | |
| <%= render(Primer::Beta::Text.new(color: :subtle)) { "#{t('.parent')}: " } %> | |
| <%= work_package.parent.subject %> | |
| <% end %> | |
| <%= render(Primer::Beta::Text.new(color: :muted, font_size: :small)) do %> | |
| <%= t('.parent') %> | |
| <%= render( | |
| Primer::Beta::Link.new( | |
| href: work_package_path(work_package.parent), | |
| underline: false, | |
| color: :default | |
| ) | |
| ) do %> | |
| <%= work_package.parent.subject %> | |
| <% end %> | |
| <% end %> |
e.g.
| # @param show_parent_link [Boolean] whether to show a link to the parent work package in row 3. | ||
| # Only rendered when the work package actually has a parent. |
There was a problem hiding this comment.
nitpick: could shorten this parameter to just show_parent (but I don't feel strongly about this either).
| .op-work-package-card--actions .__hl_inline__small_dot | ||
| font-size: 0 |
There was a problem hiding this comment.
Hmm, I don't like this. I'm not 100% sure of what implications are for accessibility, etc. but it feels "hacky". Without a supporting comment it's unclear to other devs what tis code is meant to be do..
Can we not just apply an explicit class for priority-name and use the same mechanism for hiding as op-work-package-card--assignee-name.
| .op-work-package-card--actions .__hl_inline__small_dot | |
| font-size: 0 | |
| .op-work-package-card--priority-name | |
| display: none |
or - for better accessibility support (/cc @bsatarnejad):
| .op-work-package-card--actions .__hl_inline__small_dot | |
| font-size: 0 | |
| .op-work-package-card--priority-name | |
| @extend .sr-only |
(if you do do the latter though, you'll need to make the parent container position: relative to avoid being bitten by the same issue as in #23143)
| tag: :article, | ||
| classes: { "op-work-package-card_with-metric": metric? } | ||
| classes: { | ||
| "op-work-package-card_with-drag-handle": show_drag_handle, |
There was a problem hiding this comment.
nitpick: you can alias these methods as predicate in WorkPackageCardComponent:
| "op-work-package-card_with-drag-handle": show_drag_handle, | |
| "op-work-package-card_with-drag-handle": show_drag_handle?, |
alias_method :show_drag_handle?, show_drag_handle
Ticket
https://community.openproject.org/wp/73968
https://community.openproject.org/wp/73089
What are you trying to accomplish?
Layout & Structure
Metadata Row (Row 1)
show_assignee)show_priority)with_metricslot)with_menuslot)Status Display
Footer Row (Row 3)
show_parent_link) - only rendered when a parent existswith_bottom_lineslot (e.g. time tracking, custom metadata)Lookbook Documentation
Mobile behaviour
Screenshots