39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
@props([
|
|
'variant' => 'primary',
|
|
'type' => 'button',
|
|
'href' => null,
|
|
'size' => 'md',
|
|
'block' => false,
|
|
'icon' => null,
|
|
'iconOnly' => false,
|
|
'loading' => false,
|
|
])
|
|
|
|
@php
|
|
$variant = in_array($variant, ['primary', 'secondary', 'ghost', 'danger'], true) ? $variant : 'primary';
|
|
$classes = array_filter([
|
|
'btn',
|
|
"btn--{$variant}",
|
|
$size === 'sm' ? 'btn--sm' : null,
|
|
$block ? 'btn--block' : null,
|
|
$iconOnly ? 'btn--icon' : null,
|
|
]);
|
|
@endphp
|
|
|
|
@if ($href)
|
|
<a href="{{ $href }}" {{ $attributes->class($classes) }}>
|
|
@if ($icon) <x-dynamic-component :component="'heroicon-o-'.$icon" /> @endif
|
|
@unless ($iconOnly) <span>{{ $slot }}</span> @endunless
|
|
</a>
|
|
@else
|
|
<button
|
|
type="{{ $type }}"
|
|
@if ($loading) data-busy="true" aria-busy="true" @endif
|
|
{{ $attributes->class($classes) }}
|
|
>
|
|
<span class="btn__spinner" aria-hidden="true"></span>
|
|
@if ($icon) <x-dynamic-component :component="'heroicon-o-'.$icon" /> @endif
|
|
@unless ($iconOnly) <span>{{ $slot }}</span> @endunless
|
|
</button>
|
|
@endif
|