{{-- Button Component - shadcn-inspired Usage: Click me Add Server Delete Processing --}} @props([ 'variant' => 'secondary', 'size' => 'md', 'icon' => null, 'iconRight' => null, 'loading' => false, 'loadingText' => null, 'disabled' => false, 'href' => null, 'type' => 'button', 'full' => false, ]) @php $tag = $href ? 'a' : 'button'; $baseClasses = 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50'; $variantClasses = [ 'primary' => 'bg-primary text-primary-foreground shadow hover:bg-primary/90', 'secondary' => 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80', 'outline' => 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground', 'ghost' => 'hover:bg-accent hover:text-accent-foreground', 'danger' => 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90', 'success' => 'bg-success text-white shadow-sm hover:bg-success/90', 'warning' => 'bg-warning text-white shadow-sm hover:bg-warning/90', 'info' => 'bg-info text-white shadow-sm hover:bg-info/90', 'link' => 'text-primary underline-offset-4 hover:underline', ]; $sizeClasses = [ 'xs' => 'h-7 px-2 text-xs', 'sm' => 'h-8 px-3 text-xs', 'md' => 'h-9 px-4 py-2', 'lg' => 'h-10 px-8', 'xl' => 'h-11 px-10 text-base', 'icon' => 'h-9 w-9', ]; $iconSizes = [ 'xs' => 'size-3', 'sm' => 'size-3.5', 'md' => 'size-4', 'lg' => 'size-4', 'xl' => 'size-5', 'icon' => 'size-4', ]; $classes = collect([ $baseClasses, $variantClasses[$variant] ?? $variantClasses['secondary'], $sizeClasses[$size] ?? $sizeClasses['md'], $full ? 'w-full' : '', ])->filter()->join(' '); $iconSize = $iconSizes[$size] ?? $iconSizes['md']; @endphp <{{ $tag }} @if($href) href="{{ $href }}" @endif @if($tag === 'button') type="{{ $type }}" @endif @if($disabled || $loading) disabled @endif {{ $attributes->class([$classes]) }} > @if($loading) {{ $loadingText ?? $slot }} @else @if($icon) @endif {{ $slot }} @if($iconRight) @endif @endif