@props([ 'label', 'value', 'icon' => 'chart', 'tone' => 'brand', // brand|ok|warn|bad|info|muted 'trend' => null, // ['direction' => up|down, 'percent' => float|null] or null 'hint' => null, 'goodWhenDown' => false, // e.g. expired licences falling is good news 'dense' => false, // for pages where the card is furniture, not the subject ]) @php $tones = [ 'brand' => ['bg' => 'bg-brand-50 dark:bg-brand-500/10', 'fg' => 'text-brand-600 dark:text-brand-400'], 'ok' => ['bg' => 'bg-emerald-50 dark:bg-emerald-500/10','fg' => 'text-emerald-600 dark:text-emerald-400'], 'warn' => ['bg' => 'bg-amber-50 dark:bg-amber-500/10', 'fg' => 'text-amber-600 dark:text-amber-400'], 'bad' => ['bg' => 'bg-red-50 dark:bg-red-500/10', 'fg' => 'text-red-600 dark:text-red-400'], 'info' => ['bg' => 'bg-blue-50 dark:bg-blue-500/10', 'fg' => 'text-blue-600 dark:text-blue-400'], 'muted' => ['bg' => 'bg-slate-100 dark:bg-slate-700/40', 'fg' => 'text-slate-600 dark:text-slate-300'], ]; $t = $tones[$tone] ?? $tones['brand']; // A rising number is not automatically good news - expired licences going // up is bad. goodWhenDown flips the colour without flipping the arrow, so // the direction stays factual and only the sentiment changes. $isUp = ($trend['direction'] ?? null) === 'up'; $isPositive = $goodWhenDown ? ! $isUp : $isUp; $trendColour = $isPositive ? 'text-emerald-600 dark:text-emerald-400' : 'text-red-600 dark:text-red-400'; @endphp

{{ $label }}

{{ $value }}

@if ($trend && $trend['percent'] !== null) {{ $trend['percent'] }}% from last period @elseif ($trend) {{-- Movement with nothing to compare against: say so rather than --}} {{-- printing a meaningless 100%. --}} New no prior period @else {{ $hint ?? 'No change to report' }} @endif