import * as React from 'react' import { cn } from '@/lib/utils' export type ProgressRingVariant = 'DEFAULT' | 'ACTIVE' | 'WARNING' | 'CRITICAL' export interface ProgressRingProps extends React.HTMLAttributes { value: number size?: number strokeWidth?: number label?: string showValue?: boolean variant?: ProgressRingVariant } const ProgressRing = React.forwardRef( ( { className, value = 0, size = 120, strokeWidth = 6, label, showValue = true, variant = 'DEFAULT', style, ...props }, ref ) => { const pct = Math.min(Math.max(value, 0), 100) const cx = size / 2 const cy = size / 2 const r = (size - strokeWidth) / 2 const circ = 2 * Math.PI * r const offset = circ * (1 - pct / 100) const accentColor = variant === 'ACTIVE' ? 'var(--color-green)' : variant === 'WARNING' ? 'var(--color-amber)' : variant === 'CRITICAL' ? 'var(--color-red)' : 'var(--text-secondary)' const textGlow = variant === 'ACTIVE' ? 'var(--text-glow-green)' : variant === 'WARNING' ? 'var(--text-glow-amber)' : variant === 'CRITICAL' ? 'var(--text-glow-red)' : 'none' const isSmall = size < 80 return (
{/* Center label */}
{showValue && ( {Math.round(pct)}% )} {label && ( {label} )}
) } ) ProgressRing.displayName = 'ProgressRing' export { ProgressRing }