Files
Virtnet.bond/extensions/Servers/Proxmox/views/components/ui/stat-card.blade.php
Joseph.Rawlings af62a16354 Refactor modal close behavior and improve styling
- Changed modal close event from `@click.away` to `@click.self` for better control over closing modals.
- Updated various modal button styles for consistency and improved accessibility.
- Adjusted transition durations for modal animations to enhance user experience.
- Added aria-labels to close buttons for better screen reader support.
2026-02-23 20:02:41 -05:00

125 lines
5.0 KiB
PHP

{{--
Stat Card Component - LucentUI Theme
Migrated from AdminLTE to Tailwind
Usage:
<x-proxmox::ui.stat-card value="12" label="CPU %" />
<x-proxmox::ui.stat-card value="8.5" suffix="GB" label="Memory" icon="ri-database-2-line" />
<x-proxmox::ui.stat-card value="3" label="Servers" status="success" statusText="All active" />
--}}
@props([
'value',
'label',
'suffix' => null,
'prefix' => null,
'icon' => null,
'iconClass' => '',
'variant' => null, // primary, success, warning, danger, info
'status' => null,
'statusText' => null,
'href' => null,
'progress' => null,
'progressColor' => 'primary',
'clickable' => false,
'compact' => false,
'change' => null,
'changeLabel' => null,
])
@php
$tag = $href ? 'a' : 'div';
$variantClasses = [
'primary' => 'bg-primary',
'success' => 'bg-success',
'warning' => 'bg-warning',
'danger' => 'bg-error',
'info' => 'bg-info',
];
$progressColors = [
'primary' => 'bg-primary',
'success' => 'bg-success',
'warning' => 'bg-warning',
'danger' => 'bg-error',
'info' => 'bg-info',
];
$statusClasses = [
'success' => 'text-success',
'warning' => 'text-warning',
'danger' => 'text-error',
'info' => 'text-info',
'muted' => 'text-secondary',
];
$statusClass = $statusClasses[$status] ?? '';
$progressBarColor = $progressColors[$progressColor] ?? $progressColors['primary'];
@endphp
@if($variant)
{{-- Small Box Style (colored background) --}}
<{{ $tag }}
@if($href) href="{{ $href }}" @endif
{{ $attributes->class([
'relative block overflow-hidden rounded-xl text-white transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5 hover:scale-[1.01]',
$variantClasses[$variant] ?? 'bg-primary',
]) }}
>
<div class="p-5">
<h3 class="text-2xl font-bold transition-transform duration-200">{{ $prefix }}{{ $value }}@if($suffix)<sup class="text-sm opacity-75">{{ $suffix }}</sup>@endif</h3>
<p class="text-sm opacity-90 mt-1">{{ $label }}</p>
</div>
@if($icon)
<div class="absolute top-4 right-4 opacity-30 transition-transform duration-300 hover:scale-110">
<x-dynamic-component :component="$icon" class="size-16" />
</div>
@endif
@if($statusText)
<div class="px-5 py-3 bg-black/10 text-sm transition-colors duration-200 hover:bg-black/20 flex items-center justify-between">
<span>{{ $statusText }}</span>
<x-ri-arrow-right-line class="size-4 card-arrow-animate" />
</div>
@endif
</{{ $tag }}>
@else
{{-- Info Box Style (white background with icon accent) --}}
<{{ $tag }}
@if($href) href="{{ $href }}" @endif
{{ $attributes->class([
'flex items-start gap-4 p-5 bg-background dark:bg-background-secondary border border-neutral rounded-xl shadow-sm group transition-all duration-300 hover:shadow-md hover:-translate-y-0.5',
'cursor-pointer' => $href || $clickable,
]) }}
>
@if($icon)
<span class="flex items-center justify-center w-12 h-12 bg-primary rounded-lg text-white shrink-0 transition-transform duration-300 group-hover:scale-110">
<x-dynamic-component :component="$icon" class="size-6 {{ $iconClass }}" />
</span>
@endif
<div class="flex-1 min-w-0">
<span class="text-xs font-medium text-secondary dark:text-base/50 uppercase tracking-wide">{{ $label }}</span>
<span class="block text-xl font-bold text-primary dark:text-base/90 mt-1 transition-colors duration-200 group-hover:text-primary">
@if($prefix)<small class="text-secondary dark:text-base/50 text-sm font-normal">{{ $prefix }}</small>@endif{{ $value }}@if($suffix)<small class="text-secondary dark:text-base/50 text-sm font-normal">{{ $suffix }}</small>@endif
</span>
@if($change !== null || $changeLabel)
<div class="text-xs text-secondary dark:text-base/50 mt-1">
@if($change !== null)
<span class="{{ $change >= 0 ? 'text-success' : 'text-error' }} font-semibold">
{{ $change >= 0 ? '+' : '' }}{{ $change }}%
</span>
@endif
{{ $changeLabel ?? 'from last period' }}
</div>
@endif
@if($progress !== null)
<div class="h-1.5 bg-neutral/30 rounded-full overflow-hidden mt-3">
<div class="{{ $progressBarColor }} h-full rounded-full transition-all duration-500" style="width: {{ min(100, $progress) }}%"></div>
</div>
@endif
@if($statusText)
<span class="text-xs {{ $statusClass }} mt-2 inline-block">{{ $statusText }}</span>
@endif
</div>
</{{ $tag }}>
@endif