{{-- A card-like section of a page. With a title it is a
named by its heading (h2 by default, `level` changes it), with an optional decorative icon and actions (the `actions` slot) beside the heading. tone="danger" or "warning" adds a coloured top edge; the heading text must still say what is wrong. --}} @props([ 'title' => null, 'icon' => null, 'level' => 2, 'tone' => null, 'headingId' => null, ]) @php $headingId ??= $title !== null ? 'panel-'.\Illuminate\Support\Str::slug($title).'-'.substr(md5($title), 0, 6) : null; $edge = match ($tone) { 'danger' => 'border-t-4 border-t-red-600 dark:border-t-red-400', 'warning' => 'border-t-4 border-t-amber-500 dark:border-t-amber-400', 'primary' => 'border-t-4 border-t-primary-500 dark:border-t-primary-400', default => null, }; $iconColour = match ($tone) { 'danger' => 'bg-red-100 text-red-700 dark:bg-red-400/15 dark:text-red-300', 'warning' => 'bg-amber-100 text-amber-800 dark:bg-amber-400/15 dark:text-amber-200', default => 'bg-primary-100 text-primary-700 dark:bg-primary-400/15 dark:text-primary-200', }; $tag = $title !== null ? 'section' : 'div'; @endphp <{{ $tag }} @if ($title !== null) aria-labelledby="{{ $headingId }}" @endif {{ $attributes->class(['space-y-4 rounded-xl border border-zinc-200 bg-white p-4 shadow-sm sm:p-5 dark:border-zinc-700 dark:bg-zinc-900', $edge]) }} > @if ($title !== null)
@if ($icon !== null) @endif {{ $title }} @isset($actions)
{{ $actions }}
@endisset
@endif {{ $slot }}