2023-05-03 12:09:10 +00:00
|
|
|
@props([
|
2023-05-03 13:02:21 +00:00
|
|
|
'isWarning' => null,
|
|
|
|
'defaultClass' => 'text-white bg-neutral-800 hover:bg-violet-600',
|
|
|
|
'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600',
|
2023-05-03 12:09:10 +00:00
|
|
|
'confirm' => null,
|
|
|
|
'confirmAction' => null,
|
|
|
|
])
|
2023-05-03 13:02:21 +00:00
|
|
|
<button {{ $attributes }} @class([
|
|
|
|
$defaultClass => !$confirm && !$isWarning,
|
|
|
|
$defaultWarningClass => $confirm || $isWarning,
|
|
|
|
]) @if ($attributes->whereStartsWith('wire:click'))
|
|
|
|
wire:target="{{ $attributes->whereStartsWith('wire:click')->first() }}"
|
|
|
|
wire:loading.delay.class="text-black bg-green-500" wire:loading.delay.attr="disabled"
|
|
|
|
wire:loading.delay.class.remove="{{ $defaultClass }} {{ $attributes->whereStartsWith('class')->first() }}"
|
|
|
|
@endif
|
|
|
|
@isset($confirm)
|
|
|
|
x-on:click="toggleConfirmModal('{{ $confirm }}')"
|
|
|
|
@endisset
|
|
|
|
@isset($confirmAction)
|
|
|
|
@confirm.window="$wire.{{ $confirmAction }}()"
|
|
|
|
@endisset>
|
2023-05-03 12:09:10 +00:00
|
|
|
{{ $slot }}
|
|
|
|
</button>
|