An over-engineering audit of the whole tree, applied in five reviewed batches. Behaviour stays the same except where UPGRADE.md says otherwise. PHP: the showcase and error-page stylesheets are prebuilt into resources/dist by bin/stylesheets.mjs, through Vite's own postcss-import (first occurrence kept, the order an application's build gives), instead of Stylesheets::bundle() inlining imports on every request; only the import walk DesignGuard needs stays. SchemeStylesheet::withProfiles() replaces three copies of the scheme-plus-profiles loop, material:scheme leaves spec and contrast checks to the node script that already made them, and the error page's scheme cache, the hashed view namespace, the translations path with no lang/ folder and DesignGuard's 1.x-name hints are gone. JS: the androidx shape port progress.js and both bin scripts each carried lives once in resources/js/shapes.js (the generated SVGs are unchanged); util.js holds ringIndex(), ms(), reopenGuard() and remember(), which were written out several times; listeners are released through AbortController; tooltip.js's hoverPopover() serves the rich tooltip too. CSS: every rule for an element inside the navigation rail queries `--md-navigation-rail-value` instead of repeating the seven collapsed conditions under five media branches; badge, alert, progress, slider and button read one non-inheriting colour-role table (components/color.css); the dialog chrome, the submenu's popover chrome, the chip's state layer and touch target, and the visually-hidden inputs use the shared rules they copied; foundation/tokens.css is folded into foundation.css. Views: Support\Field and Support\Link replace the error-key, bound-value and link-attribute blocks copied into the fields and link components; the timepicker period group, the menu filter and the showcase head are partials; the datepicker's steppers and entry fields are loops; component docblocks no longer restate SKILL.md. Tests and tooling: one dataset-driven ComponentStylesheetsTest replaces four per-group files, DesignGuardTest and the layout-component tests use datasets, browser tests share one ready() helper, CSS parsing lives in ComponentStylesheet alone. docs/audits and the finding IDs citing it are removed, as are pestphp/pest-plugin-laravel, the unused composer scripts and check:font; the lint job runs in the feature job, which now installs node packages so the prebuilt-stylesheet staleness test runs in CI. Feature suite 1177 passed, Chrome browser suite 299 passed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
91 lines
4.3 KiB
PHP
91 lines
4.3 KiB
PHP
{{-- An M3 Expressive floating action button: the screen's primary action.
|
|
|
|
With only an `icon` it is a FAB — `size` `sm` 56px (the default; M3's deprecated small FAB is
|
|
gone, so this is the baseline FAB), `md` 80px, `lg` 96px. With a `label` it is an extended
|
|
FAB at the same three heights. `color` is `primary` (the default), `secondary` or `tertiary`,
|
|
drawn in its container, or in the colour itself with `variant="filled"`.
|
|
|
|
It does not place itself: put it where the layout wants it, e.g.
|
|
`<div style="position: fixed; inset-inline-end: 16px; bottom: 16px"><x-fab icon="add" tooltip="New share" /></div>`.
|
|
For a create action that is a FAB on a phone and a header button above, use `<x-button fab>`.
|
|
|
|
The glyph is filled, not outlined: M3 says so twice, in the FAB's anatomy and again in its
|
|
guidelines ("icon should be filled (not outlined) and unambiguous").
|
|
|
|
There is no `disabled`: M3 says never to disable a FAB — "if its action is unavailable,
|
|
remove the FAB entirely instead" — so hide it (`@if`), or leave it out of the render, rather
|
|
than greying it out. A form-submit FAB that must not be pressed twice takes the caller's own
|
|
`wire:loading.attr="disabled"`.
|
|
|
|
`data-md-fab` marks the root, so a place a FAB sits in can draw it its own way: a navigation
|
|
rail flattens a nested FAB to elevation 0.
|
|
|
|
`collapse-on-scroll` is M3's extended FAB that "can collapse to a FAB on scroll-down and
|
|
re-expand to extended on scroll-up": while the window scrolls down it shrinks to the FAB of
|
|
its size, and it extends again when the page scrolls back up or reaches the top. The label
|
|
closes and fades while the width follows it on the spatial spring; under reduced motion the
|
|
two swap outright. The label stays in the page, clipped rather than removed, so the collapsed
|
|
FAB keeps its accessible name. It needs an `icon` — a FAB with no glyph is no FAB — and does
|
|
nothing on a plain FAB.
|
|
|
|
Sizes, corners and elevation from FabBaseline/Medium/LargeTokens and ExtendedFab*Tokens
|
|
(androidx Compose Material 3, Apache-2.0), drawn by resources/css/components/fab.css. --}}
|
|
|
|
@props([
|
|
'icon' => null,
|
|
'label' => null,
|
|
'size' => 'sm',
|
|
'color' => 'primary',
|
|
'variant' => 'container',
|
|
'link' => null,
|
|
'external' => false,
|
|
'tooltip' => null,
|
|
'type' => 'button',
|
|
'collapseOnScroll' => false,
|
|
])
|
|
|
|
@php
|
|
$size = in_array($size, ['sm', 'md', 'lg'], true) ? $size : 'sm';
|
|
$color = in_array($color, ['primary', 'secondary', 'tertiary'], true) ? $color : 'primary';
|
|
$variant = $variant === 'filled' ? 'filled' : 'container';
|
|
$extended = filled($label) || $slot->isNotEmpty();
|
|
$collapsing = $collapseOnScroll && $extended && filled($icon);
|
|
$isLink = filled($link);
|
|
|
|
$iconSize = ['sm' => 24, 'md' => 28, 'lg' => 32][$size];
|
|
$anchor = $tooltip !== null ? '--material-fab-'.\Illuminate\Support\Str::lower(\Illuminate\Support\Str::random(10)) : null;
|
|
$tag = $isLink ? 'a' : 'button';
|
|
|
|
$attributes = $attributes->merge(array_filter([
|
|
// The hook a place uses to draw a nested FAB its own way: a rail flattens it to 0dp.
|
|
'data-md-fab' => true,
|
|
'data-md-size' => $size,
|
|
'data-md-color' => $color,
|
|
'data-md-variant' => $variant,
|
|
'data-md-extended' => $extended ? true : null,
|
|
'data-md-collapse-on-scroll' => $collapsing ? true : null,
|
|
...\NoNameWeb\LivewireMaterial\Support\Link::attributes($isLink, $link, $external, $attributes),
|
|
'type' => $isLink ? null : $type,
|
|
'x-data' => $collapsing ? 'materialFab' : null,
|
|
'x-bind:data-md-collapsed' => $collapsing ? "collapsed ? '' : null" : null,
|
|
'aria-label' => ! $extended && ! $attributes->has('aria-label') ? $tooltip : null,
|
|
'style' => $anchor ? "anchor-name: {$anchor}" : null,
|
|
], fn ($value): bool => $value !== null))->class(['md-state-layer', 'md-focus-ring']);
|
|
@endphp
|
|
|
|
<{{ $tag }} {{ $attributes }}>
|
|
@if ($icon)
|
|
<x-livewire-material::icon :name="$icon" filled :size="$iconSize" />
|
|
@endif
|
|
|
|
@if ($collapsing)
|
|
<span data-md-fab-label><span>{{ $label ?? $slot }}</span></span>
|
|
@elseif ($extended)
|
|
<span>{{ $label ?? $slot }}</span>
|
|
@endif
|
|
|
|
@if ($tooltip !== null)
|
|
<x-livewire-material::tooltip :text="$tooltip" :anchor="$anchor" />
|
|
@endif
|
|
</{{ $tag }}>
|