Files
portal-api/resources/views/components/button-c-r-m.blade.php
T
2026-02-02 23:17:10 +07:00

55 lines
1.5 KiB
PHP

@php
$tag = 'button';
$href = null;
if ($route) {
$href = route($route, $params);
$tag = 'a';
} elseif ($url) {
$href = $url;
$tag = 'a';
} elseif ($attributes->has('href')) {
$href = $attributes->get('href');
$tag = 'a';
}
$baseClasses = 'd-inline-flex gap-2 align-items-center justify-content-center text-white border-0 shadow-md px-2 py-1 rounded-2';
$variants = [
'primary' => 'bg-primary',
'secondary' => 'bg-secondary',
'outline' => 'bg-outline',
'ghost' => 'bg-ghost',
'link' => 'bg-link',
'danger' => 'bg-danger',
'destructive' => 'bg-destructive',
];
$sizes = [
'default' => 'h-10',
'sm' => 'h-6',
'lg' => 'h-12',
'icon' => 'h-10',
];
$variantClass = $variants[$variant] ?? $variants['primary'];
$sizeClass = $sizes[$size] ?? $sizes['default'];
$classes = "{$baseClasses} {$variantClass} {$sizeClass}";
@endphp
@if($tag === 'a')
<a href="{{ $href }}" {{ $attributes->merge(['class' => $classes]) }}>
@if($icon)
<i data-lucide="{{ $icon }}" class="mr-2" style="height: 15px; width: 15px"></i>
@endif
{{ $slot }}
</a>
@else
<button type="{{ $type }}" {{ $attributes->merge(['class' => $classes]) }}>
@if($icon)
<i data-lucide="{{ $icon }}" class="w-1 h-1 mr-2"></i>
@endif
{{ $slot }}
</button>
@endif