PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 9m36s
PR Checks / Backend Smoke (pull_request) Successful in 5s
PR Checks / Build Backend (no push) (pull_request) Successful in 10s
PR Checks / Build Frontend (no push) (pull_request) Successful in 44s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 10s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 2m49s
The compare chart squashed clustered schools into a thin band (y pinned 0-100) under an in-chart title + per-school legend that ate ~40% of a 300px card, leaving converging lines indistinguishable on phones. - Auto-fit the y-axis to the data on all viewports (computeYBounds in lib/utils: padded + min-span for percentages, symmetric around 0 for progress, fitted for scores; negative pct-named trend metrics are not zero-clamped). - Distinct point style per school (circle/triangle/rect/rectRot/star) as secondary encoding for convergence and colour-blindness. - Mobile: drop in-chart title/legend/axis titles; add a chip row (colour dot + name) that doubles as tap-to-focus — highlights one school's line and dims the rest. Chart card 300px -> 340px, nearly all plot. - Fix a latent colour mismatch: datasets were built from Object.entries whose integer-like URN keys enumerate in ascending numeric order, desyncing line colours from card colours; the chart now receives the ordered school list. - Union years across schools instead of taking the first school's. - Extract PerformanceChart's matchMedia pattern into hooks/useIsMobile. Unit tests for metricKind/computeYBounds; e2e journey covers the mobile chips and focus toggle. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
24 lines
644 B
TypeScript
24 lines
644 B
TypeScript
/**
|
|
* Viewport hook shared by the chart components.
|
|
* Hydration-safe: SSR and the first client render report desktop; the
|
|
* media-query subscription flips the value after mount.
|
|
*/
|
|
|
|
'use client';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
export function useIsMobile(maxWidth = 640): boolean {
|
|
const [isMobile, setIsMobile] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const mq = window.matchMedia(`(max-width: ${maxWidth}px)`);
|
|
const update = () => setIsMobile(mq.matches);
|
|
update();
|
|
mq.addEventListener('change', update);
|
|
return () => mq.removeEventListener('change', update);
|
|
}, [maxWidth]);
|
|
|
|
return isMobile;
|
|
}
|