diff --git a/index.html b/index.html index 6c16a39..c84d3d0 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,8 @@ + flash: this browser's choice (ThemeToggle), else the system; + and the accessibility choices, for the same reason. --> diff --git a/package.json b/package.json index 14690f3..86e7e99 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "@fontsource/montserrat": "^5.3.0", + "@fontsource/opendyslexic": "^5.3.0", "@fontsource/poppins": "^5.3.0", "@phosphor-icons/react": "^2.1.10", "qrcode": "^1.5.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2266481..f25676d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@fontsource/montserrat': specifier: ^5.3.0 version: 5.3.0 + '@fontsource/opendyslexic': + specifier: ^5.3.0 + version: 5.3.0 '@fontsource/poppins': specifier: ^5.3.0 version: 5.3.0 @@ -66,6 +69,9 @@ packages: '@fontsource/montserrat@5.3.0': resolution: {integrity: sha512-iQPDtZOnmM5ih4JBGaMSXisRap0ixb9bAUw2hDtY7EjVfaqiiNlKtVuJl9XclxUwtwMMHNcWXfQR6zI9x05+Tg==} + '@fontsource/opendyslexic@5.3.0': + resolution: {integrity: sha512-BVYIW/ghc1U2iAghhYTN+GFWiZ3lnCy8Jf2KkZC23aHQHBNcMqKT718zckfqVxRx4qsXJmIMPWvczirRuhmtsg==} + '@fontsource/poppins@5.3.0': resolution: {integrity: sha512-cms1nM7U6SN8epIV1WMVOV8VsA645aSm3wHfzIQnkk188U341ThbJGSl2Sv54V29gnDbT2arMPfLzvVIIVCceQ==} @@ -786,6 +792,8 @@ snapshots: '@fontsource/montserrat@5.3.0': {} + '@fontsource/opendyslexic@5.3.0': {} + '@fontsource/poppins@5.3.0': {} '@jridgewell/gen-mapping@0.3.13': diff --git a/src/App.tsx b/src/App.tsx index fc432c7..43ae74f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -80,6 +80,7 @@ const AdminHome = lazyPage(() => import("./pages/admin/AdminHome.tsx")) const AdminFeedback = lazyPage(() => import("./pages/admin/AdminFeedback.tsx")) const AdminMedia = lazyPage(() => import("./pages/admin/AdminMedia.tsx")) const AdminClips = lazyPage(() => import("./pages/admin/AdminClips.tsx")) +const AdminNewsletter = lazyPage(() => import("./pages/admin/AdminNewsletter.tsx")) const EntityList = lazyPage(() => import("./pages/admin/EntityList.tsx")) const EntityEdit = lazyPage(() => import("./pages/admin/EntityEdit.tsx")) @@ -133,6 +134,7 @@ export default function App() { } /> } /> } /> + } /> }> } /> diff --git a/src/components/AccessibilityPanel.tsx b/src/components/AccessibilityPanel.tsx new file mode 100644 index 0000000..faf5ecc --- /dev/null +++ b/src/components/AccessibilityPanel.tsx @@ -0,0 +1,168 @@ +/* ═══════════════════════════════════════════════════════════════ + ACCESSIBILITY PANEL + + A button fixed to the bottom right of every public page, opening + two switches that change how the whole site reads: + + Dyslexia-friendly font every typeface becomes OpenDyslexic + (self-hosted, index.css) + Reading mode the design steps back: no background + circles, motion or shadows, one column, + larger text and plain underlined links, + the same content throughout + + Each is a data attribute on (data-font, data-reading) that + index.css styles, saved in this browser (site-font, site-reading) + and set again before the first paint by index.html, so a page + never flashes the other look. Blocked storage just means the + choice lasts until the tab closes. + + The panel closes on Escape, on the button again, or a click + anywhere else, and gives focus back to the button. + ═══════════════════════════════════════════════════════════════ */ + +import { PersonArmsSpread, X } from '@phosphor-icons/react' +import { useEffect, useId, useRef, useState } from 'react' + +/* A setting: its attribute, storage key, the value that turns + it on, and its words. */ +const SETTINGS = [ + { + attribute: 'font', + key: 'site-font', + on: 'dyslexic', + label: 'Dyslexia-friendly font', + help: 'Letters shaped to be easier to tell apart.', + }, + { + attribute: 'reading', + key: 'site-reading', + on: 'on', + label: 'Reading mode', + help: 'A plain, single column with larger text and no motion.', + }, +] as const + +type Setting = (typeof SETTINGS)[number] + +const isOn = (setting: Setting) => document.documentElement.dataset[setting.attribute] === setting.on + +function apply(setting: Setting, on: boolean) { + const root = document.documentElement + if (on) root.dataset[setting.attribute] = setting.on + else delete root.dataset[setting.attribute] + try { + if (on) localStorage.setItem(setting.key, setting.on) + else localStorage.removeItem(setting.key) + } catch { + // Storage blocked: the choice holds for this page view. + } +} + +export default function AccessibilityPanel() { + const [open, setOpen] = useState(false) + const [state, setState] = useState(() => Object.fromEntries(SETTINGS.map((s) => [s.key, isOn(s)]))) + const rootRef = useRef(null) + const buttonRef = useRef(null) + const panelId = useId() + + useEffect(() => { + if (!open) return undefined + const close = () => { + setOpen(false) + buttonRef.current?.focus() + } + const onKey = (event: KeyboardEvent) => { + if (event.key === 'Escape') close() + } + const onPointer = (event: PointerEvent) => { + if (!rootRef.current?.contains(event.target as Node)) setOpen(false) + } + document.addEventListener('keydown', onKey) + document.addEventListener('pointerdown', onPointer) + return () => { + document.removeEventListener('keydown', onKey) + document.removeEventListener('pointerdown', onPointer) + } + }, [open]) + + const toggle = (setting: Setting) => { + const next = !state[setting.key] + apply(setting, next) + setState((current) => ({ ...current, [setting.key]: next })) + } + + return ( +
+ {open && ( +
+
+

Accessibility

+ +
+ +
    + {SETTINGS.map((setting) => { + const on = state[setting.key] + const labelId = `${panelId}-${setting.attribute}` + return ( +
  • + + + + {setting.label} + + {setting.help} + +
  • + ) + })} +
+
+ )} + + +
+ ) +} diff --git a/src/components/ArrowLink.tsx b/src/components/ArrowLink.tsx index 20f5fb9..0b8869f 100644 --- a/src/components/ArrowLink.tsx +++ b/src/components/ArrowLink.tsx @@ -5,7 +5,7 @@ import { Link } from "react-router-dom"; ARROW LINK ═══════════════════════════════════════════════════════════════ */ -export default function ArrowLink({ to, label, color, size = "h-9 w-9" }) { +export default function ArrowLink({ to, label, color, size = "h-10 w-10" }) { return ( -

+

{SITE_BANNER.content.map((part, i) => { if (!part.href) return {part.text}; return part.external ? ( @@ -53,7 +53,7 @@ export default function Banner() { diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index a1cc27e..a2e48f9 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -34,11 +34,12 @@ const Footer_Links = [ const footerLinkClass = "text-white/65 hover:text-[#9cc47c] text-sm transition-colors"; +// inline-block with a little height of its own, so a finger can hit it. const pageLinkClass = - "text-white/80 hover:text-[#9cc47c] text-sm font-semibold transition-colors"; + "inline-block py-1 text-white/80 hover:text-[#9cc47c] text-sm font-semibold transition-colors"; const sectionLinkClass = - "text-white/65 hover:text-[#9cc47c] text-sm transition-colors"; + "inline-block py-1 text-white/65 hover:text-[#9cc47c] text-sm transition-colors"; const headingClass = "text-white/90 text-sm font-semibold mb-4"; @@ -92,7 +93,7 @@ export default function Footer() { {sections.length > 0 && ( -

    +
      {sections.map((section) => (