interface ProgressBarProps { value: number; max?: number; showLabel?: boolean; size?: "sm" | "md" | "lg"; variant?: "default" | "success" | "warning" | "error"; className?: string; } const sizeStyles = { sm: "h-1.5", md: "h-2", lg: "h-4", }; const variantStyles = { default: "bg-primary", success: "bg-success", warning: "bg-warning", error: "bg-destructive", }; export function ProgressBar({ value, max = 100, showLabel = false, size = "md", variant = "default", className = "" }: ProgressBarProps) { const percent = Math.min(100, Math.max(0, (value / max) * 100)); return (
{showLabel && ( {Math.round(percent)}% )}
); } // Mini Progress Bar (for compact displays) interface MiniProgressBarProps { value: number; max?: number; variant?: "default" | "success" | "warning" | "error"; className?: string; } export function MiniProgressBar({ value, max = 100, variant = "default", className = "" }: MiniProgressBarProps) { const percent = Math.min(100, Math.max(0, (value / max) * 100)); return (
); } // Progress indicator with status colors based on percentage interface SmartProgressBarProps { value: number; max?: number; size?: "sm" | "md" | "lg"; className?: string; } export function SmartProgressBar({ value, max = 100, size = "md", className = "" }: SmartProgressBarProps) { const percent = Math.min(100, Math.max(0, (value / max) * 100)); // Determine variant based on percentage let variant: "default" | "success" | "warning" | "error" = "default"; if (percent === 100) variant = "success"; else if (percent < 25) variant = "error"; else if (percent < 50) variant = "warning"; return ; } // Circular Progress (for special use cases) interface CircularProgressProps { value: number; max?: number; size?: number; strokeWidth?: number; className?: string; } export function CircularProgress({ value, max = 100, size = 40, strokeWidth = 4, className = "" }: CircularProgressProps) { const percent = Math.min(100, Math.max(0, (value / max) * 100)); const radius = (size - strokeWidth) / 2; const circumference = radius * 2 * Math.PI; const offset = circumference - (percent / 100) * circumference; // Determine color based on percentage let color = "hsl(var(--color-primary))"; if (percent === 100) color = "hsl(var(--color-success))"; else if (percent < 25) color = "hsl(var(--color-destructive))"; else if (percent < 50) color = "hsl(var(--color-warning))"; return (
{Math.round(percent)}%
); }