diff --git a/resources/boost/skills/livewire-material-development/SKILL.md b/resources/boost/skills/livewire-material-development/SKILL.md index 742b1232..bac0997f 100644 --- a/resources/boost/skills/livewire-material-development/SKILL.md +++ b/resources/boost/skills/livewire-material-development/SKILL.md @@ -458,6 +458,8 @@ A list a person chooses from is `` (or `selection="single"` / `` — outline-variant line; `vertical`, `inset` (16px start), `middle`, `decorative` (hidden from assistive tech). +`` is M3's divider with a subheader, to head a group in a list or a menu: the label (title-small, on-surface-variant) at the start, the rule 4px after it and 8px short of the end, 8px under the row. The words stay text; only the rule is the separator (`decorative` hides just the rule). Horizontal only. + ### `` A disclosure on native `
`: `` (`variant` `plain` or `filled`; `heading` slot for rich titles). Keeps its state through a morph. diff --git a/resources/views/components/divider.blade.php b/resources/views/components/divider.blade.php index b7f8d413..c77dc6bb 100644 --- a/resources/views/components/divider.blade.php +++ b/resources/views/components/divider.blade.php @@ -2,23 +2,49 @@ Horizontal by default; `vertical` stands it between items in a row (give the row a height). `inset` indents it from the start by 16px, as under a list's leading icon; `middle` from both - ends. It is `role="separator"`; with `decorative` it is hidden from assistive tech. --}} + ends. It is `role="separator"`; with `decorative` it is hidden from assistive tech. + + `text` is the divider with a subheader, as M3 draws it to head a group in a list or a menu: + the label at the start and the rule running on from it. The divider specs table gives the + geometry — "space between divider & supporting text 4dp", "divider right margin 8dp", + "divider bottom margin 8dp" — so the rule starts 4px after the words, stops 8px short of the + end and leaves 8px under the row. The label is M3's subhead: title-small in + on-surface-variant, the type the rich tooltip's specs give a subhead, since the divider's own + page names none (docs/reference/m3/components-actions-communication-containment.md + § Divider → Specs, § Tooltips → Specs). The words stay readable text that names the group + after them; only the rule is the separator, and `decorative` hides the rule and leaves the + words. `text` is for a horizontal divider; a vertical one ignores it. --}} @props([ 'vertical' => false, 'inset' => false, 'middle' => false, 'decorative' => false, + 'text' => null, ]) - +@if (filled($text) && ! $vertical) +
class([ + 'flex shrink-0 items-center gap-1 pb-2', + 'ms-4' => $inset, + 'mx-4' => $middle, + ]) }}> + {{ $text }} + +
+@else + +@endif diff --git a/resources/views/showcase/sections/containment.blade.php b/resources/views/showcase/sections/containment.blade.php index 063e3471..b2342fb2 100644 --- a/resources/views/showcase/sections/containment.blade.php +++ b/resources/views/showcase/sections/containment.blade.php @@ -98,6 +98,19 @@
LeftRight
BLADE, + 'A divider with a subheader' => <<<'BLADE' +
+ + + + + + + + + +
+ BLADE, 'Collapse bound to a property' => <<<'BLADE'
diff --git a/tests/Feature/Components/DividerTest.php b/tests/Feature/Components/DividerTest.php index cc6fe8da..3d7f8940 100644 --- a/tests/Feature/Components/DividerTest.php +++ b/tests/Feature/Components/DividerTest.php @@ -6,3 +6,21 @@ it('separates horizontally or vertically, inset on request', function () { ->and((string) $this->blade(''))->toContain('ms-4') ->and((string) $this->blade(''))->toContain('aria-hidden="true"')->not->toContain('role="separator"'); }); + +it('heads a group with a subheader, the rule running on from the words', function () { + $html = (string) $this->blade(''); + + expect($html) + ->toContain('flex shrink-0 items-center gap-1 pb-2') + ->toContain('Recent') + ->toMatch('/role="separator" aria-orientation="horizontal"\s+class="me-2 h-px min-w-0 flex-1 bg-outline-variant"/') + ->and(strpos($html, 'Recent'))->toBeLessThan(strpos($html, 'role="separator"')) + ->and((string) $this->blade(''))->toContain('flex shrink-0 items-center gap-1 pb-2 ms-4') + ->and((string) $this->blade('')) + ->toContain('>Recent') + ->toContain('aria-hidden="true"') + ->not->toContain('role="separator"') + ->and((string) $this->blade('')) + ->not->toContain('Recent') + ->toContain('aria-orientation="vertical"'); +});