/** * DotStrip — the compare screen's signature element: one measure per strip, * every school's dot on a shared track, anchored by a grey England-average * tick so "right of the tick = above average" needs no domain knowledge. */ 'use client'; import { stripPositions } from '@/lib/compareLogic'; import { CHART_COLORS, CHART_TEXT_COLORS } from '@/lib/utils'; import styles from './DotStrip.module.css'; export interface DotStripProps { label: string; /** One value per school; index = the school's chart-colour index. */ values: Array; schoolNames: string[]; /** Anchor tick, e.g. { value: 62, label: 'England 62%' }. Omit when the * benchmark isn't available — the caller should say why in `headNote`. */ anchor?: { value: number; label: string } | null; min?: number; max?: number; unit?: string; /** Tooltip on the measure label (plain-English definition). */ tip?: string; /** Small note on the right of the header row (e.g. the tick legend). */ headNote?: string; } export function DotStrip({ label, values, schoolNames, anchor = null, min = 0, max = 100, unit = '%', tip, headNote, }: DotStripProps) { const points = stripPositions(values, min, max); const span = max - min; const anchorPos = anchor != null ? Math.min(100, Math.max(0, ((anchor.value - min) / span) * 100)) : null; const ariaParts = [ anchor ? `${anchor.label}` : null, ...points.map( (p) => `${schoolNames[p.schoolIndex] ?? `School ${p.schoolIndex + 1}`} ${p.value}${unit}`, ), ].filter(Boolean); return (
{label} {headNote && {headNote}}
{anchorPos != null && anchor && ( <> {anchor.label} )} {points.map((p) => ( {p.value} ))}
); }