Accessibility: reading and color blind modes, audit fixes, calendar window
- Accessibility panel: the switch knob stays in its track; the panel follows its button in the Tab order and opens on its first switch. - Reading mode is the page as plain text: one column, no colors, pictures, cards or motion; descriptions stay in place. - Color blind mode (protanopia, deuteranopia, tritanopia, monochrome): palette swaps chosen by simulation, applied to code, data and CSS colors on public pages only. The newsletter uses the stored palette. - Audit fixes: focus not hidden by the header, focus on page change and in-page jumps, focus return for the menu, day list and people details, labelled admin fields and dialogs, keyboard map tiles, scrollable tables, and more. - Calendar asks /events for its six weeks only (?from=&to=); carousels take their 12 most recent past events (?past=12). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d067c02d33
commit
b816203c0c
45 changed files with 760 additions and 208 deletions
|
|
@ -2,28 +2,42 @@
|
|||
ACCESSIBILITY PANEL
|
||||
|
||||
A button fixed to the bottom right of every public page, opening
|
||||
two switches that change how the whole site reads:
|
||||
two switches and a choice 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
|
||||
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
|
||||
Color blind mode the palette swapped so its colors stay
|
||||
apart for that type of color blindness,
|
||||
or grays (color.ts, VISIONS)
|
||||
|
||||
Each is a data attribute on <html> (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.
|
||||
Each is a data attribute on <html> (data-font, data-reading,
|
||||
data-vision) that index.css styles, saved in this browser
|
||||
(site-font, site-reading, site-vision) and set again before the
|
||||
first paint by index.html, so a page never flashes the other
|
||||
look. A color blind mode reloads the page, since colors set from
|
||||
code and data are swapped as they load. Blocked storage just
|
||||
means the choice lasts until the tab closes.
|
||||
|
||||
The panel closes on Escape, on the button again, or a click
|
||||
Reading and color blind modes belong to the public pages, which
|
||||
are the only ones with this panel: it sets them when they mount
|
||||
and clears them when the admin takes over (index.html leaves them
|
||||
off there too), since the admin edits the colors and layout they
|
||||
would hide. The font follows the visitor everywhere.
|
||||
|
||||
The panel opens on its first switch, comes after its button in
|
||||
the Tab order, 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'
|
||||
|
||||
import { VISIONS } from '../lib/color.ts'
|
||||
|
||||
/* A setting: its <html> attribute, storage key, the value that turns
|
||||
it on, and its words. */
|
||||
const SETTINGS = [
|
||||
|
|
@ -39,35 +53,89 @@ const SETTINGS = [
|
|||
key: 'site-reading',
|
||||
on: 'on',
|
||||
label: 'Reading mode',
|
||||
help: 'A plain, single column with larger text and no motion.',
|
||||
help: 'The page as plain text: one column, larger type, no colors, pictures or 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]
|
||||
/* The saved choice, or the page's own where storage is blocked. */
|
||||
function saved(attribute: string, key: string): string | null {
|
||||
try {
|
||||
if (on) localStorage.setItem(setting.key, setting.on)
|
||||
else localStorage.removeItem(setting.key)
|
||||
return localStorage.getItem(key)
|
||||
} catch {
|
||||
return document.documentElement.dataset[attribute] ?? null
|
||||
}
|
||||
}
|
||||
|
||||
const isOn = (setting: Setting) => saved(setting.attribute, setting.key) === setting.on
|
||||
const PUBLIC_ONLY = [
|
||||
{ attribute: 'reading', key: 'site-reading' },
|
||||
{ attribute: 'vision', key: 'site-vision' },
|
||||
]
|
||||
|
||||
/* Sets (or, given null, clears) an <html> attribute and its saved copy. */
|
||||
function apply(attribute: string, key: string, value: string | null) {
|
||||
const root = document.documentElement
|
||||
if (value) root.dataset[attribute] = value
|
||||
else delete root.dataset[attribute]
|
||||
try {
|
||||
if (value) localStorage.setItem(key, value)
|
||||
else localStorage.removeItem(key)
|
||||
} catch {
|
||||
// Storage blocked: the choice holds for this page view.
|
||||
}
|
||||
}
|
||||
|
||||
/* 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)])))
|
||||
const [vision, setVision] = useState(() => saved('vision', 'site-vision') ?? '')
|
||||
const rootRef = useRef<HTMLDivElement>(null)
|
||||
const buttonRef = useRef<HTMLButtonElement>(null)
|
||||
const firstRef = useRef<HTMLButtonElement>(null)
|
||||
const panelId = useId()
|
||||
|
||||
useMediaDescriptions(state['site-reading'])
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement
|
||||
for (const { attribute, key } of PUBLIC_ONLY) {
|
||||
const value = saved(attribute, key)
|
||||
if (value) root.dataset[attribute] = value
|
||||
}
|
||||
return () => {
|
||||
for (const { attribute } of PUBLIC_ONLY) delete root.dataset[attribute]
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return undefined
|
||||
firstRef.current?.focus()
|
||||
const close = () => {
|
||||
setOpen(false)
|
||||
buttonRef.current?.focus()
|
||||
|
|
@ -88,18 +156,38 @@ export default function AccessibilityPanel() {
|
|||
|
||||
const toggle = (setting: Setting) => {
|
||||
const next = !state[setting.key]
|
||||
apply(setting, next)
|
||||
apply(setting.attribute, setting.key, next ? setting.on : null)
|
||||
setState((current) => ({ ...current, [setting.key]: next }))
|
||||
}
|
||||
|
||||
const chooseVision = (value: string) => {
|
||||
setVision(value)
|
||||
apply('vision', 'site-vision', value || null)
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={rootRef} className="fixed right-4 bottom-4 z-50 print:hidden">
|
||||
<button
|
||||
ref={buttonRef}
|
||||
type="button"
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
aria-expanded={open}
|
||||
aria-controls={open ? panelId : undefined}
|
||||
aria-label="Accessibility options"
|
||||
className="btn flex h-12 w-12 items-center justify-center bg-action text-white shadow-lg transition-colors hover:bg-action-hover"
|
||||
>
|
||||
<PersonArmsSpread size={26} weight="bold" aria-hidden="true" />
|
||||
</button>
|
||||
|
||||
{/* After the button in the page, so Tab goes from it into the
|
||||
panel; drawn above it. */}
|
||||
{open && (
|
||||
<div
|
||||
id={panelId}
|
||||
role="region"
|
||||
aria-label="Accessibility"
|
||||
className="absolute right-0 bottom-full mb-3 w-[min(20rem,calc(100vw-2rem))] border border-brand/20 bg-raised p-4 shadow-xl"
|
||||
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"
|
||||
>
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<h2 className="font-display text-base font-bold text-ink">Accessibility</h2>
|
||||
|
|
@ -117,25 +205,31 @@ export default function AccessibilityPanel() {
|
|||
</div>
|
||||
|
||||
<ul className="mt-3 space-y-3">
|
||||
{SETTINGS.map((setting) => {
|
||||
{SETTINGS.map((setting, i) => {
|
||||
const on = state[setting.key]
|
||||
const labelId = `${panelId}-${setting.attribute}`
|
||||
const helpId = `${labelId}-help`
|
||||
return (
|
||||
<li key={setting.key} className="flex items-start gap-3">
|
||||
<button
|
||||
ref={i === 0 ? firstRef : undefined}
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={on}
|
||||
aria-labelledby={labelId}
|
||||
aria-describedby={helpId}
|
||||
onClick={() => toggle(setting)}
|
||||
className={`relative mt-0.5 h-6 w-11 shrink-0 rounded-full border-2 transition-colors ${
|
||||
on ? 'border-action bg-action' : 'border-muted/50 bg-surface'
|
||||
}`}
|
||||
>
|
||||
{/* Pinned to the left edge: without it the knob
|
||||
starts from the button's centered content and
|
||||
slides out of the track when switched on. */}
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`absolute top-0.5 h-4 w-4 rounded-full transition-transform ${
|
||||
on ? 'translate-x-5 bg-white' : 'translate-x-0.5 bg-muted'
|
||||
className={`absolute top-0.5 left-0.5 h-4 w-4 rounded-full transition-transform ${
|
||||
on ? 'translate-x-5 bg-white' : 'translate-x-0 bg-muted'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
|
|
@ -143,26 +237,35 @@ export default function AccessibilityPanel() {
|
|||
<span id={labelId} className="block font-semibold text-ink">
|
||||
{setting.label}
|
||||
</span>
|
||||
<span className="block text-sm text-muted">{setting.help}</span>
|
||||
<span id={helpId} className="block text-sm text-muted">
|
||||
{setting.help}
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
|
||||
<label className="mt-4 block">
|
||||
<span className="block font-semibold text-ink">Color blind mode</span>
|
||||
<span className="block text-sm text-muted">
|
||||
Colors chosen to stay apart for your type. Reloads the page.
|
||||
</span>
|
||||
<select
|
||||
value={vision}
|
||||
onChange={(event) => chooseVision(event.target.value)}
|
||||
className="mt-2 w-full border border-muted/50 bg-surface px-3 py-2 text-sm text-ink"
|
||||
>
|
||||
<option value="">Off</option>
|
||||
{VISIONS.map((option) => (
|
||||
<option key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<button
|
||||
ref={buttonRef}
|
||||
type="button"
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
aria-expanded={open}
|
||||
aria-controls={open ? panelId : undefined}
|
||||
aria-label="Accessibility options"
|
||||
className="btn flex h-12 w-12 items-center justify-center bg-action text-white shadow-lg transition-colors hover:bg-action-hover"
|
||||
>
|
||||
<PersonArmsSpread size={26} weight="bold" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export default function Banner() {
|
|||
if (!visible) return null;
|
||||
|
||||
const linkClass =
|
||||
"underline underline-offset-4 decoration-[#9cc47c] hover:text-white transition-colors";
|
||||
"underline underline-offset-4 decoration-[var(--green-2)] hover:text-white transition-colors";
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -135,23 +135,20 @@ function Caption({ text }: { text?: string | null }) {
|
|||
)
|
||||
}
|
||||
|
||||
// Clear of the fixed header when jumped to.
|
||||
const ANCHOR_MARGIN = { scrollMarginTop: 'calc(var(--header-h, 5rem) + 1rem)' }
|
||||
|
||||
function Block({ block, accent, anchor }: { block: ContentBlock; accent: string; anchor?: string }) {
|
||||
const text = block.text ?? ''
|
||||
|
||||
switch (block.type) {
|
||||
case 'heading':
|
||||
return (
|
||||
<h3 id={anchor} className="text-2xl font-bold" style={{ color: accentText(accent), ...ANCHOR_MARGIN }}>
|
||||
<h3 id={anchor} className="text-2xl font-bold" style={{ color: accentText(accent) }}>
|
||||
{text}
|
||||
</h3>
|
||||
)
|
||||
|
||||
case 'subheading':
|
||||
return (
|
||||
<h4 id={anchor} className="text-lg font-normal" style={{ color: accentText(accent), ...ANCHOR_MARGIN }}>
|
||||
<h4 id={anchor} className="text-lg font-normal" style={{ color: accentText(accent) }}>
|
||||
{text}
|
||||
</h4>
|
||||
)
|
||||
|
|
@ -248,8 +245,9 @@ function Block({ block, accent, anchor }: { block: ContentBlock; accent: string;
|
|||
const width = Math.max(...rows.map((row) => row.length))
|
||||
return (
|
||||
// Wide tables scroll sideways inside their box on a phone
|
||||
// rather than squeezing every column to a word.
|
||||
<div className="overflow-x-auto border border-brand/15">
|
||||
// rather than squeezing every column to a word. Focusable, so
|
||||
// the arrow keys scroll it too (Safari won't on its own).
|
||||
<div tabIndex={0} role="region" aria-label="Table" className="overflow-x-auto border border-brand/15">
|
||||
<table className="min-w-full text-left text-sm leading-snug">
|
||||
<thead className="bg-tint">
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ const Footer_Links = [
|
|||
];
|
||||
|
||||
const footerLinkClass =
|
||||
"text-white/65 hover:text-[#9cc47c] text-sm transition-colors";
|
||||
"text-white/65 hover:text-[var(--green-2)] text-sm transition-colors";
|
||||
|
||||
// inline-block with a little height of its own, so a finger can hit it.
|
||||
const pageLinkClass =
|
||||
"inline-block py-1 text-white/80 hover:text-[#9cc47c] text-sm font-semibold transition-colors";
|
||||
"inline-block py-1 text-white/80 hover:text-[var(--green-2)] text-sm font-semibold transition-colors";
|
||||
|
||||
const sectionLinkClass =
|
||||
"inline-block py-1 text-white/65 hover:text-[#9cc47c] text-sm transition-colors";
|
||||
"inline-block py-1 text-white/65 hover:text-[var(--green-2)] text-sm transition-colors";
|
||||
|
||||
const headingClass = "text-white/90 text-sm font-semibold mb-4";
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import PrivacyNotice from "./PrivacyNotice.tsx";
|
|||
import PageBackdrop from "./PageBackdrop.tsx";
|
||||
import AccessibilityPanel from "./AccessibilityPanel.tsx";
|
||||
import ThemeToggle from "./ThemeToggle.tsx";
|
||||
import { scrollBehavior } from "../lib/motion.ts";
|
||||
import { jumpTo } from "../lib/focus.ts";
|
||||
|
||||
/* ── Right-side nav actions ──────────────────────────────── */
|
||||
|
||||
|
|
@ -82,7 +82,12 @@ export default function Layout() {
|
|||
const [headerHeight, setHeaderHeight] = useState(72);
|
||||
const headerRef = useRef<HTMLElement>(null);
|
||||
const closeMenuRef = useRef<HTMLButtonElement>(null);
|
||||
const openMenuRef = useRef<HTMLButtonElement>(null);
|
||||
// The desktop dropdown Escape has shut, until the pointer or focus
|
||||
// leaves it (hover and focus would otherwise hold it open).
|
||||
const [dismissed, setDismissed] = useState<string | null>(null);
|
||||
const location = useLocation();
|
||||
const lastPath = useRef(location.pathname);
|
||||
|
||||
const sectionsOf = useNavSections();
|
||||
|
||||
|
|
@ -98,7 +103,13 @@ export default function Layout() {
|
|||
closeMenuRef.current?.focus();
|
||||
const onKey = (e: KeyboardEvent) => e.key === "Escape" && setMobileMenuOpen(false);
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onKey);
|
||||
// Closed with Escape or Close, focus fell to the page with the
|
||||
// menu: give it back to the menu button. A link that changed
|
||||
// the page has already sent it to the new page (below).
|
||||
if (document.activeElement === document.body) openMenuRef.current?.focus();
|
||||
};
|
||||
}, [mobileMenuOpen]);
|
||||
|
||||
// The header grows and shrinks: the banner can be dismissed, and
|
||||
|
|
@ -115,27 +126,36 @@ export default function Layout() {
|
|||
return () => ro.disconnect();
|
||||
}, []);
|
||||
|
||||
// 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`);
|
||||
// The admin has no fixed header: nothing to stay clear of there.
|
||||
return () => {
|
||||
root.style.removeProperty("--header-h");
|
||||
};
|
||||
}, [headerHeight]);
|
||||
|
||||
// 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).
|
||||
// A new page also takes focus to its content, as a page load would,
|
||||
// so a screen reader starts there and Tab doesn't begin from a
|
||||
// link that may be gone.
|
||||
useEffect(() => {
|
||||
if (location.hash) {
|
||||
const el = document.querySelector(location.hash);
|
||||
if (el) {
|
||||
el.scrollIntoView({ behavior: scrollBehavior() });
|
||||
return;
|
||||
}
|
||||
}
|
||||
const newPage = lastPath.current !== location.pathname;
|
||||
lastPath.current = location.pathname;
|
||||
if (location.hash && jumpTo(decodeURIComponent(location.hash.slice(1)))) return;
|
||||
window.scrollTo({ top: 0 });
|
||||
if (newPage) document.getElementById("main")?.focus({ preventScroll: true });
|
||||
}, [location.pathname, location.hash, location.key]);
|
||||
|
||||
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).
|
||||
<div
|
||||
className="min-h-screen overflow-x-clip"
|
||||
style={{ "--header-h": `${headerHeight}px` } as React.CSSProperties}
|
||||
>
|
||||
<div className="min-h-screen overflow-x-clip">
|
||||
<a
|
||||
href="#main"
|
||||
className="sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[70] focus:bg-surface focus:px-4 focus:py-2 focus:font-semibold focus:text-ink"
|
||||
|
|
@ -173,14 +193,26 @@ export default function Layout() {
|
|||
{PAGE_LINKS.map((page) => {
|
||||
const pageSections = page.path === "/" ? [] : sectionsOf(page.path);
|
||||
return (
|
||||
<div key={page.path} className="group relative">
|
||||
<div
|
||||
key={page.path}
|
||||
className="group relative"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== "Escape" || pageSections.length === 0) return;
|
||||
setDismissed(page.path);
|
||||
e.currentTarget.querySelector("a")?.focus();
|
||||
}}
|
||||
onMouseLeave={() => setDismissed(null)}
|
||||
onBlur={(e) => {
|
||||
if (!e.currentTarget.contains(e.relatedTarget as Node)) setDismissed(null);
|
||||
}}
|
||||
>
|
||||
<NavLink
|
||||
to={page.path}
|
||||
end={page.path === "/"}
|
||||
className={({ isActive }) =>
|
||||
`block text-base font-bold pb-1 border-b-2 transition-colors duration-200 ${
|
||||
isActive
|
||||
? "text-white border-[#9cc47c]"
|
||||
? "text-white border-[var(--green-2)]"
|
||||
: "text-white/75 hover:text-white border-transparent"
|
||||
}`
|
||||
}
|
||||
|
|
@ -194,10 +226,14 @@ export default function Layout() {
|
|||
// (:focus-visible): a click leaves focus on the
|
||||
// link, which held the menu open after the
|
||||
// pointer had gone.
|
||||
<div className="invisible absolute top-full left-0 z-10 pt-3 opacity-0 transition-opacity duration-150 group-hover:visible group-hover:opacity-100 group-has-[:focus-visible]:visible group-has-[:focus-visible]:opacity-100">
|
||||
<div
|
||||
className={`invisible absolute top-full left-0 z-10 pt-3 opacity-0 transition-opacity duration-150 group-hover:visible group-hover:opacity-100 group-has-[:focus-visible]:visible group-has-[:focus-visible]:opacity-100 ${
|
||||
dismissed === page.path ? "!invisible !opacity-0" : ""
|
||||
}`}
|
||||
>
|
||||
<ul
|
||||
className="min-w-56 py-2 shadow-xl"
|
||||
style={{ background: "rgba(0, 16, 17, 0.97)", borderTop: "2px solid #9cc47c" }}
|
||||
style={{ background: "rgba(0, 16, 17, 0.97)", borderTop: "2px solid var(--green-2)" }}
|
||||
>
|
||||
{pageSections.map((section) => (
|
||||
<li key={section.hash}>
|
||||
|
|
@ -228,6 +264,7 @@ export default function Layout() {
|
|||
<ThemeToggle className="text-white/80 hover:bg-white/10 hover:text-white" />
|
||||
|
||||
<button
|
||||
ref={openMenuRef}
|
||||
className="lg:hidden text-white p-2"
|
||||
aria-label="Open menu"
|
||||
aria-expanded={mobileMenuOpen}
|
||||
|
|
@ -262,7 +299,7 @@ export default function Layout() {
|
|||
{/* Mobile menu */}
|
||||
{mobileMenuOpen && (
|
||||
<div
|
||||
className="fixed inset-0 z-[60] flex flex-col items-center [justify-content:safe_center] overflow-y-auto py-16"
|
||||
className="reading-solid fixed inset-0 z-[60] flex flex-col items-center [justify-content:safe_center] overflow-y-auto py-16"
|
||||
style={{ background: "rgba(0, 58, 69, 0.97)" }}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
|
|
@ -289,7 +326,7 @@ export default function Layout() {
|
|||
end={page.path === "/"}
|
||||
className={({ isActive }) =>
|
||||
`block text-2xl font-bold py-3 transition-colors ${
|
||||
isActive ? "text-[#9cc47c]" : "text-white hover:text-[#f0bd4f]"
|
||||
isActive ? "text-[var(--green-2)]" : "text-white hover:text-[#f0bd4f]"
|
||||
}`
|
||||
}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export default function LegalText({ parts }: { parts: LegalPart[] }) {
|
|||
return (
|
||||
<div className="mx-auto max-w-3xl space-y-10 px-6 leading-relaxed text-body">
|
||||
{parts.map((part) => (
|
||||
<section key={part.id} id={part.id} style={{ scrollMarginTop: '6rem' }}>
|
||||
<section key={part.id} id={part.id}>
|
||||
<h3 className="text-xl font-bold text-ink">{part.heading}</h3>
|
||||
<div className="mt-3 space-y-3">
|
||||
{part.body.map((paragraph, i) => (
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
--pb-opacity: 0.6;
|
||||
--pb-0: #d6f5fa;
|
||||
--pb-1: #e6f0dd;
|
||||
--pb-1: var(--green-3);
|
||||
--pb-2: #fdf1d6;
|
||||
--pb-3: #d6f5fa;
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
:root[data-theme="dark"] .page-backdrop {
|
||||
--pb-opacity: 0.3;
|
||||
--pb-0: #003a45;
|
||||
--pb-1: #23361a;
|
||||
--pb-1: var(--green-1);
|
||||
--pb-2: #4a2e00;
|
||||
--pb-3: #003a45;
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@
|
|||
:root:not([data-theme="light"]) .page-backdrop {
|
||||
--pb-opacity: 0.3;
|
||||
--pb-0: #003a45;
|
||||
--pb-1: #23361a;
|
||||
--pb-1: var(--green-1);
|
||||
--pb-2: #4a2e00;
|
||||
--pb-3: #003a45;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
import { useEffect, useMemo, useRef, useState, type CSSProperties } from 'react'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
import { prefersLessMotion } from '../lib/motion.ts'
|
||||
import './PageBackdrop.css'
|
||||
|
||||
/** How many shades PageBackdrop.css defines (--pb-0 to --pb-3). */
|
||||
|
|
@ -104,7 +105,7 @@ export default function PageBackdrop() {
|
|||
useEffect(() => {
|
||||
const backdrop = ref.current
|
||||
if (!backdrop || CSS.supports('animation-timeline: scroll()')) return undefined
|
||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return undefined
|
||||
if (prefersLessMotion()) return undefined
|
||||
|
||||
backdrop.dataset.parallax = 'script'
|
||||
let frame = 0
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
top 0.6s ease-in-out;
|
||||
}
|
||||
.side-nav-circle[data-family="green"] {
|
||||
background: #e6f0dd;
|
||||
background: var(--green-3);
|
||||
}
|
||||
.side-nav-circle[data-family="amber"] {
|
||||
background: #fdf1d6;
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
box-shadow: 0 4px 12px rgb(0 0 0 / 0.45);
|
||||
}
|
||||
:root[data-theme="dark"] .side-nav-circle[data-family="green"] {
|
||||
background: #23361a;
|
||||
background: var(--green-1);
|
||||
}
|
||||
:root[data-theme="dark"] .side-nav-circle[data-family="amber"] {
|
||||
background: #4a2e00;
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
box-shadow: 0 4px 12px rgb(0 0 0 / 0.45);
|
||||
}
|
||||
:root:not([data-theme="light"]) .side-nav-circle[data-family="green"] {
|
||||
background: #23361a;
|
||||
background: var(--green-1);
|
||||
}
|
||||
:root:not([data-theme="light"]) .side-nav-circle[data-family="amber"] {
|
||||
background: #4a2e00;
|
||||
|
|
|
|||
|
|
@ -80,10 +80,9 @@ export function Section({ section }: { section: ShellSection }) {
|
|||
return (
|
||||
<section
|
||||
id={id}
|
||||
// Jumped to, it lands clear of the fixed header
|
||||
// (scroll-padding-top in index.css).
|
||||
className="py-20"
|
||||
// Clear of the fixed header, whatever it holds today (Layout
|
||||
// sets --header-h from its measured height).
|
||||
style={{ scrollMarginTop: "calc(var(--header-h, 5rem) + 1rem)" }}
|
||||
>
|
||||
{/* Heading, left aligned, optional actions on the right */}
|
||||
<div className="max-w-6xl mx-auto px-6 mb-10">
|
||||
|
|
|
|||
|
|
@ -538,7 +538,9 @@ export function PeopleTilesView({
|
|||
room !== null && overflow !== "scroll" &&
|
||||
fitsOneRow(shownGroups.map((group) => group.people.length), room.width, room.tile, room.gap);
|
||||
const anchored = overflow !== "scroll";
|
||||
// Back to the tile that opened it, as Escape does (below).
|
||||
const closePanel = () => {
|
||||
rootRef.current?.querySelector<HTMLButtonElement>('.pl__tile[aria-expanded="true"]')?.focus();
|
||||
setOpenKey(null);
|
||||
onExpand?.(null, null);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
|
||||
import type { ContentsEntry } from '../lib/contents.ts'
|
||||
import { scrollBehavior } from '../lib/motion.ts'
|
||||
import { jumpTo } from '../lib/focus.ts'
|
||||
|
||||
function useLit(entries: ContentsEntry[]) {
|
||||
const [lit, setLit] = useState<string | null>(entries[0]?.id ?? null)
|
||||
|
|
@ -42,7 +42,7 @@ function useLit(entries: ContentsEntry[]) {
|
|||
|
||||
function jump(event: React.MouseEvent<HTMLAnchorElement>, id: string) {
|
||||
event.preventDefault()
|
||||
document.getElementById(id)?.scrollIntoView({ behavior: scrollBehavior(), block: 'start' })
|
||||
jumpTo(id)
|
||||
history.replaceState(null, '', `#${id}`)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export default function PrivacyNotice() {
|
|||
<div
|
||||
role="region"
|
||||
aria-label="Privacy notice"
|
||||
className="fixed bottom-20 left-4 right-4 z-40 sm:bottom-4 mx-auto max-w-md border border-brand/20 bg-surface p-4 text-sm text-body shadow-xl sm:right-auto"
|
||||
className="reading-solid fixed bottom-20 left-4 right-4 z-40 sm:bottom-4 mx-auto max-w-md border border-brand/20 bg-surface p-4 text-sm text-body shadow-xl sm:right-auto"
|
||||
>
|
||||
<p>
|
||||
No tracking cookies here. Videos and maps come from YouTube, Facebook or Google only when you press
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import type { ContentBlockItem } from '../lib/useContent.ts'
|
|||
import { Anchor, Paragraphs } from './InlineText.tsx'
|
||||
import { withAlpha, accentText, readableOn } from '../lib/color.ts'
|
||||
import { useSmallImage } from '../lib/useSmallImage.ts'
|
||||
import { focusOnMount } from '../lib/focus.ts'
|
||||
|
||||
const BODY = 'var(--color-muted)'
|
||||
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
|
||||
|
|
@ -179,6 +180,7 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
<div>
|
||||
{showMap ? (
|
||||
<iframe
|
||||
ref={focusOnMount}
|
||||
src={mapEmbed(place)}
|
||||
title={`Map: ${place}`}
|
||||
loading="lazy"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import { useState, type SyntheticEvent } from 'react'
|
|||
import HomeLink from '../pages/sections/home/HomeLink.tsx'
|
||||
import { playingSource, videoSource, videoThumbnails } from '../lib/embeds.ts'
|
||||
import { BRAND } from '../lib/color.ts'
|
||||
import { focusOnMount } from '../lib/focus.ts'
|
||||
|
||||
|
||||
export default function VideoPlayer({
|
||||
|
|
@ -43,9 +44,18 @@ export default function VideoPlayer({
|
|||
if (playing && source) {
|
||||
const live = playingSource(source)
|
||||
return live.kind === 'file' ? (
|
||||
<video src={live.src} controls autoPlay playsInline className={`aspect-video w-full rounded-md bg-black ${className}`} />
|
||||
<video
|
||||
ref={focusOnMount}
|
||||
src={live.src}
|
||||
controls
|
||||
autoPlay
|
||||
playsInline
|
||||
aria-label={title || 'Video'}
|
||||
className={`aspect-video w-full rounded-md bg-black ${className}`}
|
||||
/>
|
||||
) : (
|
||||
<iframe
|
||||
ref={focusOnMount}
|
||||
src={live.src}
|
||||
title={title || 'Video'}
|
||||
allow="autoplay; encrypted-media; picture-in-picture; fullscreen"
|
||||
|
|
|
|||
|
|
@ -278,6 +278,7 @@ export function FilePicker({
|
|||
return (
|
||||
<dialog
|
||||
ref={dialogRef}
|
||||
aria-label="Choose a file"
|
||||
onClose={onClose}
|
||||
onClick={(e) => {
|
||||
if (e.target === dialogRef.current) dialogRef.current?.close();
|
||||
|
|
@ -292,6 +293,7 @@ export function FilePicker({
|
|||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder="Search by file name"
|
||||
aria-label="Search by file name"
|
||||
className="ml-auto w-56 border border-muted/25 px-3 py-1.5 text-sm outline-none focus:border-brand"
|
||||
/>
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -439,6 +439,7 @@ export function MediaPicker({
|
|||
return (
|
||||
<dialog
|
||||
ref={dialogRef}
|
||||
aria-label="Choose an image"
|
||||
onClose={onClose}
|
||||
onClick={(e) => {
|
||||
// A click on the backdrop lands on the dialog itself.
|
||||
|
|
@ -454,6 +455,7 @@ export function MediaPicker({
|
|||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder="Search by file name"
|
||||
aria-label="Search by file name"
|
||||
className="ml-auto w-56 border border-muted/25 px-3 py-1.5 text-sm outline-none focus:border-brand"
|
||||
/>
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { jumpTo } from "../../lib/focus.ts";
|
||||
import { scrollBehavior } from "../../lib/motion.ts";
|
||||
import { accentText } from "../../lib/color.ts";
|
||||
|
||||
|
|
@ -68,10 +69,6 @@ export function useActiveSection(sections: EditorSection[]) {
|
|||
return active;
|
||||
}
|
||||
|
||||
function jump(id: string) {
|
||||
document.getElementById(id)?.scrollIntoView({ behavior: scrollBehavior(), block: "start" });
|
||||
}
|
||||
|
||||
function Label({ section, wrap }: { section: EditorSection; wrap?: boolean }) {
|
||||
return (
|
||||
<>
|
||||
|
|
@ -80,7 +77,10 @@ function Label({ section, wrap }: { section: EditorSection; wrap?: boolean }) {
|
|||
<span className="text-xs text-muted/70">({section.count})</span>
|
||||
)}
|
||||
{section.hasError && (
|
||||
<span aria-label="needs attention" className="h-1.5 w-1.5 shrink-0 rounded-full bg-danger" />
|
||||
<>
|
||||
<span aria-hidden="true" className="h-1.5 w-1.5 shrink-0 rounded-full bg-danger" />
|
||||
<span className="sr-only">needs attention</span>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
|
@ -105,7 +105,7 @@ export function SectionNav({ sections, wrap = false }: { sections: EditorSection
|
|||
<li key={section.id}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => jump(section.id)}
|
||||
onClick={() => jumpTo(section.id)}
|
||||
aria-current={lit ? "location" : undefined}
|
||||
style={section.accent ? ({ "--nav-accent": accentText(section.accent) } as React.CSSProperties) : undefined}
|
||||
className={`-ml-px flex w-full items-center gap-1.5 border-l-2 px-3 py-1.5 text-left text-sm transition-colors ${
|
||||
|
|
@ -138,7 +138,11 @@ export function SectionJump({ sections }: { sections: EditorSection[] }) {
|
|||
<span className="shrink-0">Jump to</span>
|
||||
<select
|
||||
value={active ?? ""}
|
||||
onChange={(e) => jump(e.target.value)}
|
||||
// Scroll only: the arrow keys change a select option by
|
||||
// option, and taking focus away would stop that.
|
||||
onChange={(e) =>
|
||||
document.getElementById(e.target.value)?.scrollIntoView({ behavior: scrollBehavior(), block: "start" })
|
||||
}
|
||||
className="w-full border border-muted/25 bg-surface px-3 py-1.5 text-sm text-body outline-none focus:border-brand"
|
||||
>
|
||||
{sections.map((section) => (
|
||||
|
|
|
|||
|
|
@ -267,11 +267,22 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
};
|
||||
const showFiles = field.files && !locked && (!field.filesWhen || fieldShown({ when: field.filesWhen }, row));
|
||||
|
||||
// The line under the field (its error, the deleted-row warning, or
|
||||
// its help) is read with it, and the field says when it's required
|
||||
// or wrong, not only the red star and border.
|
||||
const noteId = `${id}-note`;
|
||||
const hasNote = Boolean(error || (orphaned && !locked) || (helpText(field, row) && widget !== "checkbox"));
|
||||
const described = {
|
||||
"aria-describedby": hasNote ? noteId : undefined,
|
||||
"aria-invalid": Boolean(error || (orphaned && !locked)) || undefined,
|
||||
"aria-required": (field.required && !locked) || undefined,
|
||||
};
|
||||
const common = {
|
||||
id,
|
||||
className: `${input} ${error ? inputError : ""}`,
|
||||
value: value ?? "",
|
||||
onChange: (e) => onChange(e.target.value),
|
||||
...described,
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
@ -336,6 +347,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
value={/^#[0-9a-f]{6}$/i.test(value ?? "") ? value : colorPlaceholder(field, row)}
|
||||
disabled={locked}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
aria-label={`${typeof field.label === "function" ? field.label(row) : field.label}: pick a color`}
|
||||
className="h-9 w-12 shrink-0 border border-muted/25 bg-surface disabled:opacity-50"
|
||||
/>
|
||||
<input
|
||||
|
|
@ -398,6 +410,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
value={value ?? ""}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
placeholder={field.placeholder}
|
||||
{...described}
|
||||
className="w-full border-0 bg-transparent p-0 text-body outline-none placeholder:text-muted/45"
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -421,15 +434,15 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
</div>
|
||||
|
||||
{error ? (
|
||||
<p className="mt-1 text-xs text-danger">{error}</p>
|
||||
<p id={noteId} className="mt-1 text-xs text-danger">{error}</p>
|
||||
) : orphaned && !locked ? (
|
||||
<p className="mt-1 text-xs text-danger">
|
||||
<p id={noteId} className="mt-1 text-xs text-danger">
|
||||
This points at something that has been deleted. Pick a replacement before saving.
|
||||
</p>
|
||||
) : (
|
||||
helpText(field, row) &&
|
||||
widget !== "checkbox" && (
|
||||
<p className="mt-1 text-xs text-muted">{helpText(field, row)}</p>
|
||||
<p id={noteId} className="mt-1 text-xs text-muted">{helpText(field, row)}</p>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue