Files
Virtnet.bond/extensions/Servers/Proxmox/views/components/button.blade.php
Joseph.Rawlings e7b33a2f6c Refactor Proxmox server views for improved UI consistency and usability
- Updated server card component to use new UI elements and improved layout.
- Enhanced status display with badges and better status indicators.
- Refined quick info row for server details with consistent styling.
- Reorganized server configuration statistics into stat cards for clarity.
- Improved help modals for statistics and storage management sections.
- Streamlined alerts and warnings for better user experience.
- Updated storage management view to utilize new UI components and improve readability.
2025-12-17 11:24:17 -05:00

123 lines
4.7 KiB
PHP

@props([
'type' => 'button',
'variant' => 'primary',
'size' => 'md',
'icon' => null,
'iconPosition' => 'left',
'iconClass' => null,
'loading' => false,
'disabled' => false,
'fullWidth' => false,
'href' => null,
'outline' => false,
'rounded' => 'lg',
])
@php
// Base classes
$baseClasses = 'inline-flex items-center justify-center font-semibold transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed';
// Size classes
$sizeClasses = match($size) {
'xs' => 'px-2 py-1 text-xs gap-1',
'sm' => 'px-3 py-1.5 text-sm gap-1.5',
'md' => 'px-4 py-2 text-sm gap-2',
'lg' => 'px-5 py-2.5 text-base gap-2',
'xl' => 'px-6 py-3 text-base gap-2.5',
default => 'px-4 py-2 text-sm gap-2',
};
// Icon size classes
$iconSizeClasses = $iconClass ?? match($size) {
'xs' => 'size-3',
'sm' => 'size-3.5',
'md' => 'size-4',
'lg' => 'size-5',
'xl' => 'size-5',
default => 'size-4',
};
// Variant classes
$variantClasses = match($variant) {
'primary' => $outline
? 'border-2 border-primary text-primary hover:bg-primary hover:text-white focus:ring-primary/50'
: 'bg-primary text-white hover:bg-primary/90 focus:ring-primary/50',
'secondary' => $outline
? 'border-2 border-secondary text-secondary hover:bg-secondary hover:text-white focus:ring-secondary/50'
: 'bg-secondary text-white hover:bg-secondary/90 focus:ring-secondary/50',
'success' => $outline
? 'border-2 border-success text-success hover:bg-success hover:text-white focus:ring-success/50'
: 'bg-success text-white hover:bg-success/90 focus:ring-success/50',
'danger' => $outline
? 'border-2 border-danger text-danger hover:bg-danger hover:text-white focus:ring-danger/50'
: 'bg-danger text-white hover:bg-danger/90 focus:ring-danger/50',
'warning' => $outline
? 'border-2 border-warning text-warning hover:bg-warning hover:text-white focus:ring-warning/50'
: 'bg-warning text-white hover:bg-warning/90 focus:ring-warning/50',
'info' => $outline
? 'border-2 border-info text-info hover:bg-info hover:text-white focus:ring-info/50'
: 'bg-info text-white hover:bg-info/90 focus:ring-info/50',
'ghost' => 'text-base/70 hover:text-base/90 hover:bg-neutral/10 focus:ring-neutral/50',
'link' => 'text-primary hover:text-primary/80 underline-offset-4 hover:underline focus:ring-primary/50 p-0',
'neutral' => $outline
? 'border border-neutral/30 text-base/70 hover:bg-neutral/10 hover:text-base/90 focus:ring-neutral/50'
: 'bg-neutral/10 text-base/80 hover:bg-neutral/20 focus:ring-neutral/50',
default => $outline
? 'border-2 border-primary text-primary hover:bg-primary hover:text-white focus:ring-primary/50'
: 'bg-primary text-white hover:bg-primary/90 focus:ring-primary/50',
};
// Rounded classes
$roundedClasses = match($rounded) {
'none' => 'rounded-none',
'sm' => 'rounded-sm',
'md' => 'rounded-md',
'lg' => 'rounded-lg',
'xl' => 'rounded-xl',
'full' => 'rounded-full',
default => 'rounded-lg',
};
// Full width
$widthClasses = $fullWidth ? 'w-full' : '';
// Combined classes
$classes = "$baseClasses $sizeClasses $variantClasses $roundedClasses $widthClasses";
// Determine tag
$tag = $href ? 'a' : 'button';
@endphp
@if($href)
<a href="{{ $href }}" {{ $attributes->merge(['class' => $classes]) }}>
@else
<button
type="{{ $type }}"
{{ $disabled || $loading ? 'disabled' : '' }}
{{ $attributes->merge(['class' => $classes]) }}
>
@endif
@if($loading)
<svg class="animate-spin {{ $iconSizeClasses }}" 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>
@elseif($icon && $iconPosition === 'left')
<x-dynamic-component :component="$icon" class="{{ $iconSizeClasses }}" />
@endif
@if($slot->isNotEmpty())
<span>{{ $slot }}</span>
@endif
@if($icon && $iconPosition === 'right' && !$loading)
<x-dynamic-component :component="$icon" class="{{ $iconSizeClasses }}" />
@endif
@if($href)
</a>
@else
</button>
@endif