Accessibility: reader view and full palette swaps; version v1.12.1-accessibility

- Reading mode is now a reader view (ReaderView.tsx): the page renders
  hidden and its headings, paragraphs, links and described pictures
  are written out in one column, with no header, backdrop or footer.
- Color blind modes swap all three color families (teal, green,
  amber); palette hexes in components and CSS are now
  var(--pal-<family>-<shade>) so the modes reach them.
- CLAUDE.md and docs/updating-data-in-code.md describe both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-03 16:10:57 -05:00
parent 420a8058b4
commit de17da7dc8
19 changed files with 507 additions and 192 deletions

View file

@ -61,17 +61,26 @@ export const STORED_PALETTE = {
<html data-vision> is set before the first paint (index.html)
and a change reloads the page, so it's read once here.
Simulated with the Machado (2009) matrices, the palette's green
and amber families blur together for protanopia and tritanopia,
so there green becomes violet, the same four shades at the same
contrasts (5.3:1 on white for the main one, 9:1 or better under
ink for the light ones). For deuteranopia the palette already
stays apart (violet or magenta would be worse), so it's kept.
In each of the three, a color an admin picked off the palette
snaps to the nearest palette color first, so two picked colors
can't land on one confusable pair. Monochrome is a grayscale
filter instead (index.css). The same swap for CSS is the
--green-* variables in index.css. */
Every color on the site is one of three color families (teal,
green, amber) or the gray ink. Seen with protanopia or
deuteranopia, colors fall on one blue to yellow line plus light
and dark; with tritanopia, on a red to cyan one. Three families at
one darkness can't all stay apart there, so each mode replaces all
three, at hues and darknesses picked by simulating the type (the
Machado 2009 matrices) to keep every pair, and each from the ink,
far apart for it and for typical vision too. The closest pair of
main or light shades, in CIELAB distance, goes from 11.4 to 27.9
(protanopia), 19.5 to 24.7 (deuteranopia) and 6.4 to 21.1
(tritanopia). Contrast holds: main shades 5.3:1 or more on white
and under white text, light shades 9:1 or more under ink, so the
theme tokens drawn from them (index.css) still read in both modes.
Each family keeps its role (teal is still the buttons and links).
A color an admin picked off the palette snaps to the nearest
palette shade first, so two picked colors can't land on one
confusable pair. Monochrome is a grayscale filter instead
(index.css). The same values for CSS are the --pal-* variables
in index.css. */
export const VISIONS = [
{ id: 'protanopia', label: 'Protanopia (red weak)' },
{ id: 'deuteranopia', label: 'Deuteranopia (green weak)' },
@ -79,11 +88,22 @@ export const VISIONS = [
{ id: 'monochrome', label: 'Monochrome' },
] as const
const VIOLET = ['#9839dc', '#4d1575', '#c9a5e3', '#f4eef9']
const SWAPS: Record<string, Partial<Record<keyof typeof STORED_PALETTE, string[]>>> = {
protanopia: { green: VIOLET },
deuteranopia: {},
tritanopia: { green: VIOLET },
protanopia: {
teal: ['#167c16', '#0b3c0b', '#55ca55', '#e3f5e3'],
green: ['#921a92', '#5b105b', '#e09ce0', '#f9edf9'],
amber: ['#603911', '#482a0d', '#d7ab7f', '#f7efe7'],
},
deuteranopia: {
teal: ['#3939dc', '#1b1b9b', '#aeaee6', '#f0f0fa'],
green: ['#11602b', '#0b3c1b', '#51c979', '#e1f5e7'],
amber: ['#627214', '#30370a', '#a7bd3b', '#eff3db'],
},
tritanopia: {
teal: ['#167a59', '#0a3b2a', '#4bc79e', '#e1f5ee'],
green: ['#a31d33', '#661220', '#e2a2ac', '#f9eef0'],
amber: ['#6f6f14', '#353509', '#b9b93a', '#f2f2d8'],
},
}
const vision = typeof document === 'undefined' ? undefined : document.documentElement.dataset.vision
@ -133,9 +153,9 @@ export const BRAND = 'var(--color-action)'
export const ACCENTS = {
teal: BRAND,
deep: '#003a45',
deep: visionColor('#003a45'),
green: visionColor('#4a7431'),
amber: '#8f5b00',
amber: visionColor('#8f5b00'),
}
/* A palette fill for something colored by its name, like the