@props(['used', 'limit' => null, 'label' => 'Usage', 'planName' => null]) @php $hasLimit = ! is_null($limit) && $limit > 0; $percent = $hasLimit ? min(100, max(0, ($used / $limit) * 100)) : 0; $band = ! $hasLimit ? 'unlimited' : ($percent >= 100 ? 'full' : ($percent >= 80 ? 'near' : 'good')); $ringClass = [ 'unlimited' => 'text-brand-500', 'good' => 'text-emerald-500', 'near' => 'text-amber-500', 'full' => 'text-rose-500', ][$band]; $textClass = [ 'unlimited' => 'text-brand-700 dark:text-brand-300', 'good' => 'text-emerald-700 dark:text-emerald-300', 'near' => 'text-amber-700 dark:text-amber-300', 'full' => 'text-rose-700 dark:text-rose-300', ][$band]; $wrapClass = [ 'unlimited' => 'border-brand-200/70 bg-brand-50/60 dark:border-brand-500/20 dark:bg-brand-500/5', 'good' => 'border-slate-200/70 bg-white dark:border-slate-800 dark:bg-slate-900', 'near' => 'border-amber-200/70 bg-amber-50/60 dark:border-amber-500/20 dark:bg-amber-500/5', 'full' => 'border-rose-200/70 bg-rose-50/60 dark:border-rose-500/20 dark:bg-rose-500/5', ][$band]; $pillText = [ 'unlimited' => 'Unlimited', 'good' => 'On track', 'near' => 'Almost full', 'full' => 'Limit reached', ][$band]; // SVG ring geometry $radius = 15; $circumference = 2 * M_PI * $radius; $offset = $hasLimit ? $circumference * (1 - $percent / 100) : 0; @endphp
{{ $label }} {{ $pillText }}
@if($hasLimit) {{ $used }}/{{ $limit }} · @endif {{ $planName ? $planName.' Plan' : 'Current plan' }} @if(in_array($band, ['full', 'near'])) · Upgrade → @endif