coolify/resources/views/components/inputs/button.blade.php

25 lines
1.1 KiB
PHP
Raw Normal View History

2023-05-03 14:09:10 +02:00
@props([
2023-05-03 15:02:21 +02:00
'isWarning' => null,
2023-05-05 12:08:38 +02:00
'defaultClass' => 'text-white bg-neutral-800 hover:bg-violet-600 w-28 h-6',
'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 w-28 h-6',
'loadingClass' => 'text-black bg-green-500 w-28 h-6',
2023-05-03 14:09:10 +02:00
'confirm' => null,
'confirmAction' => null,
])
2023-05-03 15:02:21 +02:00
<button {{ $attributes }} @class([
$defaultClass => !$confirm && !$isWarning,
$defaultWarningClass => $confirm || $isWarning,
2023-05-03 20:47:24 +02:00
]) @if ($attributes->whereStartsWith('wire:click'))
2023-05-03 15:29:14 +02:00
wire:target="{{ explode('(', $attributes->whereStartsWith('wire:click')->first())[0] }}"
wire:loading.delay.class="{{ $loadingClass }}" wire:loading.delay.attr="disabled"
2023-05-03 15:02:21 +02:00
wire:loading.delay.class.remove="{{ $defaultClass }} {{ $attributes->whereStartsWith('class')->first() }}"
@endif
@isset($confirm)
2023-05-04 15:45:53 +02:00
x-on:click="toggleConfirmModal('{{ $confirm }}', '{{ explode('(', $confirmAction)[0] }}')"
2023-05-03 15:02:21 +02:00
@endisset
@isset($confirmAction)
2023-05-04 15:45:53 +02:00
x-on:{{ explode('(', $confirmAction)[0] }}.window="$wire.{{ explode('(', $confirmAction)[0] }}"
2023-05-03 15:02:21 +02:00
@endisset>
2023-05-03 14:09:10 +02:00
{{ $slot }}
</button>