Files
Virtnet.bond/extensions/Servers/Proxmox/views/components/ui/button.blade.php
Joseph.Rawlings 7a089f53e2 refactor: Update UI components to TailAdmin theme
- Changed badge, button, card, dropdown, input, modal, select, table, tabs, toggle, and tooltip components to align with the TailAdmin design system.
- Updated class names and styles for consistency across components.
- Enhanced accessibility and responsiveness in various components.
- Improved hover and focus states for better user experience.
2025-12-17 12:07:54 -05:00

91 lines
3.7 KiB
PHP

{{--
Button Component - TailAdmin Theme
Usage:
<x-proxmox::ui.button>Click me</x-proxmox::ui.button>
<x-proxmox::ui.button variant="primary" icon="ri-add-line">Add Server</x-proxmox::ui.button>
<x-proxmox::ui.button variant="danger" size="sm">Delete</x-proxmox::ui.button>
<x-proxmox::ui.button :loading="true">Processing</x-proxmox::ui.button>
--}}
@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-lg font-medium transition-colors focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-brand-500/10 disabled:pointer-events-none disabled:opacity-50';
$variantClasses = [
'primary' => 'bg-brand-500 text-white shadow-theme-xs hover:bg-brand-600',
'secondary' => 'bg-white text-gray-700 shadow-theme-xs ring-1 ring-gray-300 hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-400 dark:ring-gray-700 dark:hover:bg-white/[0.03]',
'outline' => 'border border-gray-300 bg-white shadow-theme-xs hover:bg-gray-50 hover:text-gray-800 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-white/[0.03] dark:hover:text-gray-200',
'ghost' => 'hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-white/5 dark:hover:text-gray-300',
'danger' => 'bg-error-500 text-white shadow-theme-xs hover:bg-error-600',
'success' => 'bg-success-500 text-white shadow-theme-xs hover:bg-success-600',
'warning' => 'bg-warning-500 text-white shadow-theme-xs hover:bg-warning-600',
'info' => 'bg-blue-light-500 text-white shadow-theme-xs hover:bg-blue-light-600',
'link' => 'text-brand-500 hover:text-brand-600 hover:underline underline-offset-4',
];
$sizeClasses = [
'xs' => 'h-8 px-2.5 text-xs',
'sm' => 'h-9 px-3 text-sm',
'md' => 'h-10 px-4 text-sm',
'lg' => 'h-11 px-5 text-sm',
'xl' => 'h-12 px-6 text-base',
'icon' => 'h-10 w-10',
];
$iconSizes = [
'xs' => 'size-3.5',
'sm' => 'size-4',
'md' => 'size-4',
'lg' => 'size-5',
'xl' => 'size-5',
'icon' => 'size-5',
];
$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)
<svg class="animate-spin {{ $iconSize }}" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span>{{ $loadingText ?? $slot }}</span>
@else
@if($icon)
<x-dynamic-component :component="$icon" class="fill-current {{ $iconSize }}" />
@endif
{{ $slot }}
@if($iconRight)
<x-dynamic-component :component="$iconRight" class="fill-current {{ $iconSize }}" />
@endif
@endif
</{{ $tag }}>