@props([ 'variant' => '', // e.g. "primary danger" 'size' => 'default', // sm | default | lg 'type' => 'button', // anchor | button | submit 'class' => '', 'label' => '', 'href' => null, ]) @php // allow "primary danger" (space-delimited), or even "primary,danger" $variantTokens = preg_split('/[\s,]+/', trim($variant)) ?: []; $variantMap = [ 'primary' => 'button--primary', 'secondary' => 'button--secondary', 'tertiary' => 'button--tertiary', 'danger' => 'button--danger', ]; $variantClass = collect($variantTokens) ->map(fn ($v) => $variantMap[$v] ?? null) ->filter() ->implode(' '); $sizeClass = match ($size) { 'sm' => 'button--sm', 'lg' => 'button--lg', default => '', }; $isAnchor = $type === 'anchor'; $tag = $isAnchor ? 'a' : 'button'; $buttonType = $isAnchor ? null : ($type === 'submit' ? 'submit' : 'button'); $classes = trim("button {$variantClass} {$sizeClass} {$class}"); @endphp @if($isAnchor) merge(['class' => $classes]) }}> {{ $slot }} @else @endif