71 lines
2.2 KiB
PHP
71 lines
2.2 KiB
PHP
@php
|
|
$tag = 'button';
|
|
$href = null;
|
|
$buttonType = $type;
|
|
|
|
if ($type === 'delete' || $confirm) {
|
|
$tag = 'button';
|
|
$buttonType = 'button';
|
|
$attributes = $attributes->merge([
|
|
'onclick' => "confirmDelete('$confirmUrl', '$confirmName')",
|
|
]);
|
|
} elseif ($route) {
|
|
$href = route($route, $params);
|
|
$tag = 'a';
|
|
} elseif ($url) {
|
|
$href = $url;
|
|
$tag = 'a';
|
|
} elseif ($attributes->has('href')) {
|
|
$href = $attributes->get('href');
|
|
$tag = 'a';
|
|
}
|
|
|
|
$variants = [
|
|
'primary' => 'btn-primary',
|
|
'secondary' => 'btn-secondary',
|
|
'outline' => 'btn-outline-primary',
|
|
'outline-primary' => 'btn-outline-primary',
|
|
'outline-secondary' => 'btn-outline-secondary',
|
|
'outline-success' => 'btn-outline-success',
|
|
'outline-danger' => 'btn-outline-danger',
|
|
'outline-warning' => 'btn-outline-warning',
|
|
'outline-info' => 'btn-outline-info',
|
|
'ghost' => 'btn-light',
|
|
'link' => 'btn-link',
|
|
'danger' => 'btn-danger',
|
|
'destructive' => 'btn-danger',
|
|
'success' => 'btn-success',
|
|
'warning' => 'btn-warning',
|
|
'info' => 'btn-info',
|
|
'light' => 'btn-light',
|
|
'dark' => 'btn-dark',
|
|
];
|
|
|
|
$sizes = [
|
|
'default' => '',
|
|
'sm' => 'btn-sm',
|
|
'lg' => 'btn-lg',
|
|
'xs' => 'btn-xs',
|
|
'icon' => 'btn-icon',
|
|
];
|
|
|
|
$variantClass = $variants[$variant ?? 'primary'] ?? $variants['primary'];
|
|
$sizeClass = $sizes[$size ?? 'default'] ?? '';
|
|
|
|
$classes = "btn d-flex align-items-center {$variantClass} {$sizeClass}";
|
|
@endphp
|
|
@if($tag === 'a')
|
|
<a href="{{ $href }}" {{ $attributes->merge(['class' => $classes]) }}>
|
|
@if($icon)
|
|
<i data-lucide="{{ $icon }}" style="height: 14px; width: 14px"></i>
|
|
@endif
|
|
@if($slot->isNotEmpty())<span class="ms-1">{{ $slot }}</span>@endif
|
|
</a>
|
|
@else
|
|
<button type="{{ $buttonType }}" {{ $attributes->merge(['class' => $classes]) }}>
|
|
@if($icon)
|
|
<i data-lucide="{{ $icon }}" style="height: 14px; width: 14px"></i>
|
|
@endif
|
|
@if($slot->isNotEmpty())<span class="ms-1">{{ $slot }}</span>@endif
|
|
</button>
|
|
@endif |