-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[58734] Extract work package info line into a Primer component and do…
…cument it (#17234) * create a component for WP info line * fix spacing * change component name and simplify code * add a preview for lookbook * pass workpackage itself to the component, not its id * render info line component inside the relation component * First draft of Lookbook docs * add some docs for info line component * make fon-size configurable * make id clickable * use info-line component in meeting agenda item * use info-line component in hover card --------- Co-authored-by: Parimal Satyal <[email protected]>
- Loading branch information
1 parent
efa2212
commit 8f3bfe7
Showing
8 changed files
with
82 additions
and
38 deletions.
There are no files selected for viewing
15 changes: 2 additions & 13 deletions
15
app/components/work_package_relations_tab/relation_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
12 changes: 2 additions & 10 deletions
12
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
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
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,19 @@ | ||
<%= | ||
flex_layout do |flex| | ||
flex.with_column(mr: 2) do | ||
render(WorkPackages::HighlightedTypeComponent.new(work_package: @work_package, font_size: :small)) | ||
end | ||
flex.with_column(mr: 2) do | ||
render(Primer::Beta::Link.new( | ||
href: url_for(controller: "/work_packages", action: "show", id: @work_package), | ||
title: @work_package.subject, | ||
target: :_blank, | ||
font_size: @font_size, | ||
color: :muted | ||
)) { "##{@work_package.id}" } | ||
end | ||
flex.with_column do | ||
render WorkPackages::StatusBadgeComponent.new(status: @work_package.status) | ||
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class WorkPackages::InfoLineComponent < ApplicationComponent | ||
include OpPrimer::ComponentHelpers | ||
|
||
def initialize(work_package:, font_size: :small) | ||
super | ||
|
||
@work_package = work_package | ||
@font_size = font_size | ||
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,34 @@ | ||
The work package info line is a consistent way to display the most commonly-used set of basic work package attributes. | ||
|
||
## Overview | ||
|
||
<%= embed OpenProject::WorkPackages::InfoLineComponentPreview, :playground %> | ||
|
||
## Anatomy | ||
|
||
The info line consists of three attributes that are displayed together: | ||
|
||
- Type | ||
- ID | ||
- Status | ||
|
||
Only the ID the only interactive element; it is clickable and points the work package. All other interaction has to come from the element using this work component. | ||
|
||
## Best practices | ||
|
||
It's best to not separate these three elements in different lines. The element can, however, be wrapped in multi-line if needed. | ||
|
||
## Used in | ||
|
||
- Hovercard | ||
- Work package relations tab | ||
- Work package header | ||
- ... | ||
|
||
### Code structure | ||
|
||
You can typically call the InfoLineComponent in views where work package details (Type, ID, and Status) need to be displayed in one line. You must pass a work package object containing valid data to it. | ||
|
||
```html | ||
render(WorkPackages::InfoLineComponent.new(work_package: @work_package)) | ||
``` |
10 changes: 10 additions & 0 deletions
10
lookbook/previews/open_project/work_packages/info_line_component_preview.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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
module OpenProject::WorkPackages | ||
# @logical_path OpenProject/WorkPackages | ||
class InfoLineComponentPreview < ViewComponent::Preview | ||
def playground | ||
render(WorkPackages::InfoLineComponent.new(work_package: WorkPackage.visible.first)) | ||
end | ||
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