import { Box } from "@mui/material"; import { NUTRI_SCORES, NutriScoreValue } from "@/types"; const NUTRISCORE_COLORS: Record = { a: '#0d8949', b: '#72c72b', c: '#fbc606', d: '#f37115', e: '#ee301f', }; type NutriScoreBadgeProps = { score: NutriScoreValue; size?: 'small' | 'medium' | 'large'; }; const SIZES = { small: { height: 20, activeHeight: 24, fontSize: 10, activeFontSize: 14, px: 3, activePx: 2 }, medium: { height: 22, activeHeight: 28, fontSize: 12, activeFontSize: 16, px: 3, activePx: 3, }, large: { height: 28, activeHeight: 36, fontSize: 15, activeFontSize: 20, px: 4, activePx: 4 }, }; export function NutriScoreBadge({ score, size = 'medium' }: NutriScoreBadgeProps) { const dim = SIZES[size]; return ( {NUTRI_SCORES.map((s, i) => { const isActive = s === score; const height = isActive ? dim.activeHeight : dim.height; const fontSize = isActive ? dim.activeFontSize : dim.fontSize; const isFirst = i === 0; const isLast = i === NUTRI_SCORES.length - 1; return ( {s.toUpperCase()} ); })} ); }