lostcoords-ui 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +296 -27
  3. data/app/assets/tailwind/lostcoords/ui/card.css +11 -5
  4. data/app/assets/tailwind/lostcoords/ui/collapsible.css +6 -0
  5. data/app/assets/tailwind/lostcoords/ui/components/dialog.css +2 -2
  6. data/app/assets/tailwind/lostcoords/ui/components/search.css +5 -0
  7. data/app/assets/tailwind/lostcoords/ui/components.css +1 -0
  8. data/app/assets/tailwind/lostcoords/ui/core.css +2 -2
  9. data/app/assets/tailwind/lostcoords/ui/popover.css +6 -56
  10. data/app/assets/tailwind/lostcoords/ui/search.css +96 -0
  11. data/app/assets/tailwind/lostcoords/ui/sheet.css +42 -69
  12. data/app/assets/tailwind/lostcoords/ui/theme.css +18 -0
  13. data/app/assets/tailwind/lostcoords/ui/toast.css +34 -4
  14. data/app/assets/tailwind/lostcoords/ui/typography.css +10 -0
  15. data/app/helpers/lostcoords/ui/badge_helper.rb +20 -12
  16. data/app/helpers/lostcoords/ui/button_helper.rb +63 -1
  17. data/app/helpers/lostcoords/ui/choice_helper.rb +9 -16
  18. data/app/helpers/lostcoords/ui/collapsible_helper.rb +23 -4
  19. data/app/helpers/lostcoords/ui/dialog_helper.rb +46 -11
  20. data/app/helpers/lostcoords/ui/form_helper.rb +23 -10
  21. data/app/helpers/lostcoords/ui/glass_helper.rb +6 -0
  22. data/app/helpers/lostcoords/ui/layout_helper.rb +13 -5
  23. data/app/helpers/lostcoords/ui/list_group_helper.rb +65 -0
  24. data/app/helpers/lostcoords/ui/menu_helper.rb +73 -13
  25. data/app/helpers/lostcoords/ui/navigation_helper.rb +57 -12
  26. data/app/helpers/lostcoords/ui/primitives_helper.rb +112 -34
  27. data/app/helpers/lostcoords/ui/render_attributes_helper.rb +2 -0
  28. data/app/helpers/lostcoords/ui/search_helper.rb +51 -0
  29. data/app/helpers/lostcoords/ui/sheet_helper.rb +20 -8
  30. data/app/helpers/lostcoords/ui/structures_helper.rb +106 -15
  31. data/app/helpers/lostcoords/ui/tailwind_helper.rb +1 -1
  32. data/app/helpers/lostcoords/ui/toast_helper.rb +11 -4
  33. data/app/helpers/lostcoords/ui/typography_helper.rb +5 -3
  34. data/app/javascript/lostcoords/ui/controllers/lc_menu_controller.js +5 -6
  35. data/app/javascript/lostcoords/ui/controllers/lc_nav_controller.js +79 -0
  36. data/app/javascript/lostcoords/ui/controllers/lc_search_controller.js +264 -0
  37. data/app/javascript/lostcoords/ui/controllers/lc_selection_controller.js +3 -8
  38. data/app/javascript/lostcoords/ui/controllers/lc_sheet_controller.js +42 -16
  39. data/app/javascript/lostcoords/ui/helpers/confirm.js +57 -0
  40. data/app/javascript/lostcoords/ui/helpers/floating_panel.js +9 -0
  41. data/app/javascript/lostcoords/ui/index.js +4 -2
  42. data/app/views/lostcoords/ui/components/_lc_collapsible.html.erb +3 -3
  43. data/app/views/lostcoords/ui/components/_lc_confirm_sheet.html.erb +14 -0
  44. data/app/views/lostcoords/ui/components/_lc_dialog.html.erb +24 -16
  45. data/app/views/lostcoords/ui/components/_lc_floating_panel.html.erb +11 -6
  46. data/app/views/lostcoords/ui/components/_lc_search.html.erb +25 -0
  47. data/config/locales/en.yml +11 -0
  48. data/config/locales/es.yml +11 -0
  49. data/config/locales/ja.yml +11 -0
  50. data/lib/lostcoords/ui/builders.rb +1 -1
  51. data/lib/lostcoords/ui/form_builder.rb +59 -12
  52. data/lib/lostcoords/ui/parts.rb +65 -8
  53. data/lib/lostcoords/ui/tokens.rb +3 -1
  54. data/lib/lostcoords/ui/version.rb +1 -1
  55. metadata +10 -2
  56. data/app/javascript/lostcoords/ui/controllers/lc_confirm_dialog_controller.js +0 -39
@@ -28,7 +28,8 @@ module Lostcoords::Ui
28
28
  end
29
29
 
30
30
  # A native checkbox. unchecked_value: submits a value when unchecked, like Rails' check_box; pass nil to omit it.
31
- # A block adds content under the label, such as a preview inside a card: true tile.
31
+ # A block adds content under the label, such as a preview inside a card: true tile. A nil label renders the
32
+ # bare input for a row selector the row labels, which then needs aria: { label: }.
32
33
  def lc_checkbox(label, name: nil, value: "1", checked: false, unchecked_value: "0", hint: nil, card: false, **attributes, &block)
33
34
  lc_choice("checkbox", label, hint, card, name, unchecked_value, { type: "checkbox", name: name, value: value, checked: checked, class: lc_checkbox_class }, attributes, &block)
34
35
  end
@@ -42,28 +43,20 @@ module Lostcoords::Ui
42
43
  lc_choice("switch", label, hint, false, name, unchecked_value, { type: "checkbox", role: "switch", name: name, value: value, checked: checked, class: lc_switch_class }, attributes)
43
44
  end
44
45
 
45
- # A fieldset of checkboxes, radios or switches with a legend, hint and error. With an id, the
46
- # fieldset's aria-describedby points at the hint and error, as lc_field does for its control.
47
- def lc_choice_group(legend:, id: nil, hint: nil, error: nil, **attributes, &block)
48
- lc_label!(legend, :legend)
49
- errors = Array(error).compact_blank
50
- described = [ ("#{id}-hint" if id && hint.present?), ("#{id}-error" if id && errors.any?) ].compact.presence&.join(" ")
51
- defaults = { id: id, class: lc_field_class(extra: "m-0 min-w-0 border-0 p-0"), aria: { invalid: (true if errors.any?), describedby: described }, data: { slot: "choice-group", invalid: (true if errors.any?) } }
52
- tag.fieldset(**lc_attributes(defaults, attributes)) do
53
- safe_join([
54
- tag.legend(legend, class: lc_field_label_class(extra: "p-0"), data: { slot: "choice-group-legend" }),
55
- tag.div(class: "flex flex-col gap-related", &block),
56
- *lc_field_messages(id, hint, errors)
57
- ])
46
+ # lc_fieldset with its checkboxes, radios or switches stacked.
47
+ def lc_choice_group(legend:, **options, &block)
48
+ lc_fieldset(legend: legend, **lc_attributes({ data: { slot: "choice-group" } }, options)) do
49
+ tag.div(class: "flex flex-col gap-related", &block)
58
50
  end
59
51
  end
60
52
 
61
53
  private
62
54
  def lc_choice(slot, label, hint, card, name, unchecked_value, defaults, attributes, &block)
63
- lc_label!(label, :label)
64
55
  input = lc_attributes(defaults.merge(data: { slot: "#{slot}-input" }), attributes)
56
+ lc_label!(label || input.dig(:aria, :label), :label)
65
57
  hidden = hidden_field_tag(name, unchecked_value, id: nil, disabled: input[:disabled]) if name && !unchecked_value.nil?
66
- lc_choice_label(slot, label, hint, safe_join([ hidden, tag.input(**input) ].compact), card: card, &block)
58
+ control = safe_join([ hidden, tag.input(**input) ].compact)
59
+ label.nil? ? control : lc_choice_label(slot, label, hint, control, card: card, &block)
67
60
  end
68
61
 
69
62
  # Shared with Lostcoords::Ui::FormBuilder, which renders its own inputs.
@@ -1,9 +1,28 @@
1
1
  module Lostcoords::Ui
2
2
  module CollapsibleHelper
3
- def lc_collapsible(title:, open: false, **attributes, &block)
4
- lc_label!(title, :title)
5
- defaults = { class: lc_card_class(extra: "lc-collapsible"), open: open, data: { slot: "collapsible", controller: "lc-collapsible", action: "click->lc-collapsible#toggle" } }
6
- render "lostcoords/ui/components/lc_collapsible", title: title, attributes: lc_attributes(defaults, attributes), content: (capture(&block) if block)
3
+ COLLAPSIBLE_INDICATORS = %i[marker chevron none].freeze
4
+
5
+ # Yields a builder; `collapsible.summary do … end` replaces the title with your own markup.
6
+ # card: false drops the card surface. summary_class: styles the summary, such as a button class.
7
+ # indicator: :chevron swaps the native marker for a chevron that turns as it opens; it follows the
8
+ # summary's content, so push it to the end with me-auto on a summary element.
9
+ def lc_collapsible(title: nil, open: false, card: true, summary_class: nil, indicator: :marker, **attributes, &block)
10
+ indicator = lc_option!(:indicator, indicator, COLLAPSIBLE_INDICATORS)
11
+ parts = Parts::Collapsible.new(self)
12
+ content = capture(parts, &block) if block
13
+ summary = parts.summary_content || title
14
+ raise ArgumentError, "lc_collapsible needs a title: or a summary part" if summary.blank?
15
+ summary = tag.span(summary, class: "me-auto") if indicator == :chevron && parts.summary_content.nil?
16
+
17
+ summary_classes = lc_tw("cursor-pointer text-label font-semibold",
18
+ ("list-none [&::-webkit-details-marker]:hidden" unless indicator == :marker),
19
+ ("flex min-h-control-md items-center gap-related" if indicator == :chevron), summary_class)
20
+ chevron = lc_icon("chevron-down", variant: :mini, options: { class: "size-4 shrink-0 text-muted-foreground", aria: { hidden: true }, data: { slot: "collapsible-indicator" } }) if indicator == :chevron
21
+ defaults = { class: (card ? lc_card_class(extra: "lc-collapsible") : "lc-collapsible"), open: open, data: { slot: "collapsible", controller: "lc-collapsible", action: "click->lc-collapsible#toggle" } }
22
+ render "lostcoords/ui/components/lc_collapsible",
23
+ summary: safe_join([ summary, chevron ].compact),
24
+ summary_attributes: lc_attributes({ class: summary_classes, data: { slot: "collapsible-summary" } }, parts.summary_attributes),
25
+ attributes: lc_attributes(defaults, attributes), content: content
7
26
  end
8
27
  end
9
28
  end
@@ -6,26 +6,61 @@ module Lostcoords::Ui
6
6
 
7
7
  ANCHORED = "data-anchored:[inset:var(--lc-dialog-top)_var(--lc-dialog-right)_auto_auto] data-anchored:m-0"
8
8
 
9
+ # The desktop width reads --lc-dialog-width, so a caller can widen the dialog or size content to it.
10
+ DIALOG_WIDTH = "sm:w-[min(var(--lc-dialog-width),calc(100vw-2rem))]"
11
+
9
12
  DIALOGS = {
10
- modal: "lc-dialog #{SHEET_DIALOG_SURFACE} sm:w-[min(92vw,31rem)]",
13
+ modal: "lc-dialog #{SHEET_DIALOG_SURFACE} #{DIALOG_WIDTH} sm:max-h-[calc(100dvh-2rem)]",
11
14
  context:
12
- "lc-dialog lc-dialog-context #{SHEET_DIALOG_SURFACE} sm:w-[min(22rem,calc(100vw-2rem))] " \
15
+ "lc-dialog lc-dialog-context #{SHEET_DIALOG_SURFACE} #{DIALOG_WIDTH} [--lc-dialog-width:22rem] " \
13
16
  "sm:max-h-[calc(100dvh-2rem)] sm:origin-(--lc-dialog-origin,center) [--lc-dialog-from:scale(0.96)] #{ANCHORED}"
14
17
  }.freeze
15
18
 
16
- def lc_dialog_class(kind = :modal, extra: nil)
17
- lc_tw("lc-squircle", DIALOGS.fetch(lc_option!(:kind, kind, DIALOGS.keys)), extra)
19
+ # Desktop widths; below sm every dialog is a full-width sheet.
20
+ DIALOG_SIZES = {
21
+ sm: "[--lc-dialog-width:24rem]",
22
+ md: "[--lc-dialog-width:32rem]",
23
+ lg: "[--lc-dialog-width:40rem]",
24
+ xl: "[--lc-dialog-width:64rem]"
25
+ }.freeze
26
+
27
+ CONFIRM_SHEET_ID = "lc-confirm-sheet"
28
+
29
+ # size: :sm, :md, :lg or :xl. A modal defaults to :md; a context dialog keeps its compact width.
30
+ def lc_dialog_class(kind = :modal, size: nil, extra: nil)
31
+ kind = lc_option!(:kind, kind, DIALOGS.keys)
32
+ size = lc_option!(:size, size, DIALOG_SIZES.keys) unless size.nil?
33
+ size ||= :md if kind == :modal
34
+ lc_tw("lc-squircle", DIALOGS.fetch(kind), (DIALOG_SIZES.fetch(size) if size), extra)
18
35
  end
19
36
 
20
- # Yields a builder with footer and close parts.
21
- def lc_dialog(id:, title:, description: nil, trigger: lc_t("lostcoords.ui.dialog.trigger"), kind: :modal, detents: "fit", **attributes, &block)
37
+ # Yields a builder with actions, footer and close parts.
38
+ # trigger: false renders only the <dialog>, for a controller of your own to open; point close_action at it.
39
+ # title_attributes: and description_attributes: reach the heading and description, for a controller that rewrites them.
40
+ def lc_dialog(id:, title:, description: nil, trigger: lc_t("lostcoords.ui.dialog.trigger"), kind: :modal, size: nil, detents: "fit",
41
+ close_action: "lc-dialog#close", close_label: nil, title_attributes: {}, description_attributes: {}, **attributes, &block)
22
42
  lc_label!(id, :id)
23
43
  lc_label!(title, :title)
24
- lc_label!(trigger, :trigger)
25
- defaults = { class: lc_dialog_class(kind), aria: { describedby: ("#{id}-description" if description.present?) }, data: lc_sheet_data({ slot: "dialog" }, detents: detents) }
26
- required = { id: id, aria: { labelledby: "#{id}-title" }, data: { lc_dialog_target: "dialog" } }
27
- render "lostcoords/ui/components/lc_dialog", id: id, title: title, description: description, trigger: trigger,
28
- attributes: lc_attributes(defaults, attributes, required), content: (capture(Parts::Dialog.new(self, id), &block) if block)
44
+ lc_label!(trigger, :trigger) unless trigger == false
45
+ lc_label!(close_action, :close_action)
46
+ detents = lc_option!(:detents, detents, SheetHelper::SHEET_DETENTS.map(&:to_sym)).to_s
47
+ defaults = { class: lc_dialog_class(kind, size: size), aria: { describedby: ("#{id}-description" if description.present?) }, data: { slot: "dialog" } }
48
+ required = { id: id, aria: { labelledby: "#{id}-title" }, data: ({ lc_dialog_target: "dialog" } if trigger) }.compact
49
+ parts = Parts::Dialog.new(self, id, close_action)
50
+ content = capture(parts, &block) if block
51
+ title_tag = tag.h2(title, **lc_attributes({ class: lc_heading_class(size: :subheading), data: { slot: "dialog-title" } }, title_attributes, { id: "#{id}-title" }))
52
+ description_tag = tag.p(description, **lc_attributes({ class: lc_text_class(size: :small, tone: :muted), data: { slot: "dialog-description" } }, description_attributes, { id: "#{id}-description" })) if description.present?
53
+ render "lostcoords/ui/components/lc_dialog", id: id, title: title_tag, description: description_tag, trigger: trigger, detents: detents,
54
+ close_action: close_action, close_label: close_label || lc_t("lostcoords.ui.dialog.close", title: title),
55
+ attributes: lc_attributes(defaults, attributes, required), actions: parts.header_actions, content: content
56
+ end
57
+
58
+ # The sheet Turbo's confirm opens. Render it once in the layout and set
59
+ # Turbo.config.forms.confirm to `confirm` from lostcoords/ui/helpers/confirm.
60
+ def lc_confirm_sheet(**attributes)
61
+ defaults = { class: lc_dialog_class(:context), data: { slot: "confirm-sheet", turbo_permanent: true } }
62
+ required = { id: CONFIRM_SHEET_ID, tabindex: -1, aria: { labelledby: "#{CONFIRM_SHEET_ID}-message", describedby: "#{CONFIRM_SHEET_ID}-description" } }
63
+ render "lostcoords/ui/components/lc_confirm_sheet", id: CONFIRM_SHEET_ID, attributes: lc_attributes(defaults, attributes, required)
29
64
  end
30
65
  end
31
66
  end
@@ -7,12 +7,15 @@ module Lostcoords::Ui
7
7
  "lc-press inline-flex items-center justify-center gap-1.5 whitespace-nowrap " \
8
8
  "h-control-sm rounded-xl border-0 bg-transparent " \
9
9
  "px-3 font-sans text-label cursor-pointer no-underline " \
10
- "text-muted-foreground hover:text-foreground " \
10
+ "text-muted-foreground not-disabled:hover:text-foreground " \
11
11
  "aria-selected:bg-background aria-selected:text-foreground " \
12
+ "aria-checked:bg-background aria-checked:text-foreground " \
12
13
  "aria-pressed:bg-background aria-pressed:text-foreground " \
14
+ "has-checked:bg-background has-checked:text-foreground " \
13
15
  "aria-[current]:not-aria-[current=false]:bg-background aria-[current]:not-aria-[current=false]:text-foreground " \
14
16
  "transition-[background-color,color,box-shadow,transform] duration-(--lc-motion-quick) ease-(--lc-ease-out) " \
15
- "disabled:opacity-40 disabled:pointer-events-none " \
17
+ "disabled:cursor-not-allowed disabled:text-[color-mix(in_oklab,var(--foreground)_38%,transparent)] " \
18
+ "has-disabled:cursor-not-allowed has-disabled:text-[color-mix(in_oklab,var(--foreground)_38%,transparent)] " \
16
19
  "[&_svg]:size-[1.1em] [&_svg]:shrink-0"
17
20
 
18
21
  TOGGLE_GROUP_ITEM_ACTIVE = "bg-background text-foreground hover:text-foreground"
@@ -26,15 +29,24 @@ module Lostcoords::Ui
26
29
  "focus:shadow-[0_0_0_calc(var(--spacing)*0.5)_var(--ring,color-mix(in_oklab,var(--primary)_50%,transparent))] " \
27
30
  "aria-invalid:border-destructive aria-invalid:shadow-[0_0_0_3px_color-mix(in_oklab,var(--destructive)_16%,transparent)]"
28
31
 
29
- FIELD_BASE = "lc-field grid min-w-0 gap-related has-aria-invalid:[&>label]:text-destructive"
32
+ FIELD_BASE = "lc-field grid min-w-0 has-aria-invalid:[&>label]:text-destructive"
33
+ FIELD_SIZES = { sm: "gap-tight", md: "gap-related" }.freeze
34
+ # Field labels use the text roles; TypographyHelper loads after this file, so its sizes are read at call time.
35
+ FIELD_LABEL_ROLES = { sm: :caption, md: :label }.freeze
30
36
 
31
37
  FIELD_LABEL_BASE =
32
- "block font-sans text-label font-semibold text-muted-foreground " \
38
+ "block font-sans font-semibold text-muted-foreground " \
33
39
  "transition-colors duration-(--lc-motion-quick) ease-(--lc-ease-out)"
34
40
 
35
41
  # form_with with Lostcoords::Ui::FormBuilder, so form.text_field, form.field and form.submit
36
- # render library controls.
37
- def lc_form_with(**options, &block)
42
+ # render library controls. card: true makes the form the card, and gap: makes it a stack, so the
43
+ # form needs no wrapper element.
44
+ def lc_form_with(card: false, padding: :md, gap: nil, **options, &block)
45
+ if card || gap
46
+ stack = lc_stack_class(gap: gap || :inset)
47
+ layout = { class: card ? lc_card_class(padding: padding, extra: stack) : stack, data: ({ slot: "card" } if card) }.compact
48
+ options = lc_attributes(layout, options)
49
+ end
38
50
  form_with(**options, builder: Lostcoords::Ui::FormBuilder, &block)
39
51
  end
40
52
 
@@ -59,12 +71,13 @@ module Lostcoords::Ui
59
71
  lc_tw(INPUT_BASE, "min-h-28 py-2 resize-y", extra)
60
72
  end
61
73
 
62
- def lc_field_class(extra: nil)
63
- lc_tw(FIELD_BASE, extra)
74
+ def lc_field_class(size: :md, extra: nil)
75
+ lc_tw(FIELD_BASE, FIELD_SIZES.fetch(lc_option!(:size, size, FIELD_SIZES.keys)), extra)
64
76
  end
65
77
 
66
- def lc_field_label_class(extra: nil)
67
- lc_tw(FIELD_LABEL_BASE, extra)
78
+ def lc_field_label_class(size: :md, extra: nil)
79
+ role = FIELD_LABEL_ROLES.fetch(lc_option!(:size, size, FIELD_LABEL_ROLES.keys))
80
+ lc_tw(FIELD_LABEL_BASE, TypographyHelper::TEXT_SIZES.fetch(role), extra)
68
81
  end
69
82
  end
70
83
  end
@@ -21,5 +21,11 @@ module Lostcoords::Ui
21
21
  def lc_glass_class(shape: :bar, thick: false, extra: nil)
22
22
  lc_tw("lc-glass", GLASS_SHAPES.fetch(lc_option!(:shape, shape, GLASS_SHAPES.keys)), (GLASS_THICK if thick), extra)
23
23
  end
24
+
25
+ GLASS_ELEMENTS = %i[div span label section aside header footer nav].freeze
26
+
27
+ def lc_glass(shape: :bar, thick: false, as: :div, **attributes, &block)
28
+ tag.public_send(lc_option!(:as, as, GLASS_ELEMENTS), **lc_attributes({ class: lc_glass_class(shape: shape, thick: thick), data: { slot: "glass" } }, attributes), &block)
29
+ end
24
30
  end
25
31
  end
@@ -10,6 +10,8 @@ module Lostcoords::Ui
10
10
  section: "gap-section"
11
11
  }.freeze
12
12
 
13
+ LAYOUT_ELEMENTS = %i[div section article aside header footer nav main form fieldset ul ol li].freeze
14
+
13
15
  CONTAINER_SIZES = {
14
16
  page: "lc-container-page max-w-page",
15
17
  reading: "max-w-reading",
@@ -36,12 +38,13 @@ module Lostcoords::Ui
36
38
  lc_inline_class(extra: lc_tw("min-h-control-md justify-between", extra))
37
39
  end
38
40
 
39
- def lc_stack(gap: :content, **attributes, &block)
40
- tag.div(**lc_attributes({ class: lc_stack_class(gap: gap) }, attributes), &block)
41
+ # as: picks the element, such as :section, :ul or :form, for layout that carries meaning.
42
+ def lc_stack(gap: :content, as: :div, **attributes, &block)
43
+ tag.public_send(lc_option!(:as, as, LAYOUT_ELEMENTS), **lc_attributes({ class: lc_stack_class(gap: gap) }, attributes), &block)
41
44
  end
42
45
 
43
- def lc_inline(gap: :related, **attributes, &block)
44
- tag.div(**lc_attributes({ class: lc_inline_class(gap: gap) }, attributes), &block)
46
+ def lc_inline(gap: :related, as: :div, **attributes, &block)
47
+ tag.public_send(lc_option!(:as, as, LAYOUT_ELEMENTS), **lc_attributes({ class: lc_inline_class(gap: gap) }, attributes), &block)
45
48
  end
46
49
 
47
50
  def lc_container(size: :page, **attributes, &block)
@@ -54,9 +57,14 @@ module Lostcoords::Ui
54
57
  tag.section(**lc_attributes({ class: lc_stack_class(gap: :heading) }, attributes)) do
55
58
  heading = lc_heading(title, level: level, size: :heading)
56
59
  action_content = actions.respond_to?(:call) ? capture(&actions) : actions
57
- header = tag.header(class: lc_section_header_class) { safe_join([ heading, action_content ].compact) }
60
+ header = lc_section_header { safe_join([ heading, action_content ].compact) }
58
61
  safe_join([ header, lc_stack(&block) ])
59
62
  end
60
63
  end
64
+
65
+ # The heading row of a section whose heading needs more than a title, such as a lede under it.
66
+ def lc_section_header(as: :header, **attributes, &block)
67
+ tag.public_send(lc_option!(:as, as, %i[header div]), **lc_attributes({ class: lc_section_header_class }, attributes), &block)
68
+ end
61
69
  end
62
70
  end
@@ -0,0 +1,65 @@
1
+ module Lostcoords::Ui
2
+ module ListGroupHelper
3
+ LIST_ROW = "lc-list-row min-w-0 bg-card text-card-foreground first:rounded-t-3xl last:rounded-b-3xl lc-squircle"
4
+ LIST_ITEM = "flex min-h-16 min-w-0 items-center gap-heading px-content py-heading text-start sm:px-inset"
5
+ LIST_ROW_PADDING = "px-content py-heading sm:px-inset"
6
+ LIST_ICON = "grid size-10 shrink-0 place-items-center rounded-full bg-tile [&>svg:not([class*='size-'])]:size-4.5"
7
+ LIST_ROW_TAGS = %i[div li label details a].freeze
8
+
9
+ # A titled group of list rows: the heading, then the block, then an optional footnote. The block
10
+ # holds lc_list_group and anything that belongs with it, such as the form that wraps the rows.
11
+ def lc_list_section(heading, footnote: nil, level: 2, **attributes, &block)
12
+ lc_label!(heading, :heading)
13
+ raise ArgumentError, "Invalid level: #{level.inspect}. Expected an integer from 1 to 6" unless level.is_a?(Integer) && (1..6).include?(level)
14
+
15
+ heading_id = "#{attributes[:id]}-heading" if attributes[:id]
16
+ tag.section(**lc_attributes({ class: "grid min-w-0 gap-related", aria: { labelledby: heading_id }, data: { slot: "list-section" } }, attributes)) do
17
+ safe_join([
18
+ tag.public_send("h#{level}", heading, id: heading_id, class: "m-0 px-content text-label font-semibold text-muted-foreground sm:px-inset", data: { slot: "list-heading" }),
19
+ (capture(&block) if block),
20
+ (tag.p(footnote, class: "m-0 px-content text-small text-muted-foreground sm:px-inset [&_a]:text-foreground [&_a]:underline [&_a]:underline-offset-4", data: { slot: "list-footnote" }) if footnote.present?)
21
+ ].compact)
22
+ end
23
+ end
24
+
25
+ # Rows as in iOS settings: each row is its own card-coloured panel, 2px apart, and only the
26
+ # first and last rows round.
27
+ def lc_list_group(tag: :div, **attributes, &block)
28
+ tag = lc_option!(:tag, tag, %i[div ul])
29
+ content_tag(tag, (capture(&block) if block), **lc_attributes({ class: "m-0 grid min-w-0 list-none gap-0.5 p-0", data: { slot: "list-group" } }, attributes))
30
+ end
31
+
32
+ # With a title, the row lays out icon:, the title and subtitle, then the block as its trailing
33
+ # content. Without one, the block is the whole row; padded: false drops the row's padding for
34
+ # content that pads itself, such as an lc_list_item button. href: makes the row a link.
35
+ def lc_list_row(title = nil, subtitle: nil, icon: nil, href: nil, tag: nil, padded: true, **attributes, &block)
36
+ tag = lc_option!(:tag, tag || (href ? :a : :div), LIST_ROW_TAGS)
37
+ raise ArgumentError, "href: needs tag: :a" if href && tag != :a
38
+
39
+ link = ("no-underline transition-colors duration-(--lc-motion-quick) hover:bg-accent" if href)
40
+ defaults = { href: href, data: { slot: "list-row" } }
41
+ return lc_list_item(title, subtitle: subtitle, icon: icon, tag: tag, **lc_attributes(defaults.merge(class: lc_tw(LIST_ROW, link)), attributes), &block) if title.present?
42
+
43
+ classes = lc_tw(LIST_ROW, (LIST_ROW_PADDING if padded), link)
44
+ content_tag(tag, (capture(&block) if block), **lc_attributes(defaults.merge(class: classes), attributes))
45
+ end
46
+
47
+ # The row layout without the row's surface, for an element inside a free-form row: a summary, a
48
+ # button that opens an editor. icon: takes an icon name or your own markup, such as a logo.
49
+ def lc_list_item(title, subtitle: nil, icon: nil, tag: :div, **attributes, &block)
50
+ lc_label!(title, :title)
51
+ glyph = icon.is_a?(ActiveSupport::SafeBuffer) ? icon : lc_icon(icon) if icon.present?
52
+ content_tag(tag, **lc_attributes({ class: LIST_ITEM, data: { slot: "list-item" } }, attributes)) do
53
+ text = safe_join([
54
+ content_tag(:span, title, class: "font-semibold", data: { slot: "list-title" }),
55
+ (content_tag(:span, subtitle, class: "text-small text-muted-foreground [overflow-wrap:anywhere]", data: { slot: "list-subtitle" }) if subtitle.present?)
56
+ ].compact)
57
+ safe_join([
58
+ (content_tag(:span, glyph, class: LIST_ICON, aria: { hidden: true }, data: { slot: "list-icon" }) if glyph),
59
+ content_tag(:span, text, class: "grid min-w-0 flex-1 gap-0.5", data: { slot: "list-text" }),
60
+ (capture(&block) if block)
61
+ ].compact)
62
+ end
63
+ end
64
+ end
65
+ end
@@ -5,7 +5,8 @@ module Lostcoords::Ui
5
5
  "lc-menu__popover lc-squircle lc-popover-shell hidden absolute top-[calc(100%+--spacing(1))] end-0 overscroll-contain [&_form]:m-0"
6
6
 
7
7
  MENU_POPOVER_BASE =
8
- "data-open:flex flex-col gap-px z-(--lc-z-popover) p-related " \
8
+ "data-open:grid grid-cols-[auto_minmax(0,1fr)_auto] content-start gap-y-px [&>*]:col-span-full " \
9
+ "[&_[data-slot=menu-item]]:grid-cols-subgrid z-(--lc-z-popover) p-related " \
9
10
  "min-w-56 max-w-[calc(100vw-clamp(1rem,3vw,1.5rem)*2)] max-h-[min(24rem,70vh)] overflow-y-auto"
10
11
 
11
12
  MENU_POPOVER_ALIGN = {
@@ -15,7 +16,7 @@ module Lostcoords::Ui
15
16
  }.freeze
16
17
 
17
18
  MENU_OPTION_BASE =
18
- "lc-menu__item lc-press [--lc-press-scale:0.98] group/option grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 w-full " \
19
+ "lc-menu__item lc-press [--lc-press-scale:0.98] group/option grid col-span-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 w-full " \
19
20
  "min-h-control-md px-3 py-1.5 rounded-2xl lc-squircle border-none bg-transparent text-start font-sans text-label text-foreground " \
20
21
  "no-underline cursor-pointer transition-[background-color] duration-120 [--lc-avatar-size:--spacing(7)] " \
21
22
  "hover:bg-accent focus-visible:bg-accent focus-visible:outline-none " \
@@ -26,6 +27,14 @@ module Lostcoords::Ui
26
27
  destructive: "text-destructive hover:bg-destructive-soft focus-visible:bg-destructive-soft"
27
28
  }.freeze
28
29
 
30
+ MENU_OPTION_LEADING = "col-start-1 me-3 grid min-w-5 place-items-center text-lg leading-none"
31
+ MENU_OPTION_ICON = "size-5 text-muted-foreground group-aria-checked/option:text-primary group-data-[tone=destructive]/option:text-current"
32
+ MENU_OPTION_LABEL = "col-start-2 grid min-w-0 group-aria-checked/option:font-semibold"
33
+ MENU_OPTION_HINT = "text-caption font-normal text-muted-foreground"
34
+ MENU_OPTION_CHECK = "col-start-3 ms-3 size-4 text-primary invisible group-aria-checked/option:visible"
35
+
36
+ MENU_TRIGGERS = %i[button icon].freeze
37
+
29
38
  def lc_popover_class(align: :end, extra: nil)
30
39
  lc_glass_class(shape: :menu, extra: lc_tw(POPOVER_BASE, MENU_POPOVER_ALIGN.fetch(lc_option!(:align, align, MENU_POPOVER_ALIGN.keys)), extra))
31
40
  end
@@ -38,23 +47,49 @@ module Lostcoords::Ui
38
47
  lc_tw(MENU_OPTION_BASE, MENU_OPTION_TONES.fetch(lc_option!(:tone, tone, MENU_OPTION_TONES.keys)), extra)
39
48
  end
40
49
 
41
- def lc_menu(id:, label: lc_t("lostcoords.ui.menu.label"), align: :end, **attributes, &block)
50
+ # trigger: :icon renders a quiet icon button named by label; rendered HTML becomes the content
51
+ # of a custom trigger, also named by label.
52
+ def lc_menu(id:, label: lc_t("lostcoords.ui.menu.label"), align: :end, trigger: :button, icon: "ellipsis-vertical", trigger_attributes: {}, wrapper_attributes: {}, **attributes, &block)
42
53
  align = lc_option!(:align, align, MENU_POPOVER_ALIGN.keys)
43
- lc_render_panel(id, label, nil, "lc-menu", "menu", lc_menu_popover_class(align: align), lc_attributes({ data: { slot: "menu" } }, attributes), &block)
54
+ default_trigger = ->(wiring) { lc_panel_trigger(label, trigger, icon, :secondary, wiring) } unless trigger == false
55
+ lc_render_panel(id, label, nil, "lc-menu", "menu", lc_menu_popover_class(align: align), lc_attributes({ data: { slot: "menu" } }, attributes), default_trigger, trigger_attributes, wrapper_attributes, &block)
44
56
  end
45
57
 
46
- def lc_popover(id:, label: lc_t("lostcoords.ui.popover.trigger"), title: nil, align: :end, trigger_variant: :secondary, **attributes, &block)
58
+ # Takes the same trigger options as lc_menu, including trigger: false.
59
+ def lc_popover(id:, label: lc_t("lostcoords.ui.popover.trigger"), title: nil, align: :end, trigger_variant: :secondary, trigger: :button, icon: "ellipsis-vertical", trigger_attributes: {}, wrapper_attributes: {}, **attributes, &block)
47
60
  title = title.presence
48
61
  align = lc_option!(:align, align, MENU_POPOVER_ALIGN.keys)
62
+ default_trigger = ->(wiring) { lc_panel_trigger(label, trigger, icon, trigger_variant, wiring) } unless trigger == false
49
63
  classes = lc_popover_class(align: align, extra: "data-open:flex flex-col gap-content p-inset z-(--lc-z-popover) min-w-64 max-w-[calc(100vw-2rem)]")
50
- lc_render_panel(id, label, title, "lc-popover", "dialog", classes, lc_attributes({ data: { slot: "popover" } }, attributes), trigger_variant: trigger_variant, &block)
64
+ lc_render_panel(id, label, title, "lc-popover", "dialog", classes, lc_attributes({ data: { slot: "popover" } }, attributes), default_trigger, trigger_attributes, wrapper_attributes, &block)
51
65
  end
52
66
 
53
- def lc_menu_option(label = nil, href: nil, tone: :default, **attributes, &block)
67
+ # icon: names a leading Heroicon; leading: takes other rendered content, such as an avatar, and is
68
+ # hidden from assistive technology so the label stays the name. checked: true or false makes a
69
+ # menuitemradio with a check mark. checkbox: true makes a menuitemcheckbox that flips on click and
70
+ # leaves the menu open. method: renders a button_to form for href.
71
+ def lc_menu_option(label = nil, href: nil, tone: :default, icon: nil, leading: nil, hint: nil, checked: nil, checkbox: false, method: nil, params: {}, form: {}, **attributes, &block)
54
72
  tone = lc_option!(:tone, tone, MENU_OPTION_TONES.keys)
55
- content = tag.span(block ? capture(&block) : label, class: "col-span-3")
56
- defaults = { class: lc_menu_option_class(tone: tone), role: "menuitem", data: { slot: "menu-item", action: "click->lc-menu#close" } }
57
- if href
73
+ raise ArgumentError, "Pass icon: or leading:, not both" if icon && leading
74
+ raise ArgumentError, "checked: must be true, false or nil" unless [ true, false, nil ].include?(checked)
75
+ raise ArgumentError, "method: needs an href:" if method && !href
76
+ raise ArgumentError, "checkbox: true renders a button; drop href:" if checkbox && href
77
+ checked = !!checked if checkbox
78
+
79
+ leading = lc_icon(icon, options: { class: MENU_OPTION_ICON }) if icon
80
+ text = block ? capture(&block) : label
81
+ content = safe_join([
82
+ (tag.span(leading, class: MENU_OPTION_LEADING, aria: { hidden: true }, data: { slot: "menu-item-leading" }) if leading),
83
+ tag.span(hint ? safe_join([ tag.span(text), tag.span(hint, class: MENU_OPTION_HINT, data: { slot: "menu-item-hint" }) ]) : text, class: MENU_OPTION_LABEL),
84
+ (lc_icon("check", variant: :mini, options: { class: MENU_OPTION_CHECK, "aria-hidden": true }) unless checked.nil?)
85
+ ])
86
+ role = checkbox ? "menuitemcheckbox" : (checked.nil? ? "menuitem" : "menuitemradio")
87
+ defaults = { class: lc_menu_option_class(tone: tone, extra: "gap-x-0"), role: role, data: { slot: "menu-item", tone: tone, action: checkbox ? "click->lc-menu#check" : "click->lc-menu#close" } }
88
+ defaults[:aria] = { checked: checked } unless checked.nil?
89
+
90
+ if method
91
+ button_to(content, href, **lc_attributes(defaults, attributes), method: method, params: params, form: lc_attributes({ class: "contents" }, form))
92
+ elsif href
58
93
  raise ArgumentError, "Links cannot be disabled; use a menu button instead" if attributes[:disabled] || attributes["disabled"]
59
94
 
60
95
  tag.a(content, **lc_attributes(defaults.merge(href: href), attributes))
@@ -64,13 +99,38 @@ module Lostcoords::Ui
64
99
  end
65
100
 
66
101
  private
67
- def lc_render_panel(id, label, title, controller, role, classes, attributes, trigger_variant: :secondary, &block)
102
+ def lc_panel_trigger(label, trigger, icon, variant, attributes)
103
+ custom = trigger.is_a?(String) && trigger.html_safe?
104
+ kind = custom ? :custom : lc_option!(:trigger, trigger, MENU_TRIGGERS)
105
+ case kind
106
+ when :custom, :icon
107
+ content = custom ? trigger : lc_icon(icon, options: { "aria-hidden": true })
108
+ icon_button = { type: "button", class: lc_icon_button_class(shape: :circle, size: :md, extra: ButtonHelper::ICON_BUTTON_QUIET), aria: { label: label }, data: { slot: "icon-button" } }
109
+ tag.button(content, **lc_attributes(icon_button, attributes))
110
+ else
111
+ lc_button(label, variant: variant, **attributes)
112
+ end
113
+ end
114
+
115
+ # The block runs before the default trigger renders, so a menu.trigger part can replace it.
116
+ # trigger: false renders only the panel, for a caller that hosts the controller on an ancestor
117
+ # and wires its own triggers.
118
+ def lc_render_panel(id, label, title, controller, role, classes, attributes, default_trigger, trigger_attributes, wrapper_attributes, &block)
68
119
  lc_label!(id, :id)
69
120
  lc_label!(label, :label)
70
- required = { id: id, role: role, aria: { labelledby: "#{id}-#{title ? 'title' : 'trigger'}" }, data: { "#{controller}_target" => "popover" } }
121
+ standalone = default_trigger.nil?
122
+ raise ArgumentError, "trigger: false renders no trigger or wrapper" if standalone && (trigger_attributes.present? || wrapper_attributes.present?)
123
+
124
+ wiring = { id: "#{id}-trigger", aria: { haspopup: role, expanded: false, controls: id }, data: { "#{controller}_target" => "trigger", action: "#{controller}#toggle" } }
125
+ parts = Parts::Panel.new(self, wiring)
126
+ content = capture(parts, &block) if block
127
+ trigger = parts.rendered_trigger || default_trigger.call(lc_attributes(trigger_attributes, wiring)) unless standalone
128
+ name = if title then { labelledby: "#{id}-title" } elsif standalone then { label: label } else { labelledby: "#{id}-trigger" } end
129
+ required = { id: id, role: role, aria: name, data: { "#{controller}_target" => "popover" } }
71
130
  required[:tabindex] = -1 if role == "dialog"
72
131
  merged = lc_attributes({ class: classes }, attributes, required)
73
- render "lostcoords/ui/components/lc_floating_panel", id: id, label: label, title: title, controller: controller, role: role, trigger_variant: trigger_variant, attributes: merged, content: (capture(&block) if block)
132
+ wrapper = lc_attributes({ class: "relative inline-flex" }, wrapper_attributes, { data: { controller: controller } }) unless standalone
133
+ render "lostcoords/ui/components/lc_floating_panel", id: id, title: title, wrapper: wrapper, trigger: trigger, attributes: merged, content: content
74
134
  end
75
135
  end
76
136
  end
@@ -8,8 +8,38 @@ module Lostcoords::Ui
8
8
  primary: "text-primary decoration-current/40 hover:decoration-current"
9
9
  }.freeze
10
10
 
11
- NAV_LINK = "flex min-w-0 items-center rounded-xl lc-squircle no-underline transition-colors duration-(--lc-motion-quick) " \
12
- "text-muted-foreground hover:text-foreground aria-[current=page]:text-foreground"
11
+ NAV_LINK = "flex min-w-0 items-center gap-related rounded-xl lc-squircle no-underline transition-colors duration-(--lc-motion-quick) " \
12
+ "text-muted-foreground hover:text-foreground aria-[current=page]:text-foreground [&_svg]:shrink-0 " \
13
+ "group-data-[indicator]/nav:relative group-data-[indicator]/nav:aria-[current=page]:bg-transparent"
14
+
15
+ # Each layout styles the list and its links; the indicator fill follows the links' corners.
16
+ NAV_LAYOUTS = {
17
+ column: {
18
+ list: "m-0 flex list-none flex-col gap-px p-0",
19
+ link: "[&_svg]:size-4.5",
20
+ indicator: "rounded-xl lc-squircle"
21
+ },
22
+ row: {
23
+ list: "m-0 flex min-w-0 list-none flex-wrap items-center gap-tight p-0",
24
+ link: "shrink-0 justify-center [&_svg]:size-4.5",
25
+ indicator: "rounded-xl lc-squircle"
26
+ },
27
+ dock: {
28
+ list: "m-0 grid list-none grid-flow-col auto-cols-fr gap-0.5 rounded-pill p-tight",
29
+ link: "min-h-14 flex-col justify-center gap-0.5 rounded-pill px-0 text-caption font-semibold hover:bg-transparent [&_svg]:size-6",
30
+ indicator: "rounded-pill"
31
+ },
32
+ responsive: {
33
+ list: "m-0 list-none p-0 max-sm:grid max-sm:grid-flow-col max-sm:auto-cols-fr max-sm:gap-0.5 max-sm:rounded-pill max-sm:p-tight " \
34
+ "sm:flex sm:min-w-0 sm:flex-wrap sm:items-center sm:gap-tight",
35
+ link: "justify-center max-sm:min-h-14 max-sm:flex-col max-sm:gap-0.5 max-sm:rounded-pill max-sm:px-0 max-sm:text-caption " \
36
+ "max-sm:font-semibold max-sm:hover:bg-transparent max-sm:[&_svg]:size-6 sm:shrink-0 sm:[&_svg]:size-4.5",
37
+ indicator: "max-sm:rounded-pill sm:rounded-xl lc-squircle"
38
+ }
39
+ }.freeze
40
+ NAV_INDICATOR = "pointer-events-none absolute start-0 top-0 bg-(--lc-nav-indicator,var(--accent)) opacity-0 " \
41
+ "transition-[translate,width,height,opacity] duration-[400ms] ease-(--lc-ease-out-expo) motion-reduce:transition-none " \
42
+ "group-data-[indicator]/nav:opacity-100"
13
43
 
14
44
  # An inline text link. Prose inside lc_prose styles its links already.
15
45
  def lc_link_class(tone: :inherit, extra: nil)
@@ -27,17 +57,30 @@ module Lostcoords::Ui
27
57
  link_to(content, url, **lc_attributes({ class: lc_link_class(tone: tone), data: { slot: "link" } }, attributes))
28
58
  end
29
59
 
30
- # compact: true is the quieter style for an "On this page" list.
31
- def lc_nav_link_class(compact: false, extra: nil)
60
+ # compact: true is the quieter style for an "On this page" list, in the column layout only.
61
+ def lc_nav_link_class(compact: false, layout: :column, extra: nil)
62
+ layout = lc_option!(:layout, layout, NAV_LAYOUTS.keys)
63
+ raise ArgumentError, "compact: true needs layout: :column" if compact && layout != :column
64
+
32
65
  size = compact ? "py-tight text-small aria-[current=page]:font-medium" : "min-h-control-md px-3 py-1.5 text-label hover:bg-accent aria-[current=page]:bg-accent aria-[current=page]:font-semibold"
33
- lc_tw(NAV_LINK, size, extra)
66
+ lc_tw(NAV_LINK, size, (NAV_LAYOUTS.dig(layout, :link) unless compact), extra)
34
67
  end
35
68
 
36
69
  # Yields a builder with link and group parts; links mark the current page with aria-current.
37
- def lc_nav_list(label:, compact: false, **attributes, &block)
70
+ # layout: :row lays links in a line, :dock stacks each icon above its label in equal cells for a
71
+ # phone's bottom bar, and :responsive is a dock below sm and a row from sm. indicator: true slides
72
+ # one fill to the current link, starting where it was on the previous page.
73
+ def lc_nav_list(label:, compact: false, layout: :column, indicator: false, **attributes, &block)
38
74
  lc_label!(label, :label)
39
- tag.nav(**lc_attributes({ aria: { label: label }, data: { slot: "nav-list", compact: (true if compact) } }, attributes)) do
40
- tag.ul(capture(Parts::NavList.new(self, compact), &block), class: "m-0 flex list-none flex-col gap-px p-0")
75
+ layout = lc_option!(:layout, layout, NAV_LAYOUTS.keys)
76
+ raise ArgumentError, "compact: true needs layout: :column" if compact && layout != :column
77
+
78
+ data = { slot: "nav-list", compact: (true if compact), layout: (layout unless layout == :column), controller: ("lc-nav" if indicator) }.compact
79
+ tag.nav(**lc_attributes({ class: ("group/nav relative" if indicator), aria: { label: label }, data: data }, attributes)) do
80
+ safe_join([
81
+ (tag.span(class: lc_tw(NAV_INDICATOR, NAV_LAYOUTS.dig(layout, :indicator)), aria: { hidden: true }, data: { slot: "nav-indicator", lc_nav_target: "indicator" }) if indicator),
82
+ tag.ul(capture(Parts::NavList.new(self, compact, layout, indicator), &block), class: NAV_LAYOUTS.dig(layout, :list))
83
+ ].compact)
41
84
  end
42
85
  end
43
86
 
@@ -106,8 +149,8 @@ module Lostcoords::Ui
106
149
 
107
150
  # Yields a builder; each `tabs.panel "Label" do … end` adds a tab and its panel.
108
151
  # orientation: :vertical stacks the tabs beside the panels and moves them with Arrow Up and Down.
109
- # activation: :manual moves focus with the arrows and selects with Enter or Space.
110
- def lc_tabs(id:, label:, selected: nil, orientation: :horizontal, activation: :automatic, **attributes, &block)
152
+ # activation: :manual moves focus with the arrows and selects with Enter or Space. list: adds attributes to the tab list.
153
+ def lc_tabs(id:, label:, selected: nil, orientation: :horizontal, activation: :automatic, list: {}, **attributes, &block)
111
154
  lc_label!(id, :id)
112
155
  lc_label!(label, :label)
113
156
  orientation = lc_option!(:orientation, orientation, TABS_ORIENTATIONS.keys)
@@ -123,7 +166,9 @@ module Lostcoords::Ui
123
166
  key = ->(panel) { "#{id}-#{panel.value.gsub(/[^\w-]+/, '-')}" }
124
167
  ids = tabs.panels.map(&key)
125
168
  raise ArgumentError, "tab values #{tabs.panels.map(&:value).inspect} produce duplicate ids" unless ids.uniq.size == ids.size
126
- list = tag.div(role: "tablist", aria: { label: label, orientation: (orientation if orientation == :vertical) }, class: lc_toggle_group_class(extra: layout[:list]), data: { slot: "tabs-list" }) do
169
+ list_attributes = lc_attributes({ class: lc_toggle_group_class(extra: layout[:list]), data: { slot: "tabs-list" } }, list,
170
+ { role: "tablist", aria: { label: label, orientation: (orientation if orientation == :vertical) } })
171
+ tablist = tag.div(**list_attributes) do
127
172
  safe_join(tabs.panels.map do |panel|
128
173
  active = panel.value == selected
129
174
  tag.button(panel.label, type: "button", role: "tab", id: "#{key.(panel)}-tab", tabindex: (active ? 0 : -1),
@@ -137,7 +182,7 @@ module Lostcoords::Ui
137
182
  end
138
183
  data = { slot: "tabs", controller: "lc-tabs", lc_tabs_activation_value: (activation.to_s if activation == :manual) }.compact
139
184
  tag.div(**lc_attributes({ id: id, class: layout[:root], data: data }, attributes)) do
140
- safe_join([ list, *panels ])
185
+ safe_join([ tablist, *panels ])
141
186
  end
142
187
  end
143
188
  end