Skip to content

Commit f8a5606

Browse files
committed
[#75029] Document Border Box List in Lookbook
Updates Border Box references to point to higher-level Border Box List component. Also removes old Border Box examples. https://community.openproject.org/wp/75029
1 parent adffea7 commit f8a5606

7 files changed

Lines changed: 180 additions & 173 deletions

File tree

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
The Border Box List component displays compact, structured list items with
2+
optional section headers, item actions, empty states, and a footer.
3+
4+
## Overview
5+
6+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :default %>
7+
8+
## Anatomy
9+
10+
The list is structured in up to four parts:
11+
12+
**Header** *(optional)*
13+
Names the list section. It can show a count, description, action buttons, an
14+
action menu, and an optional collapse toggle. In static headers, the description
15+
renders below the heading line. In collapsible headers, the description is part
16+
of the collapsible header and is hidden when the list is collapsed.
17+
18+
**Items**
19+
The list rows. Items can render generic row content or a work package card.
20+
21+
**Empty state** *(optional)*
22+
Shown when the list has no items.
23+
24+
**Footer** *(optional)*
25+
Shown below the items. Use it for summary or follow-up content.
26+
27+
If a page shows multiple Border Box Lists and one list has a header, all
28+
comparable lists should use headers.
29+
30+
## Parameters
31+
32+
| Parameter | Type | Default | Description |
33+
|---|---|---|---|
34+
| `container` | `String`, `Symbol`, `Class`, `Object` | required | Seed used to derive stable DOM ids for the list, header, and footer |
35+
| `scheme` | `Symbol` | `:default` | Visual scheme. Use `:transparent` for list containers that should blend into their surrounding surface |
36+
| `padding` | `Symbol` | `:default` | Row padding forwarded to the underlying `Primer::Beta::BorderBox`. Supports Primer BorderBox padding values such as `:condensed`, `:default`, and `:spacious` |
37+
| `header_padding` | `Symbol` | `:inherit` | Header-only vertical padding override. Supports `:inherit`, `:condensed`, `:default`, and `:spacious` |
38+
| `interactive` | `Boolean` | `false` | Announces counter and configured empty-state updates politely to assistive technologies |
39+
| `collapsible` | `Boolean` | `false` | Renders the header as a collapsible toggle when a header is present |
40+
| `current_user` | `User` | `User.current` | User context forwarded to work package item rows |
41+
| `system_arguments` | `Hash` | `{}` | Forwarded to the underlying `Primer::Beta::BorderBox` |
42+
43+
## Slots
44+
45+
| Slot | Description |
46+
|---|---|
47+
| `with_header` | Optional section header with title, count, description, action buttons, and menu. Pass `title_arguments:` to customize the heading |
48+
| `with_item` | Generic list row that renders the provided block content |
49+
| `with_work_package_item` | Work package row that renders a work package card |
50+
| `with_empty_state` | Empty-state content rendered when no items are present |
51+
| `with_footer` | Optional footer row below the list items |
52+
53+
## Header
54+
55+
Collapsible headers add:
56+
57+
- an **arrow indicator** next to the title to show whether the section is
58+
collapsed or expanded.
59+
- an optional **header description** that gives more context to the section and
60+
is hidden when the list is collapsed.
61+
- an optional **counter** that displays the number of items in the section.
62+
63+
When collapsed, the bottom border is slightly thicker to indicate that content
64+
is hidden.
65+
66+
Both static and collapsible headers can include additional actions. For example,
67+
a menu button can offer contextual actions such as edit, delete, move up, or
68+
move down.
69+
70+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :default, params: { collapsible: true } %>
71+
72+
## Variants
73+
74+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :playground, panels: %i[params source] %>
75+
76+
### Transparent scheme
77+
78+
Use the transparent scheme for list containers that should not render a visible
79+
header background or separator, such as Backlogs sprint and inbox containers.
80+
81+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :transparent, panels: %i[params source] %>
82+
83+
### Work package items
84+
85+
Use `with_work_package_item` for rows that should render a work package card.
86+
It renders `OpenProject::Common::WorkPackageCardComponent` by default. See the
87+
[Work Package Card documentation](/lookbook/pages/components/work_packages/card)
88+
for card-specific layout, parameters, and slots.
89+
90+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :with_work_package_items, panels: %i[source] %>
91+
92+
### Empty state
93+
94+
Use `with_empty_state` when the list can be rendered without items.
95+
96+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :empty_state, panels: %i[source] %>
97+
98+
## Uses
99+
100+
Use the Border Box List for compact item collections such as:
101+
102+
- meeting agenda items.
103+
- project attributes in project settings.
104+
- configured OAuth applications.
105+
- work package lists with card-style rows.
106+
107+
If the content needs table structure with columns and column headers, use the
108+
[Border Box Table](./tables/border_box_table) component instead.
109+
110+
## Best practices
111+
112+
**Do**
113+
114+
- Use section headers when the items have logical categories, such as open and
115+
planned meetings.
116+
- Use the built-in header actions and item menus instead of composing raw
117+
BorderBox rows by hand.
118+
- Make headers and items draggable when users need to reorder sections or move
119+
items between sections.
120+
121+
**Don't**
122+
123+
- Don't mix sections with and without headers. If one section has a header, they must all have headers.
124+
- Don't make sections collapsible when users benefit from seeing all content at
125+
once.
126+
- Don't use the Border Box List for data that needs column alignment, sorting,
127+
or column headers.
128+
129+
## Technical notes
130+
131+
Use `OpenProject::Common::BorderBoxListComponent` instead of composing
132+
`Primer::Beta::BorderBox` directly when rendering OpenProject lists.
133+
Header descriptions are wrapped in `Primer::Beta::Text` with muted text color by
134+
default, and can receive Primer system arguments through `with_description`.
135+
136+
## Code structure
137+
138+
```ruby
139+
render OpenProject::Common::BorderBoxListComponent.new(
140+
container: "project-attributes",
141+
scheme: :transparent,
142+
header_padding: :default,
143+
padding: :condensed,
144+
collapsible: true
145+
) do |list|
146+
list.with_header(
147+
title: "Project attributes",
148+
title_arguments: { aria: { describedby: "project-attributes-description" } },
149+
count: true
150+
) do |header|
151+
header.with_description(id: "project-attributes-description", font_size: :small) do
152+
"Visible in the project overview"
153+
end
154+
header.with_menu(button_aria_label: "Project attribute actions") do |menu|
155+
menu.with_item(label: "Edit", href: edit_project_path(@project))
156+
end
157+
end
158+
159+
@project_attributes.each do |attribute|
160+
list.with_item { attribute.name }
161+
end
162+
163+
list.with_empty_state(
164+
title: "No attributes yet",
165+
description: "Add attributes to describe this project."
166+
)
167+
168+
list.with_footer { "Last updated: #{helpers.format_date(@project.updated_at)}" }
169+
end
170+
```
171+
172+
For lower-level details, see the [Primer BorderBox preview examples](/lookbook/inspect/primer/beta/border_box/playground)
173+
or the [collapsible header preview examples](/lookbook/inspect/primer/open_project/border_box/collapsible_header/playground).

lookbook/docs/components/border-box.md.erb

Lines changed: 0 additions & 56 deletions
This file was deleted.

lookbook/docs/components/inset-box.md.erb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ Some places where we already use the Inset Box:
3838

3939
It is useful whenever content should stand out from the page background while staying lightweight.
4040

41-
If content needs more structure (e.g., with headers, actions, or multiple items), consider using the Border Box component instead.
41+
If content needs more structure, such as headers, actions, or multiple items,
42+
consider using the Border Box List component instead.
4243

4344
## Best practices
4445

@@ -51,7 +52,8 @@ If content needs more structure (e.g., with headers, actions, or multiple items)
5152

5253
- Don’t apply arbitrary custom background colors in CSS — use the component’s options.
5354
- Don’t duplicate "grey box" styles manually; always use the Inset Box.
54-
- Don’t use Inset Box if a more structured component (like Border Box) is better suited.
55+
- Don’t use Inset Box if a more structured component, such as Border Box List,
56+
is better suited.
5557

5658
## Technical notes
5759

lookbook/docs/components/tables/border-box-table.md.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ Some examples of where we already use the Border Box table:
3131
- to display a list of configured OpenID providers
3232
- to display a list of configured SCIM clients
3333

34-
If the content does not need a table structure with column headers and grids, please use the simpler [Border Box](../border_box) component instead.
34+
If the content does not need a table structure with column headers and grids,
35+
please use the simpler [Border Box List](../border_box_list) component instead.
3536

3637
## Technical notes
3738

lookbook/previews/op_primer/border_box_component_preview.rb

Lines changed: 0 additions & 50 deletions
This file was deleted.

lookbook/previews/op_primer/border_box_component_preview/collapsible.html.erb

Lines changed: 0 additions & 64 deletions
This file was deleted.

lookbook/previews/open_project/common/border_box_list_component_preview.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
module OpenProject
3232
module Common
3333
# @logical_path OpenProject/Common
34+
# @display min_height 400px
3435
class BorderBoxListComponentPreview < ViewComponent::Preview
3536
DEFAULT_DESCRIPTION = "Coordinate launch work and keep stakeholders aligned."
3637
TRANSPARENT_DESCRIPTION = "Sprint goals, scope, and timing for the next iteration."

0 commit comments

Comments
 (0)