button components
This commit is contained in:
13
resources/views/components/inputs/button.blade.php
Normal file
13
resources/views/components/inputs/button.blade.php
Normal file
@@ -0,0 +1,13 @@
|
||||
@props([
|
||||
'defaultClass' => 'bg-indigo-500',
|
||||
'confirm' => null,
|
||||
'confirmAction' => null,
|
||||
])
|
||||
|
||||
<button {{ $attributes }} {{ $attributes->merge(['class' => $defaultClass]) }}
|
||||
@if ($attributes->whereStartsWith('wire:click')) wire:target="{{ $attributes->whereStartsWith('wire:click')->first() }}"
|
||||
wire:loading.class="text-black bg-green-500" wire:loading.attr="disabled" wire:loading.class.remove="{{ $defaultClass }} {{ $attributes->whereStartsWith('class')->first() }}" @endif
|
||||
@isset($confirm) x-on:click="toggleConfirmModal('{{ $confirm }}')" @endisset
|
||||
@isset($confirmAction) @confirm.window="$wire.{{ $confirmAction }}()" @endisset>
|
||||
{{ $slot }}
|
||||
</button>
|
||||
54
resources/views/components/inputs/input.blade.php
Normal file
54
resources/views/components/inputs/input.blade.php
Normal file
@@ -0,0 +1,54 @@
|
||||
@props([
|
||||
'id' => null,
|
||||
'required' => false,
|
||||
'readonly' => false,
|
||||
'label' => null,
|
||||
'type' => 'text',
|
||||
'class' => '',
|
||||
'instantSave' => false,
|
||||
'disabled' => false,
|
||||
'hidden' => false,
|
||||
])
|
||||
|
||||
@if ($type === 'checkbox')
|
||||
<label for={{ $id }}>
|
||||
@if ($label)
|
||||
{{ $label }}
|
||||
@else
|
||||
{{ $id }}
|
||||
@endif
|
||||
@if ($required)
|
||||
*
|
||||
@endif
|
||||
<input type="checkbox" id={{ $id }}
|
||||
@if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $id }} @endif>
|
||||
</label>
|
||||
@error($id)
|
||||
<span class="text-red-500">{{ $message }}</span>
|
||||
@enderror
|
||||
@else
|
||||
<label for={{ $id }}>
|
||||
@if ($label)
|
||||
{{ $label }}
|
||||
@else
|
||||
{{ $id }}
|
||||
@endif
|
||||
@if ($required)
|
||||
*
|
||||
@endif
|
||||
</label>
|
||||
@if ($type === 'textarea')
|
||||
<textarea class={{ $class }} type={{ $type }} id={{ $id }}
|
||||
wire:model.defer={{ $id }} @if ($required) required @endif
|
||||
@if ($disabled) disabled @endif @if ($readonly) readOnly disabled @endif></textarea>
|
||||
@else
|
||||
<input class={{ $class }} type={{ $type }} id={{ $id }}
|
||||
wire:model.defer={{ $id }} @if ($required) required @endif
|
||||
@if ($disabled) disabled @endif
|
||||
@if ($readonly) readOnly disabled @endif />
|
||||
@endif
|
||||
|
||||
@error($id)
|
||||
<div class="text-red-500">{{ $message }}</div>
|
||||
@enderror
|
||||
@endif
|
||||
Reference in New Issue
Block a user