Skip to content

Commit eb88b90

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 fedd30a commit eb88b90

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
@@ -221,6 +221,21 @@ def playground(
221221
end
222222
end
223223

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

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

317314
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)