Merge pull request 'Accessibility, event photo and analytics (v1.12.0-accessibility)' (#25) from accessibility into main

This commit is contained in:
ngu-git-admin 2026-10-03 09:03:19 +01:00
commit f4868f19fc
58 changed files with 848 additions and 224 deletions

View file

@ -32,6 +32,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu
- Debugging: check `journalctl -u ngu-api -n 40 --no-pager` first. Make sure rsync ran from the repo (not the deployed copy) before restarting the service.
- Never run commands against the production server or database unless explicitly asked.
- Uploaded media: `UPLOADS_DIR=/var/lib/ngu/uploads`, served by nginx at `/uploads/`. Setup and the nginx block are in `docs/media-uploads.md`.
- Analytics: self-hosted Plausible, proxied by nginx at `/pa/`. The API adds its script to every page (`analyticsTag` in `server/src/pageMeta.js`), counting under the hostname of `site.json`'s `url`, so each deployment reports as itself. Nothing in `index.html` or the app.
- Page HTML goes through the API, which fills in each page's title, description, preview image and structured data (`server/src/pageMeta.js`), and serves `/sitemap.xml`. It reads `SITE_CONFIG` (site.json) and `SITE_INDEX` (the built index.html), with Panel → Site settings (the `site_settings` table) laid over site.json, and serves `/robots.txt` from the same merge. nginx setup: `docs/seo.md`.
- Video clips (Tools, admins and up): yt-dlp downloads our YouTube/Facebook videos into `CLIPS_DIR`, ffmpeg cuts them; one job at a time, files swept after a day (`server/src/clips.js`). Needs yt-dlp and ffmpeg on the VPS: `docs/video-clips.md`.
- Newsletter countdown pictures: `/api/countdown/:id.png` (`server/src/routes/countdown.js`), drawn with sharp when an email is opened; it uses the VPS's fonts, so install Poppins there (eg. into `/usr/local/share/fonts`, then `fc-cache`) or it falls back to a plain sans. The social bar's icons are static files in `public/email/`.

View file

@ -279,6 +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 `<html>` 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. |
| 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` | |

View file

@ -17,8 +17,14 @@
document.documentElement.dataset.theme =
t === "dark" || t === "light" ? t : matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
// The accessibility panel's choices (AccessibilityPanel.tsx).
// Reading and color blind modes are for the public pages: the
// admin edits colors and layout, which they would hide.
if (localStorage.getItem("site-font") === "dyslexic") document.documentElement.dataset.font = "dyslexic";
if (!location.pathname.startsWith("/admin")) {
if (localStorage.getItem("site-reading") === "on") document.documentElement.dataset.reading = "on";
var v = localStorage.getItem("site-vision");
if (/^(protanopia|deuteranopia|tritanopia|monochrome)$/.test(v || "")) document.documentElement.dataset.vision = v;
}
} catch (e) {}
</script>
<!-- site:head-end -->

View file

@ -61,6 +61,8 @@ export const events = {
text("event_logo"),
text("color"),
text("card_image"),
text("photo"),
text("photo_alt"),
bool("is_published"),
bool("is_listed"),
bool("in_timeline"),

View file

@ -0,0 +1,20 @@
-- ═══════════════════════════════════════════════════════════════
-- 061 EVENTS: EVENT PHOTO
--
-- An event's own 16:9 photo, shown whole: at the top of its page, as
-- the front page's featured event, on featured cards, in newsletter
-- picks and as its page's share preview. photo_alt says what it
-- shows, for screen readers (blank: decoration).
--
-- card_image (029) goes back to being only the faded background of
-- the event's card, which crops it to the card's shape. Until now it
-- did both jobs, so each event's photo starts as its card
-- background, to keep the front page and previews as they were.
--
-- v_events selects e.*, so it carries the new columns as it is.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE events ADD COLUMN photo TEXT;
ALTER TABLE events ADD COLUMN photo_alt TEXT;
UPDATE events SET photo = card_image WHERE card_image IS NOT NULL;

View file

@ -199,7 +199,7 @@ function eventMeta(site, db, id, meta) {
const when = [row.date_label, row.location_label].filter(Boolean).join(" · ");
const image =
imageUrl(site, row.card_image, "eventBackground") ??
imageUrl(site, row.photo, "eventPhoto") ??
imageUrl(site, row.event_logo, "eventLogo") ??
imageUrl(site, row.effective_org_logo, "organization") ??
meta.image;
@ -445,6 +445,22 @@ const REPLACED = [
can end the element early. */
const scriptJson = (value) => JSON.stringify(value).replace(/</g, "\\u003c");
/* Plausible, self-hosted and reached through nginx at /pa/ (the
Privacy page describes it). Each deployment counts under its own
address, site.json's url, so dev and live stay apart. Its script
follows the app's page changes itself. */
const PLAUSIBLE = { script: "/pa/js/script.js", api: "/pa/api/event" };
function analyticsTag(site) {
let domain;
try {
domain = new URL(site.url).hostname;
} catch {
return null; // no url, nothing to count under
}
return `<script defer data-domain="${escapeHtml(domain)}" data-api="${PLAUSIBLE.api}" src="${PLAUSIBLE.script}"></script>`;
}
export function renderPage(html, meta) {
const site = meta.site;
let out = html;
@ -477,6 +493,7 @@ export function renderPage(html, meta) {
// script in the head runs during parsing; modules wait).
`<script>window.__SITE__ = ${scriptJson(forBrowser(site))}</script>`,
site.themeCss && `<style id="site-colors">${site.themeCss}</style>`,
analyticsTag(site),
].filter(Boolean);
// A blocked site (Site settings indexing off, or site.json's

View file

@ -150,6 +150,8 @@ function shapeEvent(row, links, cardBlocks, hosts = []) {
event_logo: row.event_logo,
color: row.effective_color,
card_image: row.card_image,
photo: row.photo,
photo_alt: row.photo_alt,
hosts: hosts.map(shapeHost),
@ -463,7 +465,7 @@ content.get("/events", (c) => {
// Optional filters, each narrowing the list (src/lib/eventData.ts):
// ?scope=national ?host=<org or person slug> ?status=upcoming
// ?type=class,workshop
// ?type=class,workshop ?from=&to= (a date window) ?past=12
const where = [`is_published = 1`, `is_listed = 1`];
const params = [];
const scope = c.req.query("scope");
@ -477,11 +479,38 @@ content.get("/events", (c) => {
if (status) where.push(`effective_status = ?`), params.push(status);
const types = (c.req.query("type") ?? "").split(",").filter(Boolean).slice(0, 20);
if (types.length) where.push(`event_type IN (${marks(types.length)})`), params.push(...types);
// ?from=2026-10-01&to=2026-11-07: only events with a day in that
// window (the calendar's six weeks), plus the undated ones it
// counts. Either end may be left off. A series with no end date
// runs on, so it stays in every window after its start.
const day = (name) => {
const value = c.req.query(name);
return /^\d{4}-\d{2}-\d{2}$/.test(value ?? "") ? value : null;
};
const from = day("from");
const to = day("to");
if (from || to) {
const dated = [];
if (to) dated.push(`starts_on <= ?`), params.push(to);
if (from) {
dated.push(`COALESCE(ends_on, CASE WHEN is_series = 1 THEN '9999-12-31' ELSE starts_on END) >= ?`);
params.push(from);
}
where.push(`(starts_on IS NULL OR (${dated.join(" AND ")}))`);
}
const rows = db
let rows = db
.prepare(`SELECT * FROM v_events WHERE ${where.join(" AND ")} ORDER BY ${EVENT_ORDER}`)
.all(...params);
// ?past=12: only the 12 most recent past events (a carousel's way
// back), before their links, cards and hosts are loaded.
const past = Number.parseInt(c.req.query("past") ?? "", 10);
if (past >= 0) {
let keep = rows.filter((row) => row.effective_status === "past").length - past;
rows = rows.filter((row) => row.effective_status !== "past" || keep-- <= 0);
}
const ids = rows.map((row) => row.id);
const links = loadLinks(db, "event", ids);
const cards = loadBlocks(db, "event", ids, "card");

View file

@ -87,14 +87,15 @@ function statValue(db, row) {
}
/* The countdown's fields plus what the hero's event card also draws:
its tagline, place, card background and buttons. */
its tagline, place, photo and buttons. */
function shapeHeroEvent(db, row) {
if (!row) return null;
const { actions } = splitLinks(loadLinks(db, "event", [row.id]).get(row.id) ?? []);
return {
...shapeCountdown(row),
tagline: row.tagline,
card_image: row.card_image,
photo: row.photo,
photo_alt: row.photo_alt,
org_logo: row.effective_org_logo,
links: actions,
};

View file

@ -369,6 +369,8 @@ tx(db, () => {
event_logo: IMAGE,
color: "#d62976",
card_image: IMAGE,
photo: IMAGE,
photo_alt: "The showcase test image",
is_published: 1,
is_listed: LISTED,
in_timeline: LISTED,

View file

@ -203,7 +203,7 @@ export function shapeSeries(row) {
`image` is { file, kind }, like the timeline's logo: the record
tables keep bare filenames in different public/ directories,
and logoForKind in media.ts knows which is which. The kinds are
the ref kinds, plus 'event-background' and 'featured' (the
the ref kinds, plus 'event-photo' and 'featured' (the
card's own image). An unpublished
record's card is dropped; an unlisted one's stays, since
featuring it is attaching it by hand.
@ -213,11 +213,11 @@ const FEATURED_REFS = {
event: {
sql: (marks) =>
`SELECT id, title, tagline AS blurb, date_label AS eyebrow,
card_image, event_logo
photo, event_logo
FROM events WHERE is_published = 1 AND id IN (${marks})`,
image: (row) =>
row.card_image
? { file: row.card_image, kind: "event-background" }
row.photo
? { file: row.photo, kind: "event-photo" }
: row.event_logo
? { file: row.event_logo, kind: "event" }
: null,

View file

@ -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>
)
}

View file

@ -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

View file

@ -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>

View file

@ -35,7 +35,7 @@ import { useSmallImage } from '../lib/useSmallImage.ts'
/* Image kinds that are photographs, drawn edge to edge. Anything
else is a logo, drawn whole. */
const PHOTO_KINDS = new Set(['event-background', 'featured', 'person'])
const PHOTO_KINDS = new Set(['event-photo', 'featured', 'person'])
function hrefFor(card: FeaturedCard): string | null {
if (card.kind === 'record' && card.ref) {

View file

@ -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";

View file

@ -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]"
}`
}
>

View file

@ -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) => (

View file

@ -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;
}

View file

@ -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

View file

@ -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;

View file

@ -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">

View file

@ -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);
};

View file

@ -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}`)
}

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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) => (

View file

@ -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>

View file

@ -110,6 +110,9 @@
html {
scroll-behavior: smooth;
/* Clear of the fixed header (Layout.tsx measures it): anything
scrolled to, by an anchor or by keyboard focus, lands below it. */
scroll-padding-top: calc(var(--header-h, 0px) + 1rem);
}
/* An email address is one long word: let it break anywhere rather
@ -125,6 +128,12 @@ a[href^="mailto:"] {
outline: 2px solid var(--color-link);
outline-offset: 2px;
}
/* Not on things focused only to move the reader there (the page's
content on a new page, a section jumped to; motion.ts, jumpTo):
they aren't controls, and a ring round a whole section is noise. */
[tabindex="-1"]:focus {
outline: none;
}
/* Visitors who ask for less motion get no smooth scrolling, slides
or hover zooms. */
@ -241,39 +250,146 @@ iframe[src*="churchcenter"] {
font-family: 'OpenDyslexic', sans-serif;
}
/* Reading mode: the same content with the design stepped back. No
background circles, motion or shadows; every layout one column,
narrower and larger, with plain underlined links. */
/* Reading mode: the page as plain text. One narrow column of ink on
white (or the reverse in dark mode): no colors, backgrounds,
cards, shadows, borders, pictures, motion or decoration, larger
type and underlined links. A picture or video with a description
leaves it in its place (AccessibilityPanel.tsx copies it to
data-reading-alt on its parent). Unlayered, so it wins over the
admin's colors (theme.js, in layers). */
:root[data-reading="on"] {
--color-ink: #111111;
--color-body: #111111;
--color-muted: #444444;
--color-link: #111111;
--color-brand: #111111;
--color-action: #111111;
--color-action-hover: #444444;
--color-surface: #ffffff;
--color-tint: #ffffff;
--color-tint-soft: #ffffff;
--color-raised: #ffffff;
--color-danger: #111111;
--color-danger-tint: #ffffff;
--accent-text-mix: 100%;
font-size: 112.5%;
scroll-behavior: auto;
}
:root[data-reading="on"] .page-backdrop {
display: none;
:root[data-reading="on"][data-theme="dark"] {
--color-ink: #eeeeee;
--color-body: #eeeeee;
--color-muted: #bbbbbb;
--color-link: #eeeeee;
--color-brand: #eeeeee;
--color-action: #eeeeee;
--color-action-hover: #bbbbbb;
--color-surface: #111111;
--color-tint: #111111;
--color-tint-soft: #111111;
--color-raised: #111111;
--color-danger: #eeeeee;
--color-danger-tint: #111111;
}
@media (prefers-color-scheme: dark) {
:root[data-reading="on"]:not([data-theme="light"]) {
--color-ink: #eeeeee;
--color-body: #eeeeee;
--color-muted: #bbbbbb;
--color-link: #eeeeee;
--color-brand: #eeeeee;
--color-action: #eeeeee;
--color-action-hover: #bbbbbb;
--color-surface: #111111;
--color-tint: #111111;
--color-tint-soft: #111111;
--color-raised: #111111;
--color-danger: #eeeeee;
--color-danger-tint: #111111;
}
}
/* Everything takes the page's two colors, inline styles included. */
:root[data-reading="on"] body * {
color: var(--color-ink) !important;
background-color: transparent !important;
background-image: none !important;
border-color: transparent !important;
box-shadow: none !important;
text-shadow: none !important;
filter: none !important;
mask-image: none !important;
-webkit-mask-image: none !important;
}
:root[data-reading="on"] body,
:root[data-reading="on"] header,
:root[data-reading="on"] .reading-solid {
background-color: var(--color-surface) !important;
}
:root[data-reading="on"] header {
border-bottom: 1px solid var(--color-muted) !important;
}
:root[data-reading="on"] *,
:root[data-reading="on"] *::before,
:root[data-reading="on"] *::after {
animation: none !important;
transition: none !important;
box-shadow: none !important;
}
/* Pictures, video, maps and drawings go; the icons inside links and
buttons stay, in the text color, so an icon-only button keeps
its face. */
:root[data-reading="on"] main :is(img, picture, video, iframe, canvas, object),
:root[data-reading="on"] main svg:not(:is(a, button, label) svg),
:root[data-reading="on"] .page-backdrop,
:root[data-reading="on"] .notice::before,
:root[data-reading="on"] .notice::after {
display: none !important;
}
:root[data-reading="on"] [data-reading-alt]::after {
content: attr(data-reading-alt);
display: block;
margin-block: 0.5rem;
font-style: italic;
}
/* Controls keep an outline so they still read as controls. */
:root[data-reading="on"] :is(button, input, select, textarea, .btn) {
border: 1px solid var(--color-ink) !important;
}
:root[data-reading="on"] main {
max-width: 48rem;
max-width: 42rem;
margin-inline: auto;
padding-inline: 1rem;
}
:root[data-reading="on"] main .grid {
grid-template-columns: minmax(0, 1fr) !important;
}
:root[data-reading="on"] main p,
:root[data-reading="on"] main li {
:root[data-reading="on"] main :is(p, li, dd) {
line-height: 1.75;
}
:root[data-reading="on"] main a {
text-decoration: underline;
:root[data-reading="on"] a {
text-decoration: underline !important;
text-underline-offset: 0.2em;
}
/* Color blind modes (data-vision, color.ts has the reasoning and the
same swap for colors set from code). The palette's green family
as variables, so CSS that uses it swaps too. */
:root {
--green-0: #4a7431;
--green-1: #23361a;
--green-2: #9cc47c;
--green-3: #e6f0dd;
}
:root:is([data-vision="protanopia"], [data-vision="tritanopia"]) {
--green-0: #9839dc;
--green-1: #4d1575;
--green-2: #c9a5e3;
--green-3: #f4eef9;
}
/* Monochrome: the whole page in grays. On the root element a filter
leaves fixed elements (the header, the panel) where they were. */
:root[data-vision="monochrome"] {
filter: grayscale(1);
}
/* A notice where content would be (an empty section, a form's
note, "coming soon"): no box and no fill, just two thick brackets
at opposite corners, top left and bottom right, like a

View file

@ -147,13 +147,27 @@ export const events = {
{ path: "event_logo", label: "Event logo", widget: "image", folder: "logos", resolve: mediaUrl, full: true },
{ path: "org_logo", label: "Org logo override", widget: "image", folder: "logos", resolve: mediaUrl, full: true },
{ path: "color", label: "Color", widget: "color" },
{
path: "photo",
label: "Event photo",
widget: "image",
resolve: mediaUrl,
full: true,
help: "16:9, eg. 1920 x 1080, shown whole: at the top of the event's page, as the front page's featured event, on featured cards, in the newsletter and when the page is shared.",
},
{
path: "photo_alt",
label: "Photo description",
full: true,
help: "What the photo shows, for people who can't see it, eg. Campers around the fire at the 2025 retreat. Default: none (read as decoration).",
},
{
path: "card_image",
label: "Card background",
widget: "image",
resolve: mediaUrl,
full: true,
help: "A photo behind the event's card, faded so the text stays readable.",
help: "Only behind the event's card, faded so the text stays readable and cropped to the card's shape (about square). Keep the subject centered and leave words out.",
},
],
},

View file

@ -16,6 +16,8 @@
request runs, instead of a loading skeleton.
═══════════════════════════════════════════════════════════════ */
import { visionColor } from "./color.ts";
const BASE = import.meta.env?.VITE_API_BASE ?? "/api";
const DEFAULT_TTL = 60_000;
@ -69,7 +71,26 @@ async function request(path, options: RequestInit = {}) {
});
}
return body;
return recolors() ? recolor(body) : body;
}
/* Colors that arrive as data (an event's, a region's) shown the way
the visitor's color blind mode needs (color.ts, visionColor).
Never in the admin, where a swapped color would be saved back;
asked per request, since the site gets there without a reload. */
const recolors = () =>
typeof document !== "undefined" &&
Boolean(document.documentElement.dataset.vision) &&
!location.pathname.startsWith("/admin");
function recolor(value) {
if (value == null) return value;
if (typeof value === "string") return visionColor(value);
if (Array.isArray(value)) return value.map(recolor);
if (typeof value === "object") {
for (const key of Object.keys(value)) value[key] = recolor(value[key]);
}
return value;
}
/* ── Reads ─────────────────────────────────────────────────────

View file

@ -38,6 +38,91 @@ export function readableOn(color: string): string {
return onWhite >= onInk ? '#ffffff' : '#001011'
}
/* ── The palette ─────────────────────────────────────────────────
The site's 16 colors: four families, each [main, darkest, light,
lightest]. The theme tokens above are chosen from these; so is
anything drawn from the palette as data (a person's initials
tile, the page background, the admin home's sections). Each main
shade reads as text on white and takes white text on it (5:1 or
better); the darkest are for text, the light and lightest for
fills behind text. */
/* As stored and sent: never swapped for a color blind mode. For
colors that are saved or leave the site (the newsletter's picks);
anything drawn on a public page uses PALETTE, below. */
export const STORED_PALETTE = {
teal: ['#00748a', '#003a45', '#5cd3e6', '#d6f5fa'],
green: ['#4a7431', '#23361a', '#9cc47c', '#e6f0dd'],
amber: ['#8f5b00', '#4a2e00', '#f0bd4f', '#fdf1d6'],
ink: ['#3b5456', '#001011', '#a3b8b9', '#f5f9f8'],
}
/* ── Color blind modes (AccessibilityPanel.tsx) ──────────────────
<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. */
export const VISIONS = [
{ id: 'protanopia', label: 'Protanopia (red weak)' },
{ id: 'deuteranopia', label: 'Deuteranopia (green weak)' },
{ id: 'tritanopia', label: 'Tritanopia (blue weak)' },
{ 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 },
}
const vision = typeof document === 'undefined' ? undefined : document.documentElement.dataset.vision
const swaps = vision ? SWAPS[vision] : undefined
const SHADES = Object.entries(STORED_PALETTE).flatMap(([family, shades]) =>
shades.map((hex, i) => ({ hex, swapped: swaps?.[family as keyof typeof STORED_PALETTE]?.[i] ?? hex })),
)
const rgb = (hex: string) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16))
/* A #rrggbb color as the current color blind mode shows it: the
palette's swap, or an off-palette color snapped to the nearest
palette shade first. Anything else (a CSS variable, no mode)
comes back as it was. */
export function visionColor(color: string): string {
if (!swaps || !/^#[0-9a-f]{6}$/i.test(color)) return color
const [r, g, b] = rgb(color.toLowerCase())
let best = SHADES[0]
let bestDistance = Infinity
for (const shade of SHADES) {
const [sr, sg, sb] = rgb(shade.hex)
// Weighted RGB ("redmean"), close enough to pick a neighbor.
const mean = (r + sr) / 2
const distance = (2 + mean / 256) * (r - sr) ** 2 + 4 * (g - sg) ** 2 + (2 + (255 - mean) / 256) * (b - sb) ** 2
if (distance < bestDistance) [best, bestDistance] = [shade, distance]
}
return best.swapped
}
export const PALETTE = Object.fromEntries(
Object.entries(STORED_PALETTE).map(([family, shades]) => [family, shades.map(visionColor)]),
) as { [K in keyof typeof STORED_PALETTE]: string[] }
/* Fills that take the page's ink text (#001011, 9:1 or better) and
fills that take white text (5:1 or better), for things colored
from the palette by data, like an initials tile. */
export const PALETTE_LIGHT = ['#d6f5fa', '#e6f0dd', '#fdf1d6', '#f0bd4f', '#9cc47c', '#5cd3e6'].map(visionColor)
export const PALETTE_DARK = ['#003a45', '#23361a', '#4a2e00', '#00748a', '#4a7431', '#8f5b00', '#3b5456'].map(visionColor)
/* ── The site's accents ──────────────────────────────────────────
BRAND is the teal every page uses as its accent; it's the button
token, so the admin's palette (Site settings → Colors) reaches it.
@ -49,31 +134,10 @@ export const BRAND = 'var(--color-action)'
export const ACCENTS = {
teal: BRAND,
deep: '#003a45',
green: '#4a7431',
green: visionColor('#4a7431'),
amber: '#8f5b00',
}
/* ── The palette ─────────────────────────────────────────────────
The site's 16 colors: four families, each [main, darkest, light,
lightest]. The theme tokens above are chosen from these; so is
anything drawn from the palette as data (a person's initials
tile, the page background, the admin home's sections). Each main
shade reads as text on white and takes white text on it (5:1 or
better); the darkest are for text, the light and lightest for
fills behind text. */
export const PALETTE = {
teal: ['#00748a', '#003a45', '#5cd3e6', '#d6f5fa'],
green: ['#4a7431', '#23361a', '#9cc47c', '#e6f0dd'],
amber: ['#8f5b00', '#4a2e00', '#f0bd4f', '#fdf1d6'],
ink: ['#3b5456', '#001011', '#a3b8b9', '#f5f9f8'],
} as const
/* Fills that take the page's ink text (#001011, 9:1 or better) and
fills that take white text (5:1 or better), for things colored
from the palette by data, like an initials tile. */
export const PALETTE_LIGHT = ['#d6f5fa', '#e6f0dd', '#fdf1d6', '#f0bd4f', '#9cc47c', '#5cd3e6'] as const
export const PALETTE_DARK = ['#003a45', '#23361a', '#4a2e00', '#00748a', '#4a7431', '#8f5b00', '#3b5456'] as const
/* A palette fill for something colored by its name, like the
initials tile of a person with no photo: the same name always gets
the same fill, and each fill comes with its readable text (ink on

View file

@ -10,6 +10,8 @@
useEvents({ status: "upcoming" }) a home page strip
useEvents({ type: "workshop" }) one kind, wherever it is
useEvents({ type: ["class", "workshop"] })
useEvents({ from: "2026-09-27", to: "2026-11-07" }) a window
useEvents({ scope: "national", past: 12 }) 12 past at most
useEvents() everything
`scope` and `type` are different questions and stack rather
@ -33,7 +35,7 @@ const NO_SCOPES: any[] = [];
const NO_EVENTS: any[] = [];
/* The path for a filter, as the server reads it (routes/content.js). */
export function eventsPath({ scope, host, status, type }: any = {}) {
export function eventsPath({ scope, host, status, type, from, to, past }: any = {}) {
const query = new URLSearchParams();
if (scope) query.set("scope", scope);
// An organization or a person slug: co-hosting puts one event on
@ -42,15 +44,24 @@ export function eventsPath({ scope, host, status, type }: any = {}) {
if (status) query.set("status", status);
const types = Array.isArray(type) ? type.join(",") : type;
if (types) query.set("type", types);
// A date window (YYYY-MM-DD, either end optional): events with a
// day in it, plus undated ones. The calendar asks for its grid.
if (from) query.set("from", from);
if (to) query.set("to", to);
// Only the most recent `past` past events (a carousel's way back).
if (past != null) query.set("past", String(past));
const qs = query.toString();
return qs ? `/events?${qs}` : "/events";
}
/* A null filter fetches nothing. `ready` is whether any answer has
arrived; on a change of filter the last answer stays until the
new one lands, so a caller can keep it on screen meanwhile. */
export function useEvents(filter: any = {}) {
const { data, error, loading } = useResource(eventsPath(filter));
const { data, error, loading } = useResource(filter ? eventsPath(filter) : null);
const events = data?.events ?? NO_EVENTS;
const scopes = data?.scopes ?? NO_SCOPES;
return { events, scopes, loading, error };
return { events, scopes, loading, error, ready: data !== undefined };
}
/* Past and upcoming, split. `status` arrives already resolved, the

24
src/lib/focus.ts Normal file
View file

@ -0,0 +1,24 @@
/* Moving keyboard focus for the reader, where the page changes
under them. */
import { scrollBehavior } from './motion.ts'
/* For something that replaces the control that opened it (a
thank-you in place of its form, a player in place of its Play
button): as a ref, focus goes to it when it appears, so a screen
reader reads it and Tab carries on from there. A stable function,
so React calls it once, on mount. */
export const focusOnMount = (el: HTMLElement | null) => el?.focus()
/* Go to a part of the page, as a link to #id does: scroll it into
view and move focus there, so the next Tab carries on from it
rather than from the link (a section that can't take focus is
given tabindex -1 for it). False when there's no such id. */
export function jumpTo(id: string): boolean {
const el = document.getElementById(id)
if (!el) return false
if (!el.hasAttribute('tabindex')) el.setAttribute('tabindex', '-1')
el.scrollIntoView({ behavior: scrollBehavior(), block: 'start' })
el.focus({ preventScroll: true })
return true
}

View file

@ -1,5 +1,9 @@
/* Smooth scrolling, unless the visitor has asked for less motion.
index.css covers CSS scrolling; this is for scrollIntoView and
scrollTo calls, which don't read that setting themselves. */
export const scrollBehavior = (): ScrollBehavior =>
window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth'
/* Less motion: the visitor's system asks for it, or the
accessibility panel's reading mode is on. index.css covers CSS
scrolling and animation; these are for scrollIntoView and
scrollTo calls, and slideshows, which don't read either. */
export const prefersLessMotion = (): boolean =>
window.matchMedia('(prefers-reduced-motion: reduce)').matches ||
document.documentElement.dataset.reading === 'on'
export const scrollBehavior = (): ScrollBehavior => (prefersLessMotion() ? 'auto' : 'smooth')

View file

@ -26,7 +26,7 @@
cards and dividers (with their color, thickness and
spacing); a video is its still linked to the video
Colors are the site's palette (PALETTE) or "none"; blank is the
Colors are the site's palette (STORED_PALETTE) or "none"; blank is the
default. No unsubscribe link: Mailchimp adds its own to every send.
Email clients ignore stylesheets, CSS variables and most layout,

View file

@ -133,8 +133,11 @@ export type EventRecord = {
org_logo?: string | null
event_logo?: string | null
color?: string | null
/** Behind the card. See 029_event_card_image.sql. */
/** Behind the card only, cropped. See 029_event_card_image.sql. */
card_image?: string | null
/** The event's own 16:9 photo, shown whole. See 061_event_photo.sql. */
photo?: string | null
photo_alt?: string | null
/* In billing order. The first is the one `color` and `org_logo`
fell back to when the event set neither. */
hosts: EventHost[]

View file

@ -111,7 +111,8 @@ export type FeaturedCard = {
/** The countdown's event plus what the hero's event card draws. */
export type HeroEvent = CountdownEvent & {
tagline?: string | null
card_image?: string | null
photo?: string | null
photo_alt?: string | null
org_logo?: string | null
links: Link[]
}

View file

@ -13,6 +13,9 @@
A path asked for before starts from its last answer (api.ts,
peek) and isn't `loading` while it refreshes, so a page opened
again after the TTL doesn't flash its skeleton.
A null path asks for nothing (data stays undefined, not loading),
for a fetch that only some states need.
═══════════════════════════════════════════════════════════════ */
import { useEffect, useState } from "react";
@ -20,11 +23,15 @@ import { get, peek } from "./api.ts";
export function useResource(path, { ttl }: { ttl?: number } = {}) {
const [state, setState] = useState<any>(() => {
const stale = peek(path);
return { data: stale, error: null, loading: stale === undefined };
const stale = path ? peek(path) : undefined;
return { data: stale, error: null, loading: Boolean(path) && stale === undefined };
});
useEffect(() => {
if (!path) {
setState({ data: undefined, error: null, loading: false });
return undefined;
}
let ignore = false;
const stale = peek(path);

View file

@ -7,4 +7,4 @@
box or a build banner can read the same value later.
═══════════════════════════════════════════════════════════════ */
export const SITE_VERSION = "NGU-Web.v1.11.2-newsletter";
export const SITE_VERSION = "NGU-Web.v1.12.0-accessibility";

View file

@ -98,6 +98,15 @@ export default function EventDetail() {
<div className="max-w-6xl mx-auto px-6 space-y-8">
<Facts event={event} accent={accent} />
{/* The event's own 16:9 photo (not the card's background). */}
{event.photo && (
<img
src={mediaUrl(event.photo) ?? ''}
alt={event.photo_alt ?? ''}
className="aspect-video w-full max-w-3xl object-cover"
/>
)}
{event.description.map((paragraph, index) => (
<p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}>
{paragraph}

View file

@ -24,7 +24,7 @@ import { useSitePage, type SitePageSection } from '../lib/useSitePages.ts'
import { useHistory } from '../lib/useHistory.ts'
import { HISTORY_DECADES } from '../data/historyDecades.ts'
import { ACCENTS, BRAND } from '../lib/color.ts'
import { scrollBehavior } from '../lib/motion.ts'
import { jumpTo } from '../lib/focus.ts'
import OrgListMap, { OrgMapToggle } from './sections/OrgList-Map.tsx'
import OrgListVertical from './sections/OrgList-Vertical.tsx'
import OrgListCards from './sections/OrgList-Card.tsx'
@ -113,7 +113,7 @@ function Sections({ title, intro, sections }: { title: string; intro?: string; s
// sections have loaded; this does it again once they're here.
const { hash } = useLocation()
useEffect(() => {
if (hash) document.getElementById(decodeURIComponent(hash.slice(1)))?.scrollIntoView({ behavior: scrollBehavior() })
if (hash) jumpTo(decodeURIComponent(hash.slice(1)))
}, [hash])
const manifest = useSectionManifest(

View file

@ -464,6 +464,7 @@ export default function AdminClips() {
value={url}
onChange={(e) => setUrl(e.target.value)}
placeholder="https://www.youtube.com/watch?v=…"
aria-label="Video link"
className={`min-w-0 flex-1 ${input}`}
/>
<button type="submit" className={primary} disabled={adding || !url.trim()}>

View file

@ -391,6 +391,7 @@ function FeedbackCard({ row, onChange, onRemove, canWrite, canRemove }) {
value={note}
disabled={busy}
placeholder="Internal note: who's handling it, what was done"
aria-label="Internal note"
onChange={(e) => setNote(e.target.value)}
className="mt-3 w-full resize-y border border-muted/25 bg-surface px-3 py-2 text-sm text-body outline-none focus:border-brand focus:ring-2 focus:ring-brand/25"
/>
@ -611,6 +612,7 @@ export default function AdminFeedback({ kind = "feedback" }: { kind?: keyof type
type="search"
value={query}
placeholder="Search messages"
aria-label="Search messages"
onChange={(e) => setQuery(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter") setSearch(query.trim());

View file

@ -304,6 +304,7 @@ function FilesTab() {
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search by file name"
aria-label="Search by file name"
className="ml-auto w-64 border border-muted/25 px-3 py-2 text-sm outline-none focus:border-brand"
/>
</div>
@ -548,6 +549,7 @@ export default function AdminMedia() {
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search by file name"
aria-label="Search by file name"
className="ml-auto w-64 border border-muted/25 px-3 py-2 text-sm outline-none focus:border-brand"
/>
</div>

View file

@ -38,7 +38,7 @@ import { mediaUrl } from '../../lib/media.ts'
import { SITE_NAME, SITE_ORIGIN, siteUrl } from '../../lib/site.ts'
import { seriesLabel } from '../../lib/eventSeries.ts'
import { useWideAdminPage } from '../../lib/adminWidth.tsx'
import { PALETTE } from '../../lib/color.ts'
import { STORED_PALETTE } from '../../lib/color.ts'
import { PLATFORMS } from '../../lib/platforms.ts'
import { SOCIAL_LINKS } from '../../data/socialLinks.ts'
import {
@ -81,9 +81,10 @@ const PART_TYPES: Array<[string, string, string]> = [
]
const partLabel = (type: string) => PART_TYPES.find(([value]) => value === type)?.[1] ?? type
/* The site's palette as choices; an inbox needs the hex itself. */
/* The site's palette as choices; an inbox needs the hex itself, and
the one stored, not a color blind mode's swap (color.ts). */
const SHADES = ['', ', darkest', ', light', ', lightest']
const PALETTE_OPTIONS = Object.entries(PALETTE).flatMap(([family, shades]) =>
const PALETTE_OPTIONS = Object.entries(STORED_PALETTE).flatMap(([family, shades]) =>
shades.map((hex, i) => [hex, `${family[0].toUpperCase()}${family.slice(1)}${SHADES[i]}`]),
)
const colorField = (path: string, label: string, fallback: string, none: string, types: string[]) => ({
@ -360,7 +361,7 @@ export default function AdminNewsletter() {
.filter(Boolean)
.join(', '),
text: event.tagline ?? event.description?.[0] ?? null,
image: imageFor(event.card_image),
image: imageFor(event.photo),
href: siteUrl(eventHref(event.id)),
cta: PICK_DEFAULTS.events.cta,
})

View file

@ -378,6 +378,7 @@ export default function AdminPanel() {
value={row.role}
disabled={locked || busy || fromGroup}
onChange={(e) => changeRole(row, e.target.value)}
aria-label={`Role for ${row.name || row.email}`}
className="border border-brand/30 bg-surface px-2 py-1 text-sm text-ink disabled:cursor-not-allowed disabled:bg-tint-soft disabled:text-muted/60"
title={
fromGroup

View file

@ -149,6 +149,7 @@ export default function EntityList() {
type="search"
value={query}
placeholder="Search"
aria-label="Search"
onChange={(e) => setQuery(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && setParam("q", query.trim())}
className="border border-muted/25 bg-surface px-4 py-1.5 text-sm text-body outline-none focus:border-brand"

View file

@ -3,7 +3,9 @@
Every published event on a month grid, or as a list of the month.
Self contained like EventListCards: give it a filter and it
fetches, so it can sit on any page.
fetches, so it can sit on any page. It asks only for the six
weeks on screen (eventData.ts, from/to), so paging months costs
one small request each, not the whole history up front.
<EventCalendar /> everything
<EventCalendar host="northwest" /> one host's calendar
@ -40,7 +42,7 @@
═══════════════════════════════════════════════════════════════ */
import { ArrowRight, ArrowLeft, CaretRight, CaretLeft } from '@phosphor-icons/react'
import { useMemo, useState, type ReactNode } from 'react'
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import { Link } from 'react-router-dom'
import { typesPresent, useEvents } from '../../lib/eventData.ts'
@ -232,10 +234,24 @@ export default function EventCalendar({
controls = ALL_CONTROLS,
defaultView = 'month',
}: EventCalendarProps) {
const { events: pinned, scopes, loading, error } = useEvents({ scope, host, status, type })
const today = iso(new Date())
const [month, setMonth] = useState(monthKey(today))
// Only the six weeks on screen come from the server; the last
// month's events stay up while the next month's arrive.
const weeks = useMemo(() => gridFor(month), [month])
const gridFrom = weeks[0][0]
const gridTo = weeks[5][6]
const monthFrom = `${month}-01`
const monthTo = addDays(`${shiftMonth(month, 1)}-01`, -1)
const { events: pinned, scopes, ready, loading, error } = useEvents({
scope,
host,
status,
type,
from: gridFrom,
to: gridTo,
})
const [view, setView] = useState<CalendarView>(defaultView)
const [selected, setSelected] = useState<string | null>(null)
@ -248,15 +264,19 @@ export default function EventCalendar({
const showScope = show('scope') && !scope
const showType = show('type') && !type
const types = useMemo(() => typesPresent(pinned, EVENT_TYPES), [pinned])
// What this window holds, plus whatever is picked, so a choice
// doesn't vanish from its own dropdown on a quieter month.
const types = useMemo(
() => EVENT_TYPES.filter((t) => t.id === kind || typesPresent(pinned, [t]).length > 0),
[pinned, kind],
)
const scopeOptions = useMemo(() => {
const present = new Set(pinned.map((e) => e.scope_id))
return scopes.filter((s) => present.has(s.id))
}, [pinned, scopes])
return scopes.filter((s) => present.has(s.id) || s.id === pickedScope)
}, [pinned, scopes, pickedScope])
const events = useMemo(() => {
const needle = query.trim().toLowerCase()
return pinned.filter((e) => {
const matches = (e: EventListItem) => {
if (pickedScope && e.scope_id !== pickedScope) return false
if (kind && e.event_type !== kind) return false
if (onlineOnly && !e.is_online) return false
@ -274,14 +294,8 @@ export default function EventCalendar({
if (!haystack.includes(needle)) return false
}
return true
})
}, [pinned, pickedScope, kind, onlineOnly, query])
const weeks = useMemo(() => gridFor(month), [month])
const gridFrom = weeks[0][0]
const gridTo = weeks[5][6]
const monthFrom = `${month}-01`
const monthTo = addDays(`${shiftMonth(month, 1)}-01`, -1)
}
const events = useMemo(() => pinned.filter(matches), [pinned, pickedScope, kind, onlineOnly, needle])
const occurrences = useMemo(
() => occurrencesIn(events, gridFrom, gridTo),
@ -290,7 +304,13 @@ export default function EventCalendar({
const inMonth = occurrences.filter((o) => o.end >= monthFrom && o.start <= monthTo)
const undated = events.filter((e) => !e.starts_on).length
const filtering = Boolean(pickedScope || kind || onlineOnly || query)
const next = inMonth.length === 0 ? nextDateAfter(events, monthTo) : null
// An empty month offers a jump to the next event, so then (and only
// then) everything from the month's end on is fetched to find it.
const { events: later } = useEvents(
ready && !loading && inMonth.length === 0 ? { scope, host, status, type, from: addDays(monthTo, 1) } : null,
)
const next = inMonth.length === 0 ? nextDateAfter(later.filter(matches), monthTo) : null
const onDay = (date: string) => occurrences.filter((o) => o.start <= date && o.end >= date)
@ -421,7 +441,7 @@ export default function EventCalendar({
<p className="bg-surface p-6 text-danger">
Couldn’t load events. {error.message}
</p>
) : loading ? (
) : !ready ? (
<div className="h-[32rem] animate-pulse bg-tint" aria-hidden="true" />
) : (
<>
@ -532,6 +552,7 @@ function MonthGrid({ weeks, month, today, occurrences, selected, onSelect, accen
key={date}
type="button"
onClick={() => onSelect(date)}
data-calendar-day={date}
aria-pressed={isSelected}
aria-label={`${longDay(date)}${count ? `, ${count} event${count === 1 ? '' : 's'}` : ''}`}
className="relative flex flex-col items-start border-r border-brand/10 p-2 text-left transition-colors last:border-r-0 hover:bg-tint-soft"
@ -596,6 +617,7 @@ function Bar({ seg, accent }: { seg: Segment; accent: string }) {
>
{seg.continuesBefore && <ArrowLeft size="1em" weight="bold" className="inline align-[-0.125em]" aria-hidden="true" />}
<span className="truncate">
{canceled && <span className="sr-only">Canceled: </span>}
{seg.time && seg.span === 1 && <span className="font-normal opacity-85">{seg.time.split(' – ')[0]} </span>}
{seg.event.title}
</span>
@ -621,13 +643,28 @@ function DayPanel({
accent: string
onClose: () => void
}) {
// Opening a day takes focus to its list, which sits below the
// whole grid; closing it takes focus back to the day.
const panelRef = useRef<HTMLDivElement>(null)
const headingRef = useRef<HTMLHeadingElement>(null)
useEffect(() => {
headingRef.current?.focus()
}, [date])
const close = () => {
const day = panelRef.current?.parentElement?.querySelector<HTMLElement>(`[data-calendar-day="${date}"]`)
onClose()
day?.focus()
}
return (
<div className="mt-4 border bg-surface p-6" style={{ borderColor: `${withAlpha(accent, 25)}`}}>
<div ref={panelRef} className="mt-4 border bg-surface p-6" style={{ borderColor: `${withAlpha(accent, 25)}`}}>
<div className="flex items-center gap-4">
<h4 className="font-display text-lg font-bold">{longDay(date)}</h4>
<h4 ref={headingRef} tabIndex={-1} className="font-display text-lg font-bold outline-none">
{longDay(date)}
</h4>
<button
type="button"
onClick={onClose}
onClick={close}
className="ml-auto text-sm font-semibold hover:underline"
style={{ color: accentText(accent) }}
>

View file

@ -86,6 +86,11 @@ const PAST_PEEK = "10rem";
const PAST_PAGE = 12;
const PAST_FADE = "linear-gradient(to bottom, black 0%, black 45%, transparent 100%)";
/* How far back the carousel goes: its most recent past events only
(the server leaves the rest out). The grid's past list pages
through them all. */
const CAROUSEL_PAST = 12;
/* ── Carousel sizing ──────────────────────────────────────────
CARD the card itself
GAP space between cards, raise to push neighbors out
@ -458,6 +463,7 @@ export default function EventListCards({
host,
status,
type,
past: view === "carousel" ? CAROUSEL_PAST : undefined,
});
const cardColor = defaultColor ?? accent;
@ -511,7 +517,8 @@ export default function EventListCards({
setIndex(first === -1 ? events.length - 1 : first);
}, [events]);
// Grid view splits the list; the carousel still shows everything.
// Grid view splits the list; the carousel shows it all (the
// upcoming ones and its CAROUSEL_PAST most recent past ones).
// The list comes oldest first; the past grid reads newest first.
const { upcoming, past } = splitByStatus(events);
const pastEvents = past.reverse();
@ -719,18 +726,18 @@ export default function EventListCards({
<>
<button
onClick={prev}
disabled={index === 0}
aria-disabled={index === 0}
aria-label="Previous event"
className="absolute left-2 md:left-6 top-1/2 -translate-y-1/2 z-10 h-12 w-12 btn hidden sm:flex items-center justify-center text-2xl shadow-lg transition-all duration-200 hover:scale-110 disabled:hover:scale-100"
className="absolute left-2 md:left-6 top-1/2 -translate-y-1/2 z-10 h-12 w-12 btn hidden sm:flex items-center justify-center text-2xl shadow-lg transition-all duration-200 hover:scale-110 aria-disabled:hover:scale-100"
style={arrowStyle(index > 0)}
>
<CaretLeft size={20} weight="bold" aria-hidden="true" />
</button>
<button
onClick={next}
disabled={index === events.length - 1}
aria-disabled={index === events.length - 1}
aria-label="Next event"
className="absolute right-2 md:right-6 top-1/2 -translate-y-1/2 z-10 h-12 w-12 btn hidden sm:flex items-center justify-center text-2xl shadow-lg transition-all duration-200 hover:scale-110 disabled:hover:scale-100"
className="absolute right-2 md:right-6 top-1/2 -translate-y-1/2 z-10 h-12 w-12 btn hidden sm:flex items-center justify-center text-2xl shadow-lg transition-all duration-200 hover:scale-110 aria-disabled:hover:scale-100"
style={arrowStyle(index < events.length - 1)}
>
<CaretRight size={20} weight="bold" aria-hidden="true" />
@ -745,7 +752,7 @@ export default function EventListCards({
so they move down here, beside the dots. */}
<button
onClick={prev}
disabled={index === 0}
aria-disabled={index === 0}
aria-label="Previous event"
className="btn flex h-10 w-10 items-center justify-center sm:hidden"
style={arrowStyle(index > 0)}
@ -776,7 +783,7 @@ export default function EventListCards({
))}
<button
onClick={next}
disabled={index === events.length - 1}
aria-disabled={index === events.length - 1}
aria-label="Next event"
className="btn flex h-10 w-10 items-center justify-center sm:hidden"
style={arrowStyle(index < events.length - 1)}

View file

@ -22,6 +22,7 @@ import { PAGE_LINKS } from "../../navConfig.ts";
import { useNavSections, type NavSection } from "../../lib/navSections.ts";
import { DATA_REQUEST, FEEDBACK_TYPES } from "../../data/feedbackTypes.ts";
import { accentText, BRAND } from '../../lib/color.ts'
import { focusOnMount } from '../../lib/focus.ts'
const MUTED = "var(--color-muted)";
const MAX_CHARS = 1500;
@ -112,6 +113,7 @@ export function TilePicker({
options,
value,
onChange,
error,
}: {
legend: string;
blurb: string;
@ -119,9 +121,12 @@ export function TilePicker({
options: { id: string; label: string; hint: string }[];
value: string | null;
onChange: (id: string) => void;
/** Shown under the tiles and read with each one. */
error?: string;
}) {
const errorId = `${name}-error`;
return (
<fieldset>
<fieldset aria-describedby={error ? errorId : undefined}>
<legend className="text-base font-semibold text-body">{legend}</legend>
<p className="mt-1 text-sm" style={{ color: MUTED }}>
{blurb}
@ -138,6 +143,8 @@ export function TilePicker({
value={type.id}
checked={selected}
onChange={() => onChange(type.id)}
aria-invalid={Boolean(error)}
aria-describedby={error ? errorId : undefined}
className="peer sr-only"
/>
<span
@ -169,6 +176,7 @@ export function TilePicker({
);
})}
</div>
<FieldError id={errorId}>{error}</FieldError>
</fieldset>
);
}
@ -318,7 +326,12 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
aria-live="polite"
className="border border-brand/20 bg-surface p-8 sm:p-10"
>
<h3 className="text-2xl font-bold" style={{ color: accentText(BRAND) }}>
<h3
ref={focusOnMount}
tabIndex={-1}
className="text-2xl font-bold outline-none"
style={{ color: accentText(BRAND) }}
>
Thanks, we've got it
</h3>
{where && (

View file

@ -181,17 +181,35 @@ function Tile({
setSelected(at === ids.length - 1 ? null : ids[at + 1]);
};
const name = `${AREA_NAMES[code] || code}: ${slices.map(s => s.name).join(" / ")}${
count ? ` · ${count} group${count > 1 ? "s" : ""}` : ""
}`;
// A tile with groups is a button for the keyboard too (Enter or
// Space, as a click); the empty ones stay out of the Tab order,
// which would otherwise cross every state.
return (
<g
onClick={cycle}
onMouseEnter={() => setHovered(primary.regionId)}
onMouseLeave={() => setHovered(null)}
{...(count
? {
role: "button",
tabIndex: 0,
"aria-label": name,
onFocus: () => setHovered(primary.regionId),
onBlur: () => setHovered(null),
onKeyDown: (e) => {
if (e.key !== "Enter" && e.key !== " ") return;
e.preventDefault();
cycle();
},
}
: {})}
style={{ cursor: "pointer" }}
>
<title>
{AREA_NAMES[code] || code}: {slices.map(s => s.name).join(" / ")}
{count ? ` · ${count} group${count > 1 ? "s" : ""}` : ""}
</title>
<title>{name}</title>
<clipPath id={clipId}>
<rect x={x} y={y} width={width} height={size} />

View file

@ -23,6 +23,7 @@ import { accentText, BRAND } from "../../lib/color.ts";
import { REQUEST_FILES } from "../../lib/site.ts";
import { REQUEST_TYPES, type RequestAction } from "../../data/requestTypes.ts";
import { FieldError, MinimumNote, OptionalTag, RequiredTag, TilePicker, errorFieldClass, fieldClass } from "./FeedbackForm.tsx";
import { focusOnMount } from "../../lib/focus.ts";
const MUTED = "var(--color-muted)";
const MAX_CHARS = 5000;
@ -137,7 +138,12 @@ export default function RequestForm() {
if (status === "sent") {
return (
<div aria-live="polite" className="border border-brand/20 bg-surface p-8 sm:p-10">
<h3 className="text-2xl font-bold" style={{ color: accentText(BRAND) }}>
<h3
ref={focusOnMount}
tabIndex={-1}
className="text-2xl font-bold outline-none"
style={{ color: accentText(BRAND) }}
>
Thanks, we've got it
</h3>
<p className="mt-3 max-w-prose" style={{ color: MUTED }}>
@ -163,11 +169,11 @@ export default function RequestForm() {
options={REQUEST_TYPES}
value={category}
onChange={pick}
error={fieldErrors.category}
/>
<FieldError id="request-category-error">{fieldErrors.category}</FieldError>
{type && type.actions.length > 1 && (
<fieldset className="mt-8">
<fieldset className="mt-8" aria-describedby={fieldErrors.action ? "request-action-error" : undefined}>
<legend className="text-base font-semibold text-body">New, or an update?</legend>
<div className="mt-3 flex flex-wrap gap-3">
{type.actions.map((a) => (
@ -178,6 +184,8 @@ export default function RequestForm() {
value={a}
checked={action === a}
onChange={() => setAction(a)}
aria-invalid={Boolean(fieldErrors.action)}
aria-describedby={fieldErrors.action ? "request-action-error" : undefined}
className="peer sr-only"
/>
<span
@ -214,6 +222,7 @@ export default function RequestForm() {
maxLength={200}
value={subject}
onChange={(e) => setSubject(e.target.value)}
aria-required="true"
aria-invalid={Boolean(fieldErrors.subject)}
aria-describedby={fieldErrors.subject ? "request-subject-error" : undefined}
className={`mt-3 ${fieldClass} ${fieldErrors.subject ? errorFieldClass : ""}`}
@ -283,6 +292,7 @@ export default function RequestForm() {
? "What's there now, and what it should say instead."
: (PLACEHOLDER[type.id] ?? "Everything we'd need to add it: a description, links, and who to contact.")
}
aria-required="true"
aria-invalid={Boolean(fieldErrors.message)}
aria-describedby={fieldErrors.message ? "request-message-error" : undefined}
className={`mt-3 resize-y ${fieldClass} ${fieldErrors.message ? errorFieldClass : ""}`}

View file

@ -45,6 +45,8 @@ import DoveMark from '../../../components/DoveMark.tsx'
import PlatformIcon from '../../../components/PlatformIcon.tsx'
import { livestreamEmbedUrl, videoSource, type VideoSource } from '../../../lib/embeds.ts'
import { mediaUrl } from '../../../lib/media.ts'
import { prefersLessMotion } from '../../../lib/motion.ts'
import { focusOnMount } from '../../../lib/focus.ts'
import { eventHref } from '../../../lib/hrefs.ts'
import { seriesLabel } from '../../../lib/eventSeries.ts'
import type { Hero, HeroBackdrop, HeroEvent, HeroFeature, HeroSlide } from '../../../lib/useFrontPage.ts'
@ -263,7 +265,8 @@ function BrandBackdrop() {
function PhotoBackdrop({ slides, seconds }: { slides: HeroSlide[]; seconds: number }) {
const [index, setIndex] = useState(0)
const [paused, setPaused] = useState(false)
// Starts paused for anyone who asked for less motion; Play is there.
const [paused, setPaused] = useState(prefersLessMotion)
const ms = Math.max(3, seconds) * 1000
const current = slides[index % slides.length]
@ -370,6 +373,7 @@ function LiveFrame({ src, url, title }: { src: string | null; url: string; title
<div className="aspect-video w-full">
{src && watching ? (
<iframe
ref={focusOnMount}
src={src}
title={title || 'Livestream'}
className="h-full w-full"
@ -459,7 +463,7 @@ function VideoFrame({
it's usually Register. */
function EventPanel({ event }: { event: HeroEvent }) {
const color = event.color || 'var(--color-action)'
const photo = mediaUrl(event.card_image)
const photo = mediaUrl(event.photo)
const when = seriesLabel(event.series, event.starts_on) ?? event.date_label
const where = event.is_online && !event.location_label ? 'Online' : event.location_label
@ -469,11 +473,11 @@ function EventPanel({ event }: { event: HeroEvent }) {
style={{ boxShadow: '0 24px 48px -24px rgba(0, 16, 17, 0.6)' }}
>
{photo ? (
<img src={photo} alt="" className="aspect-[16/7] w-full object-cover" />
<img src={photo} alt={event.photo_alt ?? ''} className="aspect-video w-full object-cover" />
) : (
<div
aria-hidden="true"
className="aspect-[16/7] w-full"
className="aspect-video w-full"
style={{ background: `color-mix(in srgb, ${color} 35%, #001011)` }}
/>
)}

View file

@ -93,7 +93,7 @@ export default function NextEventCountdown({
<p className="text-xs font-bold uppercase tracking-[0.25em]" style={{ color: accentText(accent) }}>
{live ? 'Happening now' : 'Next up'}
</p>
<p className="mt-1 truncate font-display text-2xl font-bold text-ink md:text-3xl">
<p className="mt-1 line-clamp-2 break-words font-display text-2xl font-bold text-ink md:text-3xl">
{event.title}
</p>
<p className="mt-1 text-sm text-muted">
@ -104,7 +104,9 @@ export default function NextEventCountdown({
</div>
{!live && (
<div className="flex gap-2 md:gap-3" role="timer" aria-live="off">
// Out of the link's name, which would otherwise change every
// second; the date above says when.
<div className="flex gap-2 md:gap-3" aria-hidden="true">
{parts.map(([label, value]) => (
<div
key={label}

View file

@ -12,6 +12,7 @@
import { useEffect, useRef, useState } from 'react'
import type { FrontPageStat } from '../../../lib/useFrontPage.ts'
import { prefersLessMotion } from '../../../lib/motion.ts'
const COUNT_MS = 1400
@ -86,9 +87,7 @@ function CountUp({ value, run }: { value: string; run: boolean }) {
const decimals = value.split('.')[1]?.length ?? 0
const grouped = value.includes(',')
const reduced =
typeof window !== 'undefined' &&
window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
const reduced = typeof window !== 'undefined' && prefersLessMotion()
const [shown, setShown] = useState(0)