Make the disk space meter visible and show used percent.
Use an inline-colored full-width progress bar so the fill renders without relying on purged Tailwind classes.
This commit is contained in:
@@ -1,24 +1,33 @@
|
||||
@php
|
||||
/** @var array{used_percent: float, free_percent: float, free_human: string, total_human: string, used_human: string} $disk */
|
||||
$usedPercent = min(100, max(0, (float) $disk['used_percent']));
|
||||
$usedPercentLabel = rtrim(rtrim(number_format($usedPercent, 1, '.', ''), '0'), '.') ?: '0';
|
||||
$freePercent = (float) ($disk['free_percent'] ?? 100);
|
||||
// Inline colors so the fill is visible even before / without a Tailwind rebuild.
|
||||
$fillColor = match (true) {
|
||||
$freePercent <= 5 => '#dc2626',
|
||||
$freePercent <= 15 => '#f59e0b',
|
||||
default => '#0d9488',
|
||||
};
|
||||
@endphp
|
||||
<div
|
||||
class="flex items-center gap-2 rounded-lg border border-zinc-200 bg-zinc-50 px-2.5 py-1.5 dark:border-zinc-600 dark:bg-zinc-900/50"
|
||||
title="{{ $disk['free_human'] }} free of {{ $disk['total_human'] }} · {{ $disk['used_percent'] }}% used"
|
||||
class="flex min-w-36 flex-col gap-1 rounded-lg border border-zinc-200 bg-zinc-50 px-2.5 py-1.5 dark:border-zinc-600 dark:bg-zinc-900/50"
|
||||
title="{{ $disk['free_human'] }} free of {{ $disk['total_human'] }} · {{ $usedPercentLabel }}% used"
|
||||
>
|
||||
<div
|
||||
class="h-1.5 w-14 shrink-0 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700"
|
||||
class="h-2 w-full overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700"
|
||||
role="progressbar"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100"
|
||||
aria-valuenow="{{ (int) round($disk['used_percent']) }}"
|
||||
aria-label="Disk space used"
|
||||
aria-valuenow="{{ (int) round($usedPercent) }}"
|
||||
aria-label="Disk space {{ $usedPercentLabel }}% used"
|
||||
>
|
||||
<div
|
||||
class="h-full rounded-full transition-[width] duration-300 {{ $barColor }}"
|
||||
style="width: {{ min(100, max(0, $disk['used_percent'])) }}%"
|
||||
class="h-full rounded-full transition-[width] duration-300"
|
||||
style="width: {{ $usedPercent }}%; background-color: {{ $fillColor }};"
|
||||
></div>
|
||||
</div>
|
||||
<span class="hidden text-xs font-medium tabular-nums text-zinc-600 sm:inline dark:text-zinc-300">
|
||||
{{ $disk['free_human'] }} free
|
||||
<span class="text-xs font-medium tabular-nums text-zinc-600 dark:text-zinc-300">
|
||||
{{ $usedPercentLabel }}% used · {{ $disk['free_human'] }} free
|
||||
</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user