{{-- One item in an ``: an action, a link, or a choice. `label`, a leading `icon` (`icon-class` adds classes to it), an `icon-right`, a `description` under the label and a `shortcut` at the end (M3's trailing supporting text: "⌘C"). `link` makes it an anchor, with `wire:navigate` unless `external` or `no-wire-navigate`. `selected` (true or false) makes it a `menuitemcheckbox` with `aria-checked`; a selected item takes Expressive's selected shape and tertiary-container. `current` is for a menu of places rather than choices — a section picker — and marks the page you are on: `aria-current="page"`, the selected shape in secondary-container, the colour M3 gives the navigation indicator. `badge` draws `` at the end of the row: `true` for a dot, or a count. `disabled` keeps it in the list, out of reach. `keep-open` leaves the menu open when it is activated — for a choice the person may want to change twice. `icon-class` is for an icon whose colour means something of its own, a sport's glyph in the sport's colour (`icon-class="text-sport-run"`). A colour there paints the icon, a selected item's too: the icon's own colour then carries no specificity, because which of two colour utilities wins depends on the order Tailwind emits them. A disabled item's icon stays disabled. 44px tall (SegmentedMenuTokens.Item), body-large label, 20px icons, 4px corners that open to 12px at the ends of the list. --}} @props([ 'label' => null, 'icon' => null, 'iconClass' => null, 'iconRight' => null, 'description' => null, 'shortcut' => null, 'link' => null, 'external' => false, 'noWireNavigate' => false, 'selected' => null, 'current' => false, 'badge' => null, 'disabled' => false, 'keepOpen' => false, ]) @php $isLink = filled($link); $tag = $isLink ? 'a' : 'button'; $attributes = $attributes ->class([ 'group/item state-layer flex w-full min-h-11 cursor-pointer items-center gap-3 px-3 text-start outline-none', 'rounded-corner-xs first:rounded-t-corner-md last:rounded-b-corner-md', 'transition-[border-radius,background-color] duration-(--md-sys-motion-spatial-fast-duration) ease-spatial-fast', 'focus-visible:outline-3 focus-visible:-outline-offset-3 focus-visible:outline-secondary', 'py-2' => filled($description), 'rounded-corner-md bg-tertiary-container text-on-tertiary-container' => $selected === true, 'rounded-corner-md bg-secondary-container text-on-secondary-container' => $current && $selected !== true, 'pointer-events-none text-on-surface/38' => $disabled, ]) ->merge(array_filter([ 'role' => $selected === null ? 'menuitem' : 'menuitemcheckbox', 'aria-checked' => $selected === null ? null : ($selected ? 'true' : 'false'), 'aria-current' => $current ? 'page' : null, 'aria-disabled' => $disabled ? 'true' : null, 'tabindex' => '-1', 'type' => $isLink ? null : 'button', 'href' => $isLink ? $link : null, 'target' => $isLink && $external ? '_blank' : null, 'rel' => $isLink && $external ? 'noopener' : null, 'wire:navigate' => $isLink && ! $external && ! $noWireNavigate && ! $attributes->has('wire:navigate') ? true : null, 'data-keep-open' => $keepOpen ? true : null, ], fn ($value): bool => $value !== null)); $iconInk = match (true) { $disabled => 'text-on-surface/38', $selected === true => 'text-on-tertiary-container', $current => 'text-on-secondary-container', default => 'text-on-surface-variant', }; $leadingIcon = match (true) { blank($iconClass) => 'size-5 '.$iconInk, $disabled => \Illuminate\Support\Arr::toCssClasses(['size-5', $iconClass, 'text-on-surface/38!']), $selected === true => \Illuminate\Support\Arr::toCssClasses(['size-5 [:where(&)]:text-on-tertiary-container', $iconClass]), $current => \Illuminate\Support\Arr::toCssClasses(['size-5 [:where(&)]:text-on-secondary-container', $iconClass]), default => \Illuminate\Support\Arr::toCssClasses(['size-5 [:where(&)]:text-on-surface-variant', $iconClass]), }; @endphp <{{ $tag }} {{ $attributes }}> @if ($icon) @endif {{ $label ?? $slot }} @if ($description) {{ $description }} @endif @if ($badge !== null && $badge !== false && $badge !== '') @endif @if ($shortcut) {{ $shortcut }} @endif @if ($iconRight) @endif