{{-- A choice of colour profile: one swatch per profile `material:scheme` generated from `livewire-material.profiles`, each its name and its primary, secondary and tertiary colour. Native radios under the swatches, so `wire:model` and `x-model` bind as on any input and the arrow keys move the choice. Choosing one shows it on the page at once (`$store.theme.previewScheme`); storing it — and telling `Scheme::resolveProfileUsing()` — is the application's. The dots are the only colours not drawn from tokens: they show other profiles than the page's, so they are custom properties set inline from the scheme file's checked hexes, light or dark with the page. The inline pair is the standard contrast level, which is what the server can know; Alpine swaps in the level on screen (`$store.theme.resolvedContrast`) so a dot never promises a colour the page would not paint. Without profiles it renders nothing. Props: `label`, `hint`, `name` (needed with `x-model`), `profiles` (default: every generated profile). A validation message for the bound property replaces the hint. --}} @props([ 'label' => null, 'hint' => null, 'name' => null, 'profiles' => null, ]) @php $profiles ??= \NoNameWeb\LivewireMaterial\Support\Scheme::profiles(); $model = $attributes->whereStartsWith('wire:model')->first(); $name ??= $model ?: 'scheme'; $errorKey = $model ?: (filled($attributes->get('name')) ? (string) $attributes->get('name') : null); $messages = $errorKey !== null && isset($errors) ? \Illuminate\Support\Arr::flatten($errors->get($errorKey)) : []; $roles = ['primary', 'secondary', 'tertiary']; // profile => level => theme => role => hex, for the dots. Every level is filled — a profile // the caller passed in by hand, or a scheme file without the levels, repeats its standard // colours — so the binding below never asks whether a level is there. $swatches = []; foreach ($profiles === [] ? [] : \NoNameWeb\LivewireMaterial\Support\Scheme::LEVELS as $level) { $generated = $level === 'standard' ? [] : \NoNameWeb\LivewireMaterial\Support\Scheme::profiles(contrast: $level); foreach ($profiles as $profile => $scheme) { foreach (['light', 'dark'] as $theme) { foreach ($roles as $role) { $swatches[$profile][$level][$theme][$role] = ($generated[$profile] ?? $scheme)[$theme][$role]; } } } } @endphp @if ($profiles !== [])
whereDoesntStartWith(['wire:model', 'x-model'])->except('name')->class('min-w-0') }} > @if (filled($label)) {{ $label }} @endif
@foreach ($profiles as $profile => $scheme) @endforeach
@if ($messages !== []) @foreach ($messages as $message)

{{ $message }}

@endforeach @elseif (filled($hint))

{{ $hint }}

@endif
@endif