File size: 566 Bytes
db764ae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import { scoreColor } from "../utils/colors";
interface ScoreBarProps {
score: number;
max?: number;
}
export default function ScoreBar({ score, max = 1 }: ScoreBarProps) {
const pct = Math.min(100, Math.max(0, (score / max) * 100));
const color = scoreColor(score);
return (
<div className="score-bar-container">
<div className="score-bar">
<div className="score-bar-fill" style={{ width: `${pct}%`, background: color }} />
</div>
<span className="score-label" style={{ color }}>{score.toFixed(4)}</span>
</div>
);
}
|