Skip to content

Commit 9a1f37d

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 b083930 commit 9a1f37d

7 files changed

Lines changed: 154 additions & 173 deletions

File tree

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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.
15+
16+
**Items**
17+
The list rows. Items can render generic row content or a work package card.
18+
19+
**Empty state** *(optional)*
20+
Shown when the list has no items.
21+
22+
**Footer** *(optional)*
23+
Shown below the items. Use it for summary or follow-up content.
24+
25+
If a page shows multiple Border Box Lists and one list has a header, all
26+
comparable lists should use headers.
27+
28+
## Parameters
29+
30+
| Parameter | Type | Default | Description |
31+
|---|---|---|---|
32+
| `container` | `String`, `Symbol`, `Class`, `Object` | required | Seed used to derive stable DOM ids for the list, header, and footer |
33+
| `interactive` | `Boolean` | `false` | Announces counter and configured empty-state updates politely to assistive technologies |
34+
| `collapsible` | `Boolean` | `false` | Renders the header as a collapsible toggle when a header is present |
35+
| `current_user` | `User` | `User.current` | User context forwarded to work package item rows |
36+
| `system_arguments` | `Hash` | `{}` | Forwarded to the underlying `Primer::Beta::BorderBox` |
37+
38+
## Slots
39+
40+
| Slot | Description |
41+
|---|---|
42+
| `with_header` | Optional section header with title, count, description, action buttons, and menu |
43+
| `with_item` | Generic list row that renders the provided block content |
44+
| `with_work_package_item` | Work package row that renders a work package card |
45+
| `with_empty_state` | Empty-state content rendered when no items are present |
46+
| `with_footer` | Optional footer row below the list items |
47+
48+
## Header
49+
50+
Collapsible headers add:
51+
52+
- an **arrow indicator** next to the title to show whether the section is
53+
collapsed or expanded.
54+
- an optional **header description** that gives more context to the section.
55+
The description is hidden when the list is collapsed.
56+
- an optional **counter** that displays the number of items in the section.
57+
58+
When collapsed, the bottom border is slightly thicker to indicate that content
59+
is hidden.
60+
61+
Both static and collapsible headers can include additional actions. For example,
62+
a menu button can offer contextual actions such as edit, delete, move up, or
63+
move down.
64+
65+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :default, params: { collapsible: true } %>
66+
67+
## Variants
68+
69+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :playground, panels: %i[params source] %>
70+
71+
### Work package items
72+
73+
Use `with_work_package_item` for rows that should render a work package card.
74+
75+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :with_work_package_items, panels: %i[source] %>
76+
77+
### Empty state
78+
79+
Use `with_empty_state` when the list can be rendered without items.
80+
81+
<%= embed OpenProject::Common::BorderBoxListComponentPreview, :empty_state, panels: %i[source] %>
82+
83+
## Uses
84+
85+
Use the Border Box List for compact item collections such as:
86+
87+
- meeting agenda items.
88+
- project attributes in project settings.
89+
- configured OAuth applications.
90+
- work package lists with card-style rows.
91+
92+
If the content needs table structure with columns and column headers, use the
93+
[Border Box Table](./tables/border_box_table) component instead.
94+
95+
## Best practices
96+
97+
**Do**
98+
99+
- Use section headers when the items have logical categories, such as open and
100+
planned meetings.
101+
- Use the built-in header actions and item menus instead of composing raw
102+
BorderBox rows by hand.
103+
- Make headers and items draggable when users need to reorder sections or move
104+
items between sections.
105+
106+
**Don't**
107+
108+
- Don't mix sections with and without headers. If one section has a header, they must all have headers.
109+
- Don't make sections collapsible when users benefit from seeing all content at
110+
once.
111+
- Don't use the Border Box List for data that needs column alignment, sorting,
112+
or column headers.
113+
114+
## Technical notes
115+
116+
Use `OpenProject::Common::BorderBoxListComponent` instead of composing
117+
`Primer::Beta::BorderBox` directly when rendering OpenProject lists.
118+
119+
## Code structure
120+
121+
```ruby
122+
render OpenProject::Common::BorderBoxListComponent.new(
123+
container: "project-attributes",
124+
collapsible: true
125+
) do |list|
126+
list.with_header(title: "Project attributes", count: true) do |header|
127+
header.with_description { "Visible in the project overview" }
128+
header.with_menu(button_aria_label: "Project attribute actions") do |menu|
129+
menu.with_item(label: "Edit", href: edit_project_path(@project))
130+
end
131+
end
132+
133+
@project_attributes.each do |attribute|
134+
list.with_item { attribute.name }
135+
end
136+
137+
list.with_empty_state(
138+
title: "No attributes yet",
139+
description: "Add attributes to describe this project."
140+
)
141+
142+
list.with_footer { "Last updated: #{helpers.format_date(@project.updated_at)}" }
143+
end
144+
```
145+
146+
For lower-level details, see the [Primer BorderBox preview examples](/lookbook/inspect/primer/beta/border_box/playground)
147+
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
# @label Default
3637
# @param interactive toggle

0 commit comments

Comments
 (0)