@props([ 'rows' => [], // rows from MetricComparisonService::rows() 'title' => null, // card heading (null → no header bar) 'subtitle' => null, // Compact variant: half-height rows (inline attainment, short sparkline) for // pages that stack several panels and cannot spend 70px a row. Every column // still renders — nothing is dropped to save the space. 'dense' => false, ]) @php // Attainment cell styling: a coloured % with a thin track bar. Distinct from // the growth chips (signed arrows) so "94% of target" never reads like "+94%". $attain = function (?int $pct): array { if ($pct === null) { return ['label' => '—', 'text' => 'text-slate-300', 'bar' => 'bg-slate-200', 'width' => 0]; } [$text, $bar] = match (true) { $pct >= 100 => ['text-emerald-700', 'bg-emerald-500'], $pct >= 80 => ['text-amber-700', 'bg-amber-500'], default => ['text-rose-700', 'bg-rose-500'], }; return ['label' => $pct . '%', 'text' => $text, 'bar' => $bar, 'width' => max(2, min(100, $pct))]; }; $rowPad = $dense ? 'py-1.5' : 'py-2.5'; $sparkBox = $dense ? 'w-20' : 'w-24'; $sparkHeight = $dense ? 30 : 60; @endphp merge(['class' => $dense ? 'p-5' : 'p-6']) }}> @if ($title)

{{ $title }}

@if ($subtitle)

{{ $subtitle }}

@endif
{{ __('Growth vs prior') }} {{ __('Attainment vs target') }}
@endif
@forelse ($rows as $r) {{-- Growth: signed delta chips --}} {{-- Attainment: coloured % with a track bar. Dense lays the two side by side so the row keeps a single text line. --}} @foreach (['m_vs_tg', 'sixm_vs_tg', 'ytd_vs_tg'] as $i => $k) @php $a = $attain($r[$k]); @endphp @endforeach {{-- Trailing-12-month sparkline --}} @empty @endforelse
{{ __('Metric') }} {{ __('Current') }} {{ __('Growth') }} {{ __('vs Target') }} {{ __('12-mo Trend') }}
{{ __('MoM') }} {{ __('YoY') }} {{ __('6M') }} {{ __('YTD') }} {{ __('M') }} {{ __('6M') }} {{ __('YTD') }}
{{ $r['label'] }} @if ($r['target_display'] !== null) @endif {{ $r['current_display'] }}
{{ $a['label'] }}
{{ __('No metrics to compare yet.') }}