From de17da7dc8ec38e1db0b9eab9a40a587aa9e7f74 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Sat, 3 Oct 2026 16:10:57 -0500 Subject: [PATCH] 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--) so the modes reach them. - CLAUDE.md and docs/updating-data-in-code.md describe both. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- docs/updating-data-in-code.md | 2 +- src/components/AccessibilityPanel.tsx | 38 +---- src/components/Banner.tsx | 2 +- src/components/Footer.tsx | 6 +- src/components/Layout.tsx | 67 +++++--- src/components/PageBackdrop.css | 24 +-- src/components/PageShell.css | 18 +-- src/components/PrivacyNotice.tsx | 2 +- src/components/ReaderView.tsx | 217 ++++++++++++++++++++++++++ src/components/VideoPlayer.tsx | 2 +- src/components/admin/SectionNav.tsx | 7 +- src/index.css | 202 ++++++++++++++---------- src/lib/color.ts | 54 +++++-- src/lib/readingMode.ts | 15 ++ src/lib/version.ts | 2 +- src/pages/Privacy.tsx | 21 ++- src/pages/sections/home/HeroStage.tsx | 14 +- src/pages/sections/home/StatsBand.tsx | 4 +- 19 files changed, 507 insertions(+), 192 deletions(-) create mode 100644 src/components/ReaderView.tsx create mode 100644 src/lib/readingMode.ts diff --git a/CLAUDE.md b/CLAUDE.md index d462ebd..f4630a0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -71,7 +71,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu - **Imports need explicit extensions** (`.ts`, `.tsx`, `.js`) everywhere. - **Vite resolves `.js` before `.ts`**, so a `.js` and `.ts` file with the same base name will import the wrong one. Give new hooks distinct names. - **Don't use `fallback: EMPTY` in api.ts hooks.** It silently returns empty arrays and hides server errors; let the error state surface. -- **Colors are tokens, not hex.** Admins can override any token (Panel → Site settings → Colors). The defaults are `server/src/themeDefaults.js` plus the same values as CSS in `src/index.css`; the build fails if they differ (`themeDefaultsCheck` in `vite.config.ts`), and migration 041's CHECK lists the token names. Use the utilities from `src/index.css` (`text-ink`, `text-body`, `text-muted`, `text-link`, `bg-surface`, `bg-tint`, `bg-action`, `border-brand/20`...) so dark mode works; a literal only for something that must look the same in both modes (white on a dark band, a platform's color). Data colors (accents, event and region colors) go through `withAlpha`, `accentText` and `readableOn` in `src/lib/color.ts`, never `${color}55`. +- **Colors are tokens, not hex.** Admins can override any token (Panel → Site settings → Colors). The defaults are `server/src/themeDefaults.js` plus the same values as CSS in `src/index.css`; the build fails if they differ (`themeDefaultsCheck` in `vite.config.ts`), and migration 041's CHECK lists the token names. Use the utilities from `src/index.css` (`text-ink`, `text-body`, `text-muted`, `text-link`, `bg-surface`, `bg-tint`, `bg-action`, `border-brand/20`...) so dark mode works; a literal only for something that must look the same in both modes (white on a dark band, a platform's color). Data colors (accents, event and region colors) go through `withAlpha`, `accentText` and `readableOn` in `src/lib/color.ts`, never `${color}55`. A palette color in a component or CSS file is `var(--pal--)`, not its hex, so the color blind modes reach it. - **Icons are Phosphor** (`@phosphor-icons/react`), weight `bold` (or `fill` for play/star). No hand-drawn `` icons and no Unicode glyphs as icons (× › ▶ →). Brand marks are the exception: `DoveMark`, `PlatformIcon`, the Google logo, the group map. - **Accents come from `src/lib/color.ts`:** `BRAND` (the teal, via the button token so the admin palette reaches it) and `ACCENTS` (deep, green, olive), all from `PALETTE` (the site's 16-color grid). Not a new hex in a page. - **Corners: square.** Everything is square except buttons, which use the `btn` utility (Poppins Bold, a small `var(--btn-radius)` corner, also for plain CSS), video players (small rounded) and things round by nature (dots, radio marks, the play button). A note in place of content (empty section, "coming soon") uses the `notice` utility (corner brackets), not a dashed border. Cards sit on `bg-raised` with a shadow so they stand off the page. Nothing glows: no blur blobs, no glow shadows. diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index a186be5..2bbeb97 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -279,7 +279,7 @@ The numbers band's "Number Source" dropdown works the same way: | The icons a Front page "Find your way in" path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. | | A page section's accent color | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a color there, not a hex in a page. Each is readable as text on white and the tints. | | The palette (the 16-color grid the theme is drawn from) | `PALETTE` in `src/lib/color.ts` | Four families, a column each. `PALETTE_LIGHT` / `PALETTE_DARK` are the fills things colored by data use (a person's initials tile, `paletteFill`); the page background's layers (how many circles, their sizes and parallax speeds) are `LAYERS` in `src/components/PageBackdrop.tsx` and its shades are in `PageBackdrop.css`; the admin home's two alternating group colors are `BLOCK_COLORS` in `src/pages/admin/AdminHome.tsx`. | -| The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `` styled in `src/index.css`, and `index.html` sets it again before the first paint, so a new one goes in all three. A color blind mode swaps palette families (`SWAPS`, picked by simulating each type: see the comment there) in code, in data colors as they load (`src/lib/api.ts`, never under /admin) and in CSS (the `--green-*` variables in `src/index.css`); a hex from the green family in a component should be one of those variables. Something saved or sent (the newsletter's colors) uses `STORED_PALETTE`, which is never swapped. | +| The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `` styled in `src/index.css`, and `index.html` sets it again before the first paint, so a new one goes in all three. A color blind mode replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal--)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. Something saved or sent (the newsletter's colors) uses `STORED_PALETTE`, which is never swapped. | | Privacy Policy and Terms wording | `src/pages/Privacy.tsx`, `src/pages/Terms.tsx` | The `PARTS` list, and `LAST_UPDATED` whenever the wording changes. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. | | Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. | | Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | | diff --git a/src/components/AccessibilityPanel.tsx b/src/components/AccessibilityPanel.tsx index 9f25f16..38fd39b 100644 --- a/src/components/AccessibilityPanel.tsx +++ b/src/components/AccessibilityPanel.tsx @@ -6,10 +6,10 @@ Dyslexia-friendly font every typeface becomes OpenDyslexic (self-hosted, index.css) - Reading mode the page as plain text: one column of - ink on white, no colors, pictures, - cards or motion; a picture's - description stays in its place + Reading mode the page as text: its headings, + paragraphs, links and described + pictures in one column, nothing else + (ReaderView.tsx) Color blind mode the palette swapped so its colors stay apart for that type of color blindness, or grays (color.ts, VISIONS) @@ -53,7 +53,7 @@ const SETTINGS = [ key: 'site-reading', on: 'on', label: 'Reading mode', - help: 'The page as plain text: one column, larger type, no colors, pictures or motion.', + help: 'The page as text: headings, paragraphs, links and pictures in one column, nothing else.', }, ] as const @@ -87,30 +87,6 @@ function apply(attribute: string, key: string, value: string | null) { } } -/* Reading mode hides pictures, video and maps; their descriptions - (alt, title, aria-label) go on the parent as data-reading-alt, - which index.css shows in their place. An attribute rather than a - new element, so React's own nodes are left alone. */ -const DESCRIBED = 'main img[alt]:not([alt=""]), main iframe[title], main video[aria-label]' - -function describeMedia() { - for (const el of document.querySelectorAll(DESCRIBED)) { - const words = el.getAttribute('alt') ?? el.getAttribute('title') ?? el.getAttribute('aria-label') - const kind = el.tagName === 'IMG' ? 'Image' : 'Video' - el.parentElement?.setAttribute('data-reading-alt', `${kind}: ${words}`) - } -} - -function useMediaDescriptions(on: boolean) { - useEffect(() => { - if (!on) return undefined - describeMedia() - const observer = new MutationObserver(describeMedia) - observer.observe(document.body, { childList: true, subtree: true }) - return () => observer.disconnect() - }, [on]) -} - export default function AccessibilityPanel() { const [open, setOpen] = useState(false) const [state, setState] = useState(() => Object.fromEntries(SETTINGS.map((s) => [s.key, isOn(s)]))) @@ -120,8 +96,6 @@ export default function AccessibilityPanel() { const firstRef = useRef(null) const panelId = useId() - useMediaDescriptions(state['site-reading']) - useEffect(() => { const root = document.documentElement for (const { attribute, key } of PUBLIC_ONLY) { @@ -187,7 +161,7 @@ export default function AccessibilityPanel() { id={panelId} role="region" aria-label="Accessibility" - className="reading-solid absolute right-0 bottom-full mb-3 w-[min(20rem,calc(100vw-2rem))] border border-brand/20 bg-raised p-4 shadow-xl" + className="absolute right-0 bottom-full mb-3 w-[min(20rem,calc(100vw-2rem))] border border-brand/20 bg-raised p-4 shadow-xl" >

Accessibility

diff --git a/src/components/Banner.tsx b/src/components/Banner.tsx index a8fb404..e03d1c6 100644 --- a/src/components/Banner.tsx +++ b/src/components/Banner.tsx @@ -25,7 +25,7 @@ export default function Banner() { if (!visible) return null; const linkClass = - "underline underline-offset-4 decoration-[var(--green-2)] hover:text-white transition-colors"; + "underline underline-offset-4 decoration-[var(--pal-green-2)] hover:text-white transition-colors"; return (
(null); const location = useLocation(); const lastPath = useRef(location.pathname); + const reading = useReadingMode(); + // The page itself, drawn hidden for the reader view to read. + const pageRef = useRef(null); const sectionsOf = useNavSections(); @@ -124,19 +129,20 @@ export default function Layout() { ); ro.observe(el); return () => ro.disconnect(); - }, []); + }, [reading]); // On the root, so anything can read it: index.css keeps focused // and jumped-to things clear of the header with it // (scroll-padding-top), and PostContents offsets by it. useEffect(() => { const root = document.documentElement; - root.style.setProperty("--header-h", `${headerHeight}px`); + // Reading mode has no header to stay clear of. + root.style.setProperty("--header-h", `${reading ? 0 : headerHeight}px`); // The admin has no fixed header: nothing to stay clear of there. return () => { root.style.removeProperty("--header-h"); }; - }, [headerHeight]); + }, [headerHeight, reading]); // Router does not scroll on navigation. Go to top on a new page, // or to the anchor if the URL carries one (handles deep links too). @@ -151,17 +157,42 @@ export default function Layout() { if (newPage) document.getElementById("main")?.focus({ preventScroll: true }); }, [location.pathname, location.hash, location.key]); + const skipLink = ( + + Skip to content + + ); + + // Reading mode: the page as plain text (ReaderView.tsx), with no + // header, backdrop, footer or notices; the panel stays, to turn it + // off. The page itself still renders, hidden, for the reader to + // read, so every page works without a version of its own. + if (reading) { + return ( +
+ {skipLink} +
+ + +
+ +
+ ); + } + return ( // overflow-x-clip, not -hidden: hidden makes this div a scroll // container, and then nothing inside it can be position: sticky // (a blog post's contents column scrolled away with the page).
- - Skip to content - + {skipLink} {/* ── NAV ─────────────────────────────────────────────── */}
@@ -212,7 +243,7 @@ export default function Layout() { className={({ isActive }) => `block text-base font-bold pb-1 border-b-2 transition-colors duration-200 ${ isActive - ? "text-white border-[var(--green-2)]" + ? "text-white border-[var(--pal-green-2)]" : "text-white/75 hover:text-white border-transparent" }` } @@ -233,13 +264,13 @@ export default function Layout() { >