import { useMemo } from 'react'; import { cn } from '@/lib/utils'; export interface ProgressProps { value: number; // 0-100 max?: number; variant?: 'linear' | 'circular'; showLabel?: boolean; label?: string; color?: string; className?: string; } /** * Composant Progress pour afficher la progression d'une opération. */ export function Progress({ value, max = 100, variant = 'linear', showLabel = false, label, color, className, }: ProgressProps) { const percentage = useMemo(() => { const clampedValue = Math.max(0, Math.min(value, max)); return Math.round((clampedValue / max) * 100); }, [value, max]); if (variant === 'circular') { const radius = 20; const circumference = 2 * Math.PI * radius; const strokeDashoffset = circumference - (percentage / 100) * circumference; return (
{/* Background circle */} {/* Progress circle */} {showLabel && ( {percentage}% )}
); } return (
{(showLabel || label) && (
{label && {label}} {showLabel && ( {percentage}% )}
)}
); }