import { cn } from "@/lib/utils"; interface QuotaBarProps { label: string; // value between 0 and 100 percentUsed: number; leftLabel: string; rightLabel?: string; // shows a 2px destructive notch at the fill tip when true showDeficitNotch?: boolean; className?: string; } function fillColor(pct: number): string { if (pct > 90) return "bg-red-400"; if (pct > 70) return "bg-yellow-400"; return "bg-green-400"; } export function QuotaBar({ label, percentUsed, leftLabel, rightLabel, showDeficitNotch = false, className, }: QuotaBarProps) { const clampedPct = Math.min(100, Math.max(0, percentUsed)); // keep the notch visible even near the edges const notchLeft = Math.min(clampedPct, 97); return (
{/* row header */}
{label}
{leftLabel} {rightLabel && ( {rightLabel} )}
{/* track — boxed border, square corners to match the theme */}
{/* fill */}
{/* deficit notch — 2px wide, sits at the fill tip */} {showDeficitNotch && clampedPct > 0 && (
)}
); }