import { motion } from 'motion/react'; interface ScoreRingProps { score: number; maxScore?: number; size?: number; label?: string; color?: string; /** 링 중앙 숫자 타이포 오버라이드 (기본 text-2xl) */ valueClassName?: string; /** 링 중앙 숫자 아래 보조 표기 (예: "/ 100") */ subLabel?: string; } function getScoreColor(score: number, maxScore: number): string { const pct = (score / maxScore) * 100; if (pct <= 40) return '#C084CF'; // soft violet — critical if (pct <= 60) return '#8B9CF7'; // periwinkle blue — caution if (pct <= 80) return '#7C6DD8'; // medium purple — good return '#6C5CE7'; // Infinith primary purple — excellent } export function ScoreRing({ score, maxScore = 100, size = 120, label, color, valueClassName = 'text-2xl', subLabel, }: ScoreRingProps) { const strokeWidth = 8; const radius = (size - strokeWidth) / 2; const circumference = 2 * Math.PI * radius; const progress = Math.min(score / maxScore, 1); const strokeDashoffset = circumference * (1 - progress); const resolvedColor = color ?? getScoreColor(score, maxScore); return (
{score} {subLabel && {subLabel}}
{label && ( {label} )}
); }