{{-- ===================================================== Etebarit - by Gisoo Web Solutions ------------------------------------------------------ Gisoo.net ------------------------------------------------------ Copyright (c) 2026 Gisoo Web Solutions ===================================================== This code is protected by copyright ===================================================== File: bar.blade.php ------------------------------------------------------ Use: The multi-colour good-standing meter. Six tier segments sized by their score span, with a marker at the user's score, so a user sees at a glance which level they are on and how far into it. Reused on the dashboard and wherever a plan is locked by standing. The meter runs low(left) -> high(right); the labels are Persian. ===================================================== --}} @props([ 'score' => 0, 'level' => 0, 'showMeta' => true, // The label above the meter. Defaults to the first-person "your level"; // admin screens pass a third-person heading. 'heading' => null, // Optional Alpine expression (0..100) for a second, distinct marker showing // a plan's required level. Null hides it; used on the standing-lock modal. 'requiredPercentVar' => null, ]) @php use App\Support\GoodStanding; $score = (int) $score; $level = (int) $level; $tiers = GoodStanding::tiers(); $count = count($tiers); $percent = GoodStanding::percent($score); $color = GoodStanding::color($level); $label = GoodStanding::label($level); // Segment widths follow each tier's score span so the marker lands exactly // on the boundary between levels. $segments = []; foreach ($tiers as $i => $tier) { $next = $i + 1 < $count ? $tiers[$i + 1]['min'] : GoodStanding::MAX_SCORE; $segments[] = [ 'color' => $tier['color'], 'width' => ($next - $tier['min']) / GoodStanding::MAX_SCORE * 100, ]; } @endphp