@props(['label', 'value', 'unit' => null, 'sub' => null, 'icon' => null, 'series' => [], 'tone' => 'accent', 'trend' => null]) @php use Illuminate\Support\Str; $stroke = [ 'accent' => 'text-accent', 'cyan' => 'text-cyan', 'online' => 'text-online', 'warning' => 'text-warning', 'offline' => 'text-offline', ][$tone] ?? 'text-accent'; $gid = 'm-'.Str::slug($label); // sparkline path from the series $n = count($series); $w = 100; $h = 40; $pad = 4; $pts = []; $min = $n ? min($series) : 0; $max = $n ? max($series) : 1; $range = max(1, $max - $min); foreach ($series as $i => $v) { $x = $n > 1 ? round($i / ($n - 1) * $w, 2) : 0; $y = round($h - $pad - (($v - $min) / $range) * ($h - 2 * $pad), 2); $pts[] = "$x,$y"; } $line = implode(' ', $pts); $area = $n ? "0,$h ".$line." $w,$h" : ''; $trendColor = ['up' => 'text-online', 'down' => 'text-offline', 'flat' => 'text-ink-3'][$trend['dir'] ?? 'flat'] ?? 'text-ink-3'; $arrow = ['up' => '▲', 'down' => '▼', 'flat' => '▪'][$trend['dir'] ?? 'flat'] ?? '▪'; @endphp
merge(['class' => 'relative flex min-h-[122px] flex-col gap-2.5 overflow-hidden rounded-lg border border-line bg-surface pt-4 shadow-panel']) }}>
@if ($icon)@endif {{ $label }} @if ($trend) {{ $arrow }} {{ $trend['text'] }} @endif
{{ $value }} @if ($unit){{ $unit }}@endif @if ($sub){{ $sub }}@endif