Files
livewire-material/resources/views/showcase/sections/communication.blade.php
T
Andreas Reinhold / reiniandClaude Opus 5 3fb0a404db Write the showcase examples' layout tags as an application does
Plan step 38 review: nine sections' examples wrapped their components
in <x-livewire-material::stack>, ::row and ::grid (148 tags) beside an
unprefixed <x-button>, while bars, containment and the layout pages
wrote <x-stack>. The code sample is what an application copies, and
the example component rewrites only unprefixed tags to a configured
prefix, so the namespaced ones taught a second form and escaped it.
Every example now writes <x-stack>, <x-row> and <x-grid>; a test
rejects a namespaced tag inside an example heredoc.

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

120 lines
8.0 KiB
PHP

@php
$examples = [
'Badges' => <<<'BLADE'
<span style="position: relative; display: inline-flex"><x-icon name="notifications" /><x-badge floating /></span>
<span style="position: relative; display: inline-flex"><x-icon name="mail" /><x-badge value="4" floating /></span>
<span style="position: relative; display: inline-flex"><x-icon name="inbox" /><x-badge value="1204" max="999" floating /></span>
<x-badge value="Expired" tonal />
<x-badge value="Active" color="success" tonal />
<x-badge value="Password" color="info" tonal />
<x-badge value="Built in" color="primary" solid />
<x-badge value="Pro" outline />
<x-badge value="Draft" color="neutral" tonal />
<x-badge value="Archived" color="neutral" outline />
<span style="position: relative; display: inline-flex"><x-icon name="chat" /><x-badge value="2" color="neutral" floating /></span>
<x-badge tonal color="tertiary"><x-icon name="bolt" filled optical="20" size="12" /> Pro</x-badge>
<x-badge value="Beta" tonal color="plain" data-md-showcase-badge-plain />
BLADE,
'Snackbars' => <<<'BLADE'
<x-row gap="space200" wrap align="center" x-data>
<x-button label="Saved" variant="tonal" x-on:click="materialToast('Settings saved', { type: 'success' })" />
<x-button label="With a description" variant="tonal" x-on:click="materialToast('Upload failed', { type: 'error', description: 'The file is larger than 4 GB.' })" />
<x-button label="With an action" variant="tonal" x-on:click="materialToast('Share deleted', { action: { label: 'Undo', handler: () => materialToast('Share restored', { type: 'info' }) } })" />
<x-button label="Until dismissed" variant="tonal" x-on:click="materialToast('Your storage is almost full', { type: 'warning', timeout: 0 })" />
<x-button label="Sticky, with an event" variant="tonal" x-on:click="materialToast('A new version is ready', { type: 'info', sticky: true, action: { label: 'Reload', event: 'showcase:reload' } })" x-on:showcase:reload.window="materialToast('Reloading…')" />
</x-row>
BLADE,
'Two lines, and the keyboard shortcut that reaches them' => <<<'BLADE'
<x-stack gap="space200" x-data>
<x-row gap="space200" wrap align="center">
<x-button label="Two lines" variant="tonal" x-on:click="materialToast('Upload paused', { description: 'The connection dropped at 64%. It carries on when you are back.' })" />
<x-button label="Two lines, with an action" variant="tonal" x-on:click="materialToast('Upload paused', { description: 'The connection dropped at 64%. It carries on when you are back.', action: { label: 'Retry now', handler: () => materialToast('Retrying…') } })" />
</x-row>
<p class="md-type-body-md md-ink-variant">
A description makes the snackbar 68px, M3's two-line height; below <code>medium</code> the action wraps under the text.
Press <kbd class="md-type-label-md" data-md-showcase-kbd>Alt</kbd>&nbsp;+&nbsp;<kbd class="md-type-label-md" data-md-showcase-kbd>G</kbd> to move the focus to a snackbar that has an action.
</p>
</x-stack>
BLADE,
'Plain tooltips' => <<<'BLADE'
<x-button icon="content_copy" tooltip="Copy link" />
<x-button icon="qr_code_2" tooltip-bottom="Show QR code" />
<x-tooltip text="Expires in 3 days" side="right">
<span tabindex="0" class="md-type-body-md md-ink-variant md-focus-ring" data-md-showcase-focus-demo>holiday-photos.zip</span>
</x-tooltip>
BLADE,
'Rich tooltips' => <<<'BLADE'
<x-rich-tooltip title="Expiry" text="Recipients lose access after this time. Admins can change the longest time allowed.">
<x-button icon="help" aria-label="About expiry" />
</x-rich-tooltip>
<x-rich-tooltip title="Password protection" text="Recipients need the password before they can see the files." persistent>
<x-button label="Press for details" icon="lock" variant="outlined" />
<x-slot:actions>
<x-button label="Learn more" />
</x-slot:actions>
</x-rich-tooltip>
BLADE,
'Alerts' => <<<'BLADE'
<x-stack gap="space200">
<x-alert title="Storage almost full" description="3.8 GB of 4 GB used. Old shares are deleted when they expire." color="warning" />
<x-alert description="Links are shown only once. Copy yours before you leave the page." dismissible />
<x-alert title="Upload failed" color="error">
The connection dropped at 64%.
<x-slot:actions><x-button label="Try again" /></x-slot:actions>
</x-alert>
<x-alert description="Settings saved." color="success" />
</x-stack>
BLADE,
'Stats' => <<<'BLADE'
<x-grid :columns="['compact' => 1, 'medium' => 2, 'expanded' => 4]" gap="space200">
<x-stat title="Shares" value="1,204" icon="link" description="12 this week" />
<x-stat title="Files" value="8,317" icon="description" />
<x-stat title="Stored" value="3.2 GB" icon="hard_drive" description="of 4 GB" />
<x-stat title="Downloads" value="42,019" icon="download" />
</x-grid>
BLADE,
'Empty state' => <<<'BLADE'
<x-stack gap="space200">
<x-empty-state icon="upload_file" title="No shares yet" description="Files you share appear here, with their links and when they expire.">
<x-slot:actions>
<x-button label="Upload files" icon="upload" variant="filled" />
</x-slot:actions>
</x-empty-state>
</x-stack>
BLADE,
'Empty state with an illustration' => <<<'BLADE'
<x-stack gap="space200">
<x-empty-state title="No routes yet" description="Draw a route on the map, or import one from a GPX file.">
<x-slot:illustration style="color: var(--md-sys-color-primary)">
<svg style="width: 128px; height: 128px" viewBox="0 0 120 120" fill="none" aria-hidden="true">
<circle cx="60" cy="60" r="56" data-md-showcase-illustration="container" />
<path d="M28 86C40 62 56 92 68 64S86 42 90 46" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="1 10" />
<circle cx="28" cy="86" r="7" fill="currentColor" />
<path d="M90 18a12 12 0 0 1 12 12c0 10-12 22-12 22S78 40 78 30a12 12 0 0 1 12-12Z" data-md-showcase-illustration="accent" />
<circle cx="90" cy="30" r="4" data-md-showcase-illustration="on-accent" />
</svg>
</x-slot:illustration>
<x-slot:actions>
<x-button label="Draw a route" icon="route" variant="filled" />
</x-slot:actions>
</x-empty-state>
</x-stack>
BLADE,
];
@endphp
<x-livewire-material::stack as="section" id="communication" gap="space300">
<h2 class="md-visually-hidden">Communication</h2>
<p class="md-type-body-md md-ink-variant">
<code>&lt;x-badge&gt;</code>, <code>&lt;x-toast&gt;</code> (the snackbar host, fed by the <code>Toasts</code> concern or <code>materialToast()</code>),
<code>&lt;x-tooltip&gt;</code>, <code>&lt;x-rich-tooltip&gt;</code>, <code>&lt;x-alert&gt;</code>, <code>&lt;x-stat&gt;</code> and <code>&lt;x-empty-state&gt;</code>.
</p>
@foreach ($examples as $title => $code)
<x-showcase::example :$title :$code />
@endforeach
</x-livewire-material::stack>