Files
livewire-material/resources/views/showcase/sections/buttons.blade.php
T
Andreas Reinhold / reiniandClaude Opus 5 ebdcdb82b5 Write the showcase examples without showcase-only hooks
Plan step 38 review: the component sections' code samples, which an
application copies, carried 60 data-md-showcase-* hooks that only
showcase.css draws (a sized loading indicator, the plain badge's own
colours, a bordered bar frame, the navigation demos' frames, a table's
scroll wrapper...), so a copied sample did nothing in the application.
They now write what an application has: <x-surface outlined corner>
for a frame and a line, <x-row> for the FAB menu's corner, and an
inline style from the tokens for a size, a scroll box or a colour,
as the Containment batch already did. The side sheet demo takes
align="stretch", which holds in both of <x-row stack-below>'s modes,
instead of a hook that undid align="start" once stacked. The menu
icon colours go through icon-class with two unlayered application-like
classes, which the sample's comment names, and the fields' and date
picker's widths are inline styles now that style reaches their roots.
The radio hint said "from sm"; it is medium.

showcase.css keeps only the frame and the foundation specimens; its
header describes the file instead of the batches that wrote it. The
tests reject a showcase hook or a class outside md-* and the named
application classes in any example, a showcase.css selector outside
its own hooks, and a hook no showcase view renders.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
2026-09-15 06:21:18 +02:00

186 lines
11 KiB
PHP

@php
$examples = [
'Variants' => <<<'BLADE'
<x-button label="Filled" variant="filled" />
<x-button label="Tonal" variant="tonal" />
<x-button label="Outlined" variant="outlined" />
<x-button label="Elevated" variant="elevated" />
<x-button label="Text" />
BLADE,
'Sizes, with an icon' => <<<'BLADE'
<x-button label="Extra small" icon="upload" variant="filled" size="xs" />
<x-button label="Small" icon="upload" variant="filled" />
<x-button label="Medium" icon="upload" variant="filled" size="md" />
<x-button label="Large" icon="upload" variant="filled" size="lg" />
<x-button label="Extra large" icon="upload" variant="filled" size="xl" />
BLADE,
'Square, and pressed (hold the pointer down)' => <<<'BLADE'
<x-button label="Round" variant="tonal" size="md" />
<x-button label="Square" variant="tonal" size="md" shape="square" />
BLADE,
'Colours' => <<<'BLADE'
<x-button label="Primary" primary />
<x-button label="Secondary" variant="filled" color="secondary" />
<x-button label="Tertiary" variant="filled" color="tertiary" />
<x-button label="Delete" icon="delete" danger />
<x-button label="Take down" caution />
<x-button label="Success" variant="tonal" color="success" />
<x-button label="Info" variant="outlined" color="info" />
BLADE,
'Toggle buttons' => <<<'BLADE'
<x-button label="Filled" variant="filled" :selected="false" />
<x-button label="Selected" variant="filled" :selected="true" />
<x-button label="Tonal" variant="tonal" :selected="false" />
<x-button label="Selected" variant="tonal" :selected="true" />
<x-button label="Outlined" variant="outlined" :selected="false" />
<x-button label="Selected" variant="outlined" :selected="true" />
BLADE,
'Icon buttons, and their tooltips' => <<<'BLADE'
<x-button icon="favorite" tooltip="Standard" />
<x-button icon="favorite" tooltip="Filled" variant="filled" />
<x-button icon="favorite" tooltip="Tonal" variant="tonal" />
<x-button icon="favorite" tooltip="Outlined" variant="outlined" />
<x-button icon="favorite" tooltip="Selected" variant="filled" :selected="true" />
<x-button icon="favorite" tooltip="Selected, square" variant="tonal" shape="square" :selected="true" />
BLADE,
'Icon button sizes and widths' => <<<'BLADE'
<x-button icon="share" tooltip="XS narrow" variant="tonal" size="xs" width="narrow" />
<x-button icon="share" tooltip="S" variant="tonal" />
<x-button icon="share" tooltip="M wide" variant="tonal" size="md" width="wide" />
<x-button icon="share" tooltip="L" variant="tonal" size="lg" />
<x-button icon="share" tooltip="XL wide" variant="tonal" size="xl" width="wide" />
BLADE,
'Links and disabled' => <<<'BLADE'
<x-button label="Opens a page" link="#buttons" variant="outlined" />
<x-button label="Leaves the site" link="https://m3.material.io" external icon-right="open_in_new" />
<x-button label="Disabled" variant="filled" disabled />
<x-button label="Disabled link" link="#buttons" variant="tonal" disabled />
<x-button icon="delete" tooltip="Disabled" variant="outlined" disabled />
BLADE,
'Loading indicator' => <<<'BLADE'
<x-loading />
<x-loading contained />
<x-loading label="Uploading" style="width: 96px; height: 96px; color: var(--md-sys-color-tertiary);" />
<x-loading contained style="width: 32px; height: 32px;" />
BLADE,
'Button groups: standard (press a button) and connected' => <<<'BLADE'
<x-button-group label="Standard" size="md">
<x-button label="Day" variant="tonal" size="md" />
<x-button label="Week" variant="tonal" size="md" />
<x-button label="Month" variant="tonal" size="md" />
</x-button-group>
<x-button-group label="Formatting" connected>
<x-button icon="format_bold" aria-label="Bold" variant="tonal" :selected="true" />
<x-button icon="format_italic" aria-label="Italic" variant="tonal" :selected="false" />
<x-button icon="format_underlined" aria-label="Underline" variant="tonal" :selected="false" />
</x-button-group>
BLADE,
'A connected group that owns its selection' => <<<'BLADE'
<x-stack gap="space300" x-data="{ view: 'week', marks: ['bold'] }">
<x-button-group connected selection="single" required label="View" x-model="view">
<x-button label="Day" value="day" variant="tonal" :selected="false" />
<x-button label="Week" value="week" variant="tonal" :selected="true" />
<x-button label="Month" value="month" variant="tonal" :selected="false" />
</x-button-group>
<x-button-group connected selection="multi" label="Formatting" x-model="marks">
<x-button icon="format_bold" aria-label="Bold" value="bold" variant="tonal" :selected="true" />
<x-button icon="format_italic" aria-label="Italic" value="italic" variant="tonal" :selected="false" />
<x-button icon="format_underlined" aria-label="Underline" value="underline" variant="tonal" :selected="false" />
</x-button-group>
<p class="md-type-body-md md-ink-variant">
View: <code x-text="view"></code> · marks: <code x-text="marks.join(', ') || 'none'"></code>.
The shape follows at once; the colours come from each button's own <code>:selected</code>, which a Livewire render brings back.
</p>
</x-stack>
BLADE,
'Square groups (hold a button down)' => <<<'BLADE'
<x-button-group label="Square standard" size="md" shape="square">
<x-button label="Day" variant="tonal" size="md" />
<x-button label="Week" variant="tonal" size="md" />
<x-button label="Month" variant="tonal" size="md" />
</x-button-group>
<x-button-group label="Square formatting" connected shape="square">
<x-button icon="format_bold" aria-label="Bold" variant="tonal" :selected="true" />
<x-button icon="format_italic" aria-label="Italic" variant="tonal" :selected="false" />
<x-button icon="format_underlined" aria-label="Underline" variant="tonal" :selected="false" />
</x-button-group>
<x-stack x-data="{ density: 'cosy' }">
<x-group label="Density" name="showcase-density" shape="square" x-model="density" inline :options="[
['id' => 'compact', 'name' => 'Compact'],
['id' => 'cosy', 'name' => 'Cosy'],
['id' => 'roomy', 'name' => 'Roomy'],
]" />
</x-stack>
BLADE,
'A choice as a connected group' => <<<'BLADE'
<x-grid :columns="['compact' => 1, 'medium' => 2]" gap="space300" x-data="{ theme: 'system', days: ['mon'] }">
<x-group label="Theme" name="showcase-theme" x-model="theme" :options="[
['id' => 'light', 'name' => 'Light', 'icon' => 'light_mode'],
['id' => 'dark', 'name' => 'Dark', 'icon' => 'dark_mode'],
['id' => 'system', 'name' => 'System', 'icon' => 'computer'],
]" />
<x-group label="Days" name="showcase-days" x-model="days" multiple variant="outlined" hint="Thursday is fully booked" hint-class="md-ink-warning" :options="[
['id' => 'mon', 'name' => 'Mon'],
['id' => 'tue', 'name' => 'Tue'],
['id' => 'wed', 'name' => 'Wed'],
['id' => 'thu', 'name' => 'Thu', 'disabled' => true],
]" />
</x-grid>
BLADE,
'Split buttons' => <<<'BLADE'
<x-split-button label="Download all" icon="download" menu-label="Download options">
<x-menu-item label="As a ZIP" icon="folder_zip" />
<x-menu-item label="One by one" icon="download" />
</x-split-button>
<x-split-button label="Share" variant="tonal" size="md" menu-label="Share options">
<x-menu-item label="Copy link" icon="content_copy" />
<x-menu-item label="Email" icon="mail" />
</x-split-button>
<x-split-button label="Save" variant="outlined" size="xs" menu-label="Save options">
<x-menu-item label="Save as draft" />
</x-split-button>
BLADE,
'FABs and extended FABs' => <<<'BLADE'
<x-fab icon="add" tooltip="New share" />
<x-fab icon="edit" size="md" color="secondary" tooltip="Edit" />
<x-fab icon="upload" size="lg" color="tertiary" tooltip="Upload" />
<x-fab icon="add" label="New share" />
<x-fab icon="upload" label="Upload" size="md" variant="filled" />
BLADE,
'An extended FAB that collapses on scroll (scroll the page)' => <<<'BLADE'
<x-fab icon="edit" label="Compose" collapse-on-scroll />
<x-fab icon="upload" label="Upload" size="md" color="secondary" collapse-on-scroll />
<x-fab icon="add" label="New share" size="lg" color="tertiary" collapse-on-scroll />
BLADE,
'FAB menu' => <<<'BLADE'
<x-row justify="end" align="end" style="width: 100%; height: 288px;">
<x-fab-menu label="New">
<x-fab-menu-item label="Upload files" icon="upload_file" />
<x-fab-menu-item label="Upload a folder" icon="drive_folder_upload" />
<x-fab-menu-item label="Paste text" icon="content_paste" />
</x-fab-menu>
</x-row>
BLADE,
];
@endphp
<x-livewire-material::stack as="section" id="buttons" gap="space300">
<h2 class="md-visually-hidden">Buttons</h2>
<p class="md-type-body-md md-ink-variant">
<code>&lt;x-button&gt;</code>: label buttons, icon buttons and toggles in M3 Expressive's five sizes.
</p>
@foreach ($examples as $title => $code)
<x-showcase::example :$title :$code />
@endforeach
</x-livewire-material::stack>