export interface ScoreColorTokens { label: string; solid: string; gradientFrom: string; gradientTo: string; gradient: string; } export interface ScoreRingStrokeGradient { x1: string; y1: string; x2: string; y2: string; stops: ReadonlyArray<{ offset: string; stopColor: string }>; } export function getScoreRingStrokeGradient(score: number): ScoreRingStrokeGradient { const s = Number.isFinite(score) ? score : 0; const axis = { x1: '100%', y1: '50%', x2: '0%', y2: '50%' } as const; if (s >= 70) { return { ...axis, stops: [ { offset: '0%', stopColor: '#ffc15e' }, { offset: '100%', stopColor: '#68f349' }, ], }; } if (s >= 40) { return { ...axis, stops: [ { offset: '0%', stopColor: '#F34949' }, { offset: '50%', stopColor: '#f59e45' }, { offset: '100%', stopColor: '#ffc15e' }, ], }; } return { ...axis, stops: [ { offset: '0%', stopColor: '#F34949' }, { offset: '100%', stopColor: '#fb7185' }, ], }; } export function getScoreColors(score: number): ScoreColorTokens { const s = Number.isFinite(score) ? score : 0; if (s >= 70) { return { label: '#6cf24a', solid: '#68f349', gradientFrom: '#ffc15e', gradientTo: '#68f349', gradient: 'linear-gradient(to right, #ffc15e, #68f349)', }; } if (s >= 40) { return { label: '#ffc15e', solid: '#ffc15e', gradientFrom: '#F34949', gradientTo: '#ffc15e', gradient: 'linear-gradient(to right, #F34949 0%, #f59e45 50%, #ffc15e 100%)', }; } return { label: '#F34949', solid: '#F34949', gradientFrom: '#F34949', gradientTo: '#fb7185', gradient: 'linear-gradient(to right, #F34949 0%, #fb7185 100%)', }; }