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

35 lines
1.5 KiB
PHP
Raw Normal View History

2023-05-03 12:09:10 +00:00
@props([
2023-05-03 13:02:21 +00:00
'isWarning' => null,
2023-05-14 12:43:49 +00:00
'isBold' => false,
2023-05-09 09:33:50 +00:00
'disabled' => null,
2023-05-14 12:43:49 +00:00
'defaultClass' => 'text-white hover:bg-coollabs h-10 rounded transition-colors',
2023-05-16 18:47:59 +00:00
'defaultWarningClass' => 'text-red-500 hover:text-white hover:bg-red-600 h-10 rounded',
2023-05-14 12:43:49 +00:00
'disabledClass' => 'text-neutral-400 h-10 rounded',
'loadingClass' => 'text-black bg-green-500 h-10 rounded',
2023-05-03 12:09:10 +00:00
'confirm' => null,
'confirmAction' => null,
])
2023-05-03 13:02:21 +00:00
<button {{ $attributes }} @class([
2023-05-14 12:43:49 +00:00
$defaultClass => !$confirm && !$isWarning && !$disabled && !$isBold,
2023-05-09 09:33:50 +00:00
$defaultWarningClass => ($confirm || $isWarning) && !$disabled,
$disabledClass => $disabled,
2023-05-14 12:43:49 +00:00
$isBold => $isBold
? 'bg-coollabs text-white hover:bg-coollabs-100 h-10 rounded transition-colors'
: '',
2023-05-09 09:33:50 +00:00
]) @if ($attributes->whereStartsWith('wire:click') && !$disabled)
2023-05-03 13:29:14 +00:00
wire:target="{{ explode('(', $attributes->whereStartsWith('wire:click')->first())[0] }}"
wire:loading.delay.class="{{ $loadingClass }}" wire:loading.delay.attr="disabled"
2023-05-03 13:02:21 +00:00
wire:loading.delay.class.remove="{{ $defaultClass }} {{ $attributes->whereStartsWith('class')->first() }}"
@endif
2023-05-09 09:33:50 +00:00
@if ($disabled !== null)
disabled title="{{ $disabled }}"
@endif
2023-05-03 13:02:21 +00:00
@isset($confirm)
2023-05-04 13:45:53 +00:00
x-on:click="toggleConfirmModal('{{ $confirm }}', '{{ explode('(', $confirmAction)[0] }}')"
2023-05-03 13:02:21 +00:00
@endisset
@isset($confirmAction)
2023-05-04 13:45:53 +00:00
x-on:{{ explode('(', $confirmAction)[0] }}.window="$wire.{{ explode('(', $confirmAction)[0] }}"
2023-05-03 13:02:21 +00:00
@endisset>
2023-05-03 12:09:10 +00:00
{{ $slot }}
</button>