Skip to content

Commit 0d5d9e9

Browse files
committed
[DREAM-697] Add header drag-handle preview
Documents the `show_drag_handle` header option of `BorderBoxListComponent` in Lookbook, pairing the header handle with per-row `DragHandle` columns as reorderable lists render it. https://community.openproject.org/wp/DREAM-697
1 parent eca46cf commit 0d5d9e9

2 files changed

Lines changed: 35 additions & 18 deletions

File tree

lookbook/previews/open_project/common/border_box_list_component_preview.rb

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,21 @@ def playground(
220220
end
221221
end
222222

223+
# @label With header drag handle
224+
# Reorderable list whose header and rows show a drag handle.
225+
# @param padding [Symbol] select [default, condensed, spacious]
226+
# @param header_padding [Symbol] select [inherit, condensed, default, spacious]
227+
# @param collapsible toggle
228+
def with_header_drag_handle(padding: :default, header_padding: :inherit, collapsible: false)
229+
render_with_template(
230+
locals: {
231+
padding:,
232+
header_padding:,
233+
collapsible: boolean_preview_param(collapsible)
234+
}
235+
)
236+
end
237+
223238
# @label Empty state
224239
# List with a header and an empty state (Blankslate), no items.
225240
# @param padding [Symbol] select [default, condensed, spacious]
@@ -293,24 +308,6 @@ def with_collapsible_header_label(
293308
)
294309
end
295310

296-
# @label With header drag handle
297-
# @param padding [Symbol] select [default, condensed, spacious]
298-
# @param header_padding [Symbol] select [inherit, condensed, default, spacious]
299-
# @param collapsible toggle
300-
def with_header_drag_handle(padding: :default, header_padding: :inherit, collapsible: false)
301-
render OpenProject::Common::BorderBoxListComponent.new(
302-
container: "border-box-list-header-drag-handle-preview",
303-
padding:,
304-
header_padding:,
305-
collapsible: boolean_preview_param(collapsible)
306-
) do |list|
307-
list.with_header(title: "Reorderable section", count: true, show_drag_handle: true)
308-
309-
list.with_item { "First item" }
310-
list.with_item { "Second item" }
311-
end
312-
end
313-
314311
private
315312

316313
def render_label_list(container:, label:, label_scheme:, with_action_button:, padding:, header_padding:,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<%= render OpenProject::Common::BorderBoxListComponent.new(
2+
container: "border-box-list-header-drag-handle-preview",
3+
padding:,
4+
header_padding:,
5+
collapsible:
6+
) do |list| %>
7+
<% list.with_header(title: "Reorderable section", count: true, show_drag_handle: true) %>
8+
<% list.with_item do %>
9+
<%= render(Primer::OpenProject::FlexLayout.new(align_items: :center, ml: -2)) do |row| %>
10+
<% row.with_column(style: "width: 1.5rem") { render(Primer::OpenProject::DragHandle.new) } %>
11+
<% row.with_column(flex: 1) { "one" } %>
12+
<% end %>
13+
<% end %>
14+
<% list.with_item do %>
15+
<%= render(Primer::OpenProject::FlexLayout.new(align_items: :center, ml: -2)) do |row| %>
16+
<% row.with_column(style: "width: 1.5rem") { render(Primer::OpenProject::DragHandle.new) } %>
17+
<% row.with_column(flex: 1) { "two" } %>
18+
<% end %>
19+
<% end %>
20+
<% end %>

0 commit comments

Comments
 (0)