Accessibility: reading mode for every page, full color blind palettes (v1.12.1-accessibility) #26

Merged
ngu-git-admin merged 4 commits from accessibility into main 2026-10-04 04:30:55 +01:00
24 changed files with 788 additions and 180 deletions
Showing only changes of commit 27e5fbd690 - Show all commits

View file

@ -279,7 +279,7 @@ The numbers band's "Number Source" dropdown works the same way:
| The icons a Front page "Find your way in" path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. |
| A page section's accent color | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a color there, not a hex in a page. Each is readable as text on white and the tints. |
| The palette (the 16-color grid the theme is drawn from) | `PALETTE` in `src/lib/color.ts` | Four families, a column each. `PALETTE_LIGHT` / `PALETTE_DARK` are the fills things colored by data use (a person's initials tile, `paletteFill`); the page background's layers (how many circles, their sizes and parallax speeds) are `LAYERS` in `src/components/PageBackdrop.tsx` and its shades are in `PageBackdrop.css`; the admin home's two alternating group colors are `BLOCK_COLORS` in `src/pages/admin/AdminHome.tsx`. |
| The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `<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 replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal-<family>-<shade>)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. A part it can't read well draws its own text version when `useReadingMode()` (`src/lib/readingMode.ts`) is on: the stats band, the calendar (the next six weeks as a list) and the featured cards; the countdown draws nothing. Something saved or sent (the newsletter's colors) uses `STORED_PALETTE`, which is never swapped. |
| The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `<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 replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal-<family>-<shade>)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. A part it can't read well (a carousel, tabs, details behind a click, a map) draws its own text version when `useReadingMode()` (`src/lib/readingMode.ts`) is on: the hero, pathfinder, stats, history rail, event lists, calendar (the next six weeks), featured cards, org lists and groups map, history timeline, schedule, people tiles and video player; the countdown draws nothing. A new component with any of those should do the same. 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

@ -35,6 +35,10 @@
"Formatted" is InlineText.tsx: **bold**, *italic*, [text](url),
line breaks, and a blank line for a new paragraph.
Reading mode (readingMode.ts): a linked image with no alt text
is a line linking with its caption, and a video's caption is its
link (VideoPlayer), not said twice.
An unknown `type` renders its text as a paragraph rather than
disappearing. A block somebody typed into the admin should be
visible even if the renderer hasn't caught up with it.
@ -50,6 +54,7 @@ import { accentText, BRAND } from '../lib/color.ts'
import { headingAnchors } from '../lib/contents.ts'
import { SITE_NAME } from '../lib/site.ts'
import { useSmallImage } from '../lib/useSmallImage.ts'
import { useReadingMode } from '../lib/readingMode.ts'
const BODY = 'var(--color-muted)'
@ -66,11 +71,20 @@ export default function ContentBlocks({
// Headings get ids so a post's contents (PostContents) and a shared
// link (#getting-there) can point at them.
const { idAt } = headingAnchors(blocks)
// The heading level a block's own headings take: under the last
// heading (h3) or subheading (h4) before it, else the section's h2.
let under = 2
const levels = blocks.map((block) => {
const level = (under + 1) as 3 | 4 | 5
if (block.type === 'heading') under = 3
if (block.type === 'subheading') under = 4
return level
})
return (
<div className={`space-y-6 ${className}`}>
{blocks.map((block, index) => (
<Block key={block.id ?? index} block={block} accent={accent} anchor={idAt.get(index)} />
<Block key={block.id ?? index} block={block} accent={accent} anchor={idAt.get(index)} level={levels[index]} />
))}
</div>
)
@ -135,8 +149,19 @@ function Caption({ text }: { text?: string | null }) {
)
}
function Block({ block, accent, anchor }: { block: ContentBlock; accent: string; anchor?: string }) {
function Block({
block,
accent,
anchor,
level,
}: {
block: ContentBlock
accent: string
anchor?: string
level: 3 | 4 | 5
}) {
const text = block.text ?? ''
const reading = useReadingMode()
switch (block.type) {
case 'heading':
@ -294,6 +319,14 @@ function Block({ block, accent, anchor }: { block: ContentBlock; accent: string;
case 'image': {
const src = mediaUrl(block.media)
if (!src) return null
// The reader leaves out a picture with no alt, and its link with it.
if (reading && block.href && !block.alt) {
return (
<p>
<Anchor href={block.href}>{text || 'Open link'}</Anchor>
</p>
)
}
const img = (
<img
src={src}
@ -320,7 +353,7 @@ function Block({ block, accent, anchor }: { block: ContentBlock; accent: string;
<div className="overflow-hidden">
<VideoPlayer url={block.href} still={mediaUrl(block.media)} title={text || null} />
</div>
<Caption text={text} />
{!reading && <Caption text={text} />}
</figure>
)
@ -335,8 +368,8 @@ function Block({ block, accent, anchor }: { block: ContentBlock; accent: string;
if (!block.team_id && picked.length === 0) return null
return (
<div className="space-y-6">
{block.team_id && <PeopleTiles size="lg" teams={block.team_id} accent={accent} />}
{picked.length > 0 && <PeopleTiles size="lg" people={picked} accent={accent} />}
{block.team_id && <PeopleTiles size="lg" teams={block.team_id} accent={accent} headingLevel={level} />}
{picked.length > 0 && <PeopleTiles size="lg" people={picked} accent={accent} headingLevel={level} />}
</div>
)
}

View file

@ -25,7 +25,8 @@
longer stretches its neighbor.
Reading mode (readingMode.ts) gets each card as a linked heading
and its words, a video card linking to its video.
and its words, a video card linking to its video. `level` is that
heading's level, one under the heading above the cards.
═══════════════════════════════════════════════════════════════ */
@ -84,8 +85,9 @@ function VideoPicture({ card }: { card: FeaturedCard }) {
const RULE = 'border-brand'
function Card({ card, large }: { card: FeaturedCard; large: boolean }) {
function Card({ card, large, level }: { card: FeaturedCard; large: boolean; level: 3 | 4 }) {
const href = hrefFor(card)
const Title = level === 4 ? 'h4' : 'h3'
const text = (
<div className={`flex flex-1 flex-col ${large ? 'p-8 md:p-10' : 'p-7'}`}>
@ -93,7 +95,7 @@ function Card({ card, large }: { card: FeaturedCard; large: boolean }) {
<p className="text-sm font-semibold text-link">{card.eyebrow}</p>
)}
{card.title && (
<h3 className={`mt-2 font-display font-bold leading-snug text-ink ${large ? 'text-2xl md:text-3xl' : 'text-lg'}`}>
<Title className={`mt-2 font-display font-bold leading-snug text-ink ${large ? 'text-2xl md:text-3xl' : 'text-lg'}`}>
{href ? (
// Stretched over the whole card, so the picture and the
// blurb are part of the click without nesting links.
@ -106,7 +108,7 @@ function Card({ card, large }: { card: FeaturedCard; large: boolean }) {
) : (
card.title
)}
</h3>
</Title>
)}
{card.blurb && (
<p className={`mt-2 leading-relaxed text-muted ${large ? '' : 'line-clamp-3 text-sm'}`}>{card.blurb}</p>
@ -135,7 +137,10 @@ function Card({ card, large }: { card: FeaturedCard; large: boolean }) {
)
}
function ReadingCards({ cards }: { cards: FeaturedCard[] }) {
type FeaturedCardsProps = { cards: FeaturedCard[]; level?: 3 | 4 }
function ReadingCards({ cards, level = 3 }: FeaturedCardsProps) {
const Title = level === 4 ? 'h4' : 'h3'
return (
<>
{cards.map((card, index) => {
@ -143,7 +148,7 @@ function ReadingCards({ cards }: { cards: FeaturedCard[] }) {
return (
<div key={`${card.kind}-${card.ref?.id ?? card.url}-${index}`}>
{card.eyebrow && <p>{card.eyebrow}</p>}
{card.title && <h3>{href ? <HomeLink url={href}>{card.title}</HomeLink> : card.title}</h3>}
{card.title && <Title>{href ? <HomeLink url={href}>{card.title}</HomeLink> : card.title}</Title>}
{card.blurb && <p>{card.blurb}</p>}
</div>
)
@ -152,9 +157,9 @@ function ReadingCards({ cards }: { cards: FeaturedCard[] }) {
)
}
export default function FeaturedCards({ cards }: { cards: FeaturedCard[] }) {
export default function FeaturedCards({ cards, level = 3 }: FeaturedCardsProps) {
const reading = useReadingMode()
if (reading) return <ReadingCards cards={cards} />
if (reading) return <ReadingCards cards={cards} level={level} />
const leadLarge = cards.length >= 3
return (
<div className="overflow-hidden shadow-md">
@ -164,6 +169,7 @@ export default function FeaturedCards({ cards }: { cards: FeaturedCard[] }) {
key={`${card.kind}-${card.ref?.id ?? card.url}-${index}`}
card={card}
large={leadLarge && index === 0}
level={level}
/>
))}
</ul>

View file

@ -5,11 +5,20 @@
filled in its accent, then its website, email and socials
outlined. Nothing at all when it has none. Used on an
organization's page and on the Organization page (NGU's own).
A platform's icon has its name beside it for screen readers and
reading mode, unless the label already says it (PlatformName).
═══════════════════════════════════════════════════════════════ */
import PlatformIcon from './PlatformIcon.tsx'
import type { OrganizationRecord } from '../lib/useContent.ts'
import { accentText } from '../lib/color.ts'
import { PLATFORMS } from '../lib/platforms.ts'
function PlatformName({ platform, label }: { platform?: string | null; label?: string | null }) {
const name = PLATFORMS.find((p) => p.id === platform)?.label
if (!name || label?.toLowerCase().includes(name.toLowerCase())) return null
return <span className="sr-only">{label ? `${name}: ` : name}</span>
}
export default function OrgContact({ org, accent }: { org: OrganizationRecord; accent: string }) {
const hasAny =
@ -29,6 +38,7 @@ export default function OrgContact({ org, accent }: { org: OrganizationRecord; a
style={{ background: accent }}
>
<PlatformIcon platform={link.platform} />
<PlatformName platform={link.platform} label={link.label} />
{link.label}
</a>
))}
@ -51,6 +61,7 @@ export default function OrgContact({ org, accent }: { org: OrganizationRecord; a
style={{ borderColor: accent, color: accentText(accent) }}
>
<PlatformIcon platform={link.platform} />
<PlatformName platform={link.platform} label={link.label} />
{link.label}
</a>
))}

View file

@ -18,6 +18,7 @@ import { isBadId, personHref } from "../lib/hrefs.ts";
import { mediaUrl, initials } from "../lib/media.ts";
import { useSmallImage } from "../lib/useSmallImage.ts";
import { paletteFill } from "../lib/color.ts";
import { useReadingMode } from "../lib/readingMode.ts";
import "./PeopleTiles.css";
/**
@ -71,6 +72,10 @@ import "./PeopleTiles.css";
* with no photo gets their initials on a palette color
* (paletteFill in color.ts).
*
* Reading mode (readingMode.ts) gets everyone, no "Show all", each
* a heading (linked to their profile) and their title, facts and bio
* as lines (ReadingPeople).
*
* Field names follow the API (is_owner, location_label), so a row
* from /api/teams/:id/people drops in unchanged.
*
@ -122,7 +127,8 @@ export interface PeopleGroupInput extends Omit<PeopleGroup, "people"> {
export interface TeamSpec {
id: string;
/** Heading for the members group. Defaults to the team's name. */
/** Heading for the members group beside a lead group, or among
* several teams. Defaults to the team's name. */
label?: string;
/** Heading for the lead group. Defaults to the lead's own title. */
leadLabel?: string;
@ -146,6 +152,9 @@ export interface PeopleTilesProps
align?: "start" | "center";
accent?: string;
tilt?: boolean;
/** The group labels' heading level, by what they sit under (3 under
* a section's h2). In reading mode the names are one level under. */
headingLevel?: 3 | 4 | 5;
/** How long a fetched team or person is reused, in ms. */
ttl?: number;
emptyMessage?: string;
@ -372,8 +381,10 @@ function buildTeamGroups(
return [
{
id: data.team.id,
// One unlabeled team needs no heading; several always do.
label: teamCount > 1 || spec.label ? name : undefined,
// One team alone needs no heading (its page or section names
// it); several always do. `label` names the members beside a
// lead group.
label: teamCount > 1 ? name : undefined,
accent,
people: data.people,
},
@ -408,6 +419,7 @@ export function PeopleTilesView({
accent,
tilt = false,
emptyMessage = "No one listed yet.",
headingLevel = 3,
onExpand,
className = "",
style,
@ -426,6 +438,7 @@ export function PeopleTilesView({
const [clipped, setClipped] = useState<ReadonlySet<string>>(() => new Set());
const rootRef = useRef<HTMLDivElement>(null);
const probeRef = useRef<HTMLSpanElement>(null);
const reading = useReadingMode();
const resolvedSize: PeopleTilesSize = SIZE_FEATURES[size] ? size : "md";
const features = SIZE_FEATURES[resolvedSize];
@ -532,6 +545,8 @@ export function PeopleTilesView({
if (!resolvedGroups.length) {
return emptyMessage ? <p className="pl__empty">{emptyMessage}</p> : null;
}
if (reading) return <ReadingPeople groups={resolvedGroups} level={headingLevel} />;
const Label = `h${headingLevel}` as "h3";
const open = openKey ? findByKey(resolvedGroups, openKey) : null;
const oneRow =
@ -598,7 +613,7 @@ export function PeopleTilesView({
>
{(group.label || group.note) && (
<header className="pl__group-head">
{group.label && <h3 className="pl__group-label">{group.label}</h3>}
{group.label && <Label className="pl__group-label">{group.label}</Label>}
{group.note && <p className="pl__group-note">{group.note}</p>}
</header>
)}
@ -883,6 +898,52 @@ function DetailPanel({
);
}
/* Reading mode: every person and what their details panel says. */
function ReadingPeople({ groups, level }: { groups: PeopleGroup[]; level: 3 | 4 | 5 }) {
const Label = `h${level}` as "h3";
return (
<div>
{groups.map((group) => {
// Names sit under the group's label, or take its place.
const Name = `h${group.label ? level + 1 : level}` as "h4";
return (
<section key={group.id}>
{group.label && <Label>{group.label}</Label>}
{group.note && <p>{group.note}</p>}
{group.people.map((person, index) => {
const href = profileHref(person);
const title = titleOf(person);
const org = resolveOrg(person.org);
const bio = Array.isArray(person.bio) ? person.bio : [person.bio];
return (
<div key={keyFor(group, person, index)}>
<Name>{href ? <Link to={href}>{person.name}</Link> : person.name}</Name>
{title && <p>{title}</p>}
{person.pronouns && <p>Pronouns: {person.pronouns}</p>}
{org && (
<p>
Home organization: {org.href ? <a href={org.href}>{org.name}</a> : org.name}
</p>
)}
{person.location_label && <p>Based in: {person.location_label}</p>}
{person.public_email && (
<p>
Email: <a href={`mailto:${person.public_email}`}>{person.public_email}</a>
</p>
)}
{bio.filter(Boolean).map((paragraph, i) => (
<p key={i}>{paragraph}</p>
))}
</div>
);
})}
</section>
);
})}
</div>
);
}
function Chevron() {
return (
<CaretDown size={12} weight="bold" aria-hidden="true" />

View file

@ -14,26 +14,46 @@
h1 to h6 headings, at their level
p, li, td, quote... paragraphs, with their links
a links (a card that is one link gives its
heading the link)
heading the link, or with none its first
line or picture); an icon-only link reads
its aria-label
br a line break
a part drawn on its a line of its own: a row of facts or link
own line buttons reads one per line
form one line saying it can't be used here
img with alt text pictures; one with empty alt is decoration
(a card's faded background) and is left out
a button that opens its words, as a line: a person's tile, a
something schedule row (aria-expanded)
What's dropped: other buttons, form fields, navigation lists, video and
map frames, drawings, and anything hidden from screen readers
(aria-hidden, the copies a carousel draws for its turns).
map frames, drawings, anything hidden from screen readers
(aria-hidden, the copies a carousel draws for its turns) and
anything CSS hides (display: none, eg. a print-only footer).
Ids on sections and headings are kept, so #links still land.
What this can't do well (a carousel showing one card, tabs,
details opened by a click, a count waiting to be scrolled to) the
component draws as text itself when useReadingMode() is on.
═══════════════════════════════════════════════════════════════ */
import { useEffect, useState, type ReactNode, type RefObject } from 'react'
import { Fragment, useEffect, useState, type ReactNode, type RefObject } from 'react'
import { Link } from 'react-router-dom'
import { PAGE_LINKS } from '../navConfig.ts'
type Inline = string | { href: string; children: Inline[] }
type Block =
/* A <br> in the page, kept as a line break (an address, a poem). */
const BREAK = '
'
/* `ids` are the page's own ids on a section or heading (a section
and its heading can both have one), kept so a #link (the side
nav, a "Jump to" button) still lands. */
type Block = { ids?: string[] } & (
| { kind: 'heading'; level: number; content: Inline[] }
| { kind: 'text'; content: Inline[] }
| { kind: 'image'; src: string; alt: string }
| { kind: 'image'; src: string; alt: string; href?: string }
)
const SKIP = new Set(['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEMPLATE', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA', 'NAV', 'IFRAME', 'VIDEO', 'AUDIO', 'CANVAS', 'DIALOG', 'svg'])
const HEADINGS = new Set(['H1', 'H2', 'H3', 'H4', 'H5', 'H6'])
@ -48,7 +68,16 @@ const skipped = (el: Element) =>
(SKIP.has(el.tagName) && !opens(el)) ||
el.getAttribute('aria-hidden') === 'true' ||
el.hasAttribute('hidden') ||
['button', 'switch', 'tab', 'slider', 'presentation', 'none'].includes(el.getAttribute('role') ?? '')
['button', 'switch', 'tab', 'slider', 'presentation', 'none'].includes(el.getAttribute('role') ?? '') ||
// Hidden by CSS: a print-only footer, a phone-only copy.
getComputedStyle(el).display === 'none'
/* Drawn on a line of its own (a flex row's items, a block link): a
row of facts or link buttons reads one per line, not run together. */
const ownLine = (el: Element) => {
const display = getComputedStyle(el).display
return !display.startsWith('inline') && display !== 'contents'
}
/* A link's address as the app routes it: a path for this site, so
it opens without reloading; the full address for anywhere else. */
@ -66,9 +95,12 @@ function hrefOf(a: HTMLAnchorElement): string | null {
function inline(node: Node): Inline[] {
if (node.nodeType === Node.TEXT_NODE) return [node.textContent ?? '']
if (!(node instanceof Element) || skipped(node) || node.tagName === 'IMG') return []
if (node.tagName === 'BR') return [' ']
const children = [...node.childNodes].flatMap(inline)
if (node.tagName === 'BR') return [BREAK]
let children = [...node.childNodes].flatMap(inline)
const href = node instanceof HTMLAnchorElement ? hrefOf(node) : null
// An icon-only link (an arrow) names itself in aria-label.
const label = node.getAttribute('aria-label')
if (href && label && !textOf(children)) children = [label]
const parts: Inline[] = href ? [{ href, children }] : children
// A part the page draws on its own line (a span set to block, a
// flex row's items) has no space in its text: give it one.
@ -82,13 +114,20 @@ const isBlock = (el: Element) => opens(el) || el.matches(BLOCK_SELECTOR) || el.q
function extract(root: Element): Block[] {
const blocks: Block[] = []
// Ids waiting for the next block written, which takes them.
let pendingIds: string[] = []
const push = (block: Block) => {
blocks.push(pendingIds.length ? { ...block, ids: pendingIds } : block)
pendingIds = []
}
const text = (content: Inline[]) => {
if (textOf(content)) blocks.push({ kind: 'text', content })
if (textOf(content)) push({ kind: 'text', content })
}
function walk(el: Element, link: string | null) {
// The root is the hidden copy of the page itself: read inside it.
if (el !== root && skipped(el)) return
if (el.id && el !== root) pendingIds.push(el.id)
if (opens(el)) {
// Each part on its own line in the page (a name, a title) joins
// with a comma.
@ -98,10 +137,14 @@ function extract(root: Element): Block[] {
text([parts.join(', ')])
return
}
if (el.tagName === 'FORM') {
text(['This form can’t be filled in while reading mode is on. Turn it off (the accessibility button) to use it.'])
return
}
if (HEADINGS.has(el.tagName)) {
const content = [...el.childNodes].flatMap(inline)
if (textOf(content)) {
blocks.push({ kind: 'heading', level: Number(el.tagName[1]), content: link ? [{ href: link, children: content }] : content })
push({ kind: 'heading', level: Number(el.tagName[1]), content: link ? [{ href: link, children: content }] : content })
}
return
}
@ -109,7 +152,7 @@ function extract(root: Element): Block[] {
const img = el as HTMLImageElement
const alt = img.getAttribute('alt')?.trim()
const src = img.currentSrc || img.getAttribute('src')
if (alt && src) blocks.push({ kind: 'image', src, alt })
if (alt && src) push({ kind: 'image', src, alt, ...(link ? { href: link } : {}) })
return
}
if (TEXT_BLOCKS.has(el.tagName) && !el.querySelector('p,li,h1,h2,h3,h4,h5,h6,img')) {
@ -117,19 +160,26 @@ function extract(root: Element): Block[] {
return
}
if (el.tagName === 'TR') {
const cells = [...el.children].map((cell) => [...cell.childNodes].flatMap(inline)).filter((c) => textOf(c))
const cells = [...el.children].map((cell) => [...cell.childNodes].flatMap(inline)).map((c) => (textOf(c) ? c : ['-']))
text(cells.flatMap((cell, i) => (i ? [' · ', ...cell] : cell)))
return
}
// A link around a whole card: its parts, with the link on the first
// heading (or, with none, kept as a line of its own).
// heading; with none, on its aria-label as a line of its own, or
// else on its first line of text.
const href = el instanceof HTMLAnchorElement ? hrefOf(el) : null
if (href && isBlock(el)) {
const before = blocks.length
for (const child of el.children) walk(child, href)
if (!blocks.slice(before).some((b) => b.kind === 'heading')) {
const own = blocks.slice(before)
if (!own.some((b) => b.kind === 'heading')) {
const label = el.getAttribute('aria-label')
const first = own.findIndex((b) => b.kind === 'text')
if (label) blocks.splice(before, 0, { kind: 'text', content: [{ href, children: [label] }] })
else if (first >= 0) {
const block = blocks[before + first] as Extract<Block, { kind: 'text' }>
blocks[before + first] = { ...block, content: [{ href, children: block.content }] }
}
}
return
}
@ -142,6 +192,10 @@ function extract(root: Element): Block[] {
text(run)
run = []
walk(child, link)
} else if (child instanceof Element && !skipped(child) && ownLine(child)) {
text(run)
run = []
text(inline(child))
} else {
run.push(...inline(child))
}
@ -159,20 +213,31 @@ function extract(root: Element): Block[] {
function render(parts: Inline[]): ReactNode[] {
return parts.map((part, i) => {
if (typeof part === 'string') return part
const children = render(part.children)
return part.href.startsWith('/') ? (
<Link key={i} to={part.href}>
{children}
</Link>
) : (
<a key={i} href={part.href}>
{children}
</a>
if (typeof part === 'string') {
if (!part.includes(BREAK)) return part
return part.split(BREAK).map((line, j) => (
<Fragment key={`${i}-${j}`}>
{j > 0 && <br />}
{line}
</Fragment>
))
}
return (
<Anchor key={i} href={part.href}>
{render(part.children)}
</Anchor>
)
})
}
/* A page on this site opens without reloading; a file (an upload,
the API) or anywhere else is a plain link. */
const isFile = (href: string) => /^\/(uploads|api)\//.test(href)
function Anchor({ href, children }: { href: string; children: ReactNode }) {
return href.startsWith('/') && !isFile(href) ? <Link to={href}>{children}</Link> : <a href={href}>{children}</a>
}
export default function ReaderView({ source }: { source: RefObject<HTMLElement | null> }) {
const [blocks, setBlocks] = useState<Block[]>([])
@ -207,10 +272,37 @@ export default function ReaderView({ source }: { source: RefObject<HTMLElement |
))}
</p>
{blocks.map((block, i) => {
if (block.kind === 'image') return <img key={i} src={block.src} alt={block.alt} loading="lazy" />
if (block.kind === 'text') return <p key={i}>{render(block.content)}</p>
const [id, ...more] = block.ids ?? []
const anchors = more.map((other) => <span key={other} id={other} />)
if (block.kind === 'image') {
return (
<Fragment key={i}>
{anchors}
{block.href ? (
<Anchor href={block.href}>
<img id={id} src={block.src} alt={block.alt} loading="lazy" />
</Anchor>
) : (
<img id={id} src={block.src} alt={block.alt} loading="lazy" />
)}
</Fragment>
)
}
if (block.kind === 'text') {
return (
<p key={i} id={id}>
{anchors}
{render(block.content)}
</p>
)
}
const Heading = `h${block.level}` as 'h1'
return <Heading key={i}>{render(block.content)}</Heading>
return (
<Heading key={i} id={id}>
{anchors}
{render(block.content)}
</Heading>
)
})}
</article>
)

View file

@ -18,10 +18,14 @@
the place typed in, with a link out to the full map.
Tabs follow the ARIA tab pattern: arrow keys move between them.
Reading mode (readingMode.ts) gets every day as a heading, each
entry a line (time, title, place, person) with its fold-out after
it, no map frame (ReadingSchedule).
═══════════════════════════════════════════════════════════════ */
import { CaretDown } from '@phosphor-icons/react'
import { useId, useState, type KeyboardEvent } from 'react'
import { Fragment, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
import { Link } from 'react-router-dom'
import { personHref } from '../lib/hrefs.ts'
@ -31,6 +35,7 @@ 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'
import { useReadingMode } from '../lib/readingMode.ts'
const BODY = 'var(--color-muted)'
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
@ -215,6 +220,54 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
)
}
/* Reading mode: every day, every entry and its fold-out, as text. A
day is an h4, under the page's h3 block headings (ContentBlocks). */
function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string | null; accent: string }) {
return (
<div>
{intro && <Paragraphs text={intro} accent={accent} />}
{days.map((day, index) => (
<div key={day.name || index}>
{days.length > 1 && <h4>{day.name || 'Schedule'}</h4>}
<ul>
{day.entries.map((entry, i) => {
const graphic = mediaUrl(entry.media)
const place = entry.map?.trim()
const parts: ReactNode[] = [
entry.time,
entry.url ? <Anchor href={entry.url}>{entry.text}</Anchor> : entry.text,
entry.location,
entry.person && <Link to={personHref(entry.person.id)}>{entry.person.name}</Link>,
].filter(Boolean)
return (
<li key={i}>
<p>
{parts.map((part, j) => (
<Fragment key={j}>
{j > 0 && ' · '}
{part}
</Fragment>
))}
</p>
{entry.detail && <p>{entry.detail}</p>}
{entry.person?.tagline && <p>{entry.person.tagline}</p>}
{entry.description && <Paragraphs text={entry.description} accent={accent} />}
{graphic && <img src={graphic} alt={entry.media_alt ?? ''} />}
{place && (
<p>
<a href={mapLink(place)}>Open {place} in Google Maps</a>
</p>
)}
</li>
)
})}
</ul>
</div>
))}
</div>
)
}
export default function ScheduleBlock({
items,
intro,
@ -227,8 +280,10 @@ export default function ScheduleBlock({
const days = groupByDay(items)
const [active, setActive] = useState(() => todayIndex(days))
const baseId = useId()
const reading = useReadingMode()
if (days.length === 0) return null
if (reading) return <ReadingSchedule days={days} intro={intro} accent={accent} />
const current = days[Math.min(active, days.length - 1)]
// Arrows move one tab and wrap; Home and End jump to the ends.

View file

@ -14,6 +14,9 @@
corners, as the only rounded thing besides buttons and dots. A link that embeds.ts can't turn into a
player (not https, or not a host it knows how to frame) still
goes somewhere: the still becomes a link to it.
Reading mode (readingMode.ts) gets a link to the video (an
uploaded file's own address), named by its title.
═══════════════════════════════════════════════════════════════ */
import { Play } from '@phosphor-icons/react'
@ -23,6 +26,7 @@ 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'
import { useReadingMode } from '../lib/readingMode.ts'
export default function VideoPlayer({
@ -40,6 +44,16 @@ export default function VideoPlayer({
const [playing, setPlaying] = useState(false)
const [skipped, setSkipped] = useState(0)
const source = videoSource(url)
const reading = useReadingMode()
if (reading) {
const href = source?.kind === 'file' ? source.src : url
return href ? (
<p>
<a href={href}>{title || 'Watch the video'}</a>
</p>
) : null
}
if (playing && source) {
const live = playingSource(source)

View file

@ -54,11 +54,15 @@ function GivingPanel() {
"
style={{ backgroundColor: BRAND, "--tw-ring-color": BRAND } as React.CSSProperties}
>
Give
Give through Church Center
</a>
<p className="mt-4 text-sm text-muted">
If you would like to send a check, please email our Board Treasurer at treasurer@nextgenerationofunity.org to get an address.
If you would like to send a check, please email our Board Treasurer at{" "}
<a href="mailto:treasurer@nextgenerationofunity.org" className="text-link underline">
treasurer@nextgenerationofunity.org
</a>{" "}
to get an address.
</p>
</div>
);

View file

@ -6,7 +6,8 @@
record (GET /directory), scored by suggest.ts against the
address. So /organisation offers Organization, /retreat offers
Retreats, and an old /chapters/lynnwood offers the Lynnwood group.
Below them, the main pages to start from.
Below them, the main pages to start from, except in reading mode,
whose own line of page links (ReaderView) already gives them.
The server sends this same page with a 404 status for an unknown
address (routes/pages.js), so search engines drop it.
@ -23,6 +24,7 @@ import { useDirectory, type Directory } from '../lib/useContent.ts'
import { blogHref, eventHref, orgHref, personHref, teamHref, awardHref } from '../lib/hrefs.ts'
import { suggest, type Candidate } from '../lib/suggest.ts'
import { ACCENTS, BRAND } from '../lib/color.ts'
import { useReadingMode } from '../lib/readingMode.ts'
const ORG_KIND_LABEL: Record<string, string> = {
national: 'Organization',
@ -64,6 +66,7 @@ export default function NotFound() {
const { pathname } = useLocation()
const { data: directory, loading } = useDirectory()
const matches = useMemo(() => suggest(pathname, candidates(directory ?? null)), [pathname, directory])
const reading = useReadingMode()
return (
<PageShell
@ -103,13 +106,13 @@ export default function NotFound() {
</ul>
) : (
<p className="notice max-w-xl p-6 text-body">
Try one of the main pages below, or the menu at the top.
{reading ? 'Try one of the main pages at the top.' : 'Try one of the main pages below, or the menu at the top.'}
</p>
)}
</div>
),
},
{
...(reading ? [] : [{
id: 'start',
title: 'Start from',
accent: ACCENTS.green,
@ -126,7 +129,7 @@ export default function NotFound() {
))}
</div>
),
},
}]),
]}
/>
)

View file

@ -31,6 +31,7 @@ import { mediaUrl } from '../lib/media.ts'
import { initialsFor } from '../lib/organizations.ts'
import Logo from '../components/Logo.tsx'
import { withAlpha, accentText, readableOn, BRAND } from '../lib/color.ts'
import { useReadingMode } from '../lib/readingMode.ts'
const BODY = 'var(--color-muted)'
@ -38,6 +39,7 @@ export default function OrganizationDetail() {
const { id } = useParams()
const { pathname } = useLocation()
const { data: org, loading, error, notFound, reload } = useOrganization(id)
const reading = useReadingMode()
if (!org) {
return (
@ -143,12 +145,25 @@ export default function OrganizationDetail() {
}
if (org.awards.length > 0) {
const recipients = (count: number) =>
count === 0 ? 'No recipients yet' : `${count} recipient${count === 1 ? '' : 's'}`
sections.push({
id: 'awards',
title: 'Awards',
blurb: `Given by ${org.short_name || org.name}.`,
accent,
content: (
// Reading mode: a card reads as one long link, so each award is
// a line with its name linked.
content: reading ? (
<ul>
{org.awards.map((award) => (
<li key={award.id}>
<Link to={`/awards/${award.id}`}>{award.name}</Link>
{award.description && `: ${award.description}`} ({recipients(award.recipient_count)})
</li>
))}
</ul>
) : (
<div className="max-w-6xl mx-auto px-6 grid gap-4 sm:grid-cols-2">
{org.awards.map((award) => (
<Link
@ -166,9 +181,7 @@ export default function OrganizationDetail() {
</span>
)}
<span className="mt-3 block text-xs uppercase tracking-wide opacity-70" style={{ color: BODY }}>
{award.recipient_count === 0
? 'No recipients yet'
: `${award.recipient_count} recipient${award.recipient_count === 1 ? '' : 's'}`}
{recipients(award.recipient_count)}
</span>
</Link>
))}

View file

@ -37,6 +37,7 @@ import { mediaUrl, initials } from '../lib/media.ts'
import { eventTypeLabel } from '../lib/eventTypes.ts'
import { capitalize } from '../lib/text.ts'
import { accentText, BRAND } from '../lib/color.ts'
import { useReadingMode } from '../lib/readingMode.ts'
const BODY = 'var(--color-muted)'
@ -205,7 +206,7 @@ export default function PersonDetail() {
{(posts) => (
<ul className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
{posts.map((post) => (
<PostCard key={post.id} post={post} accent={accent} />
<PostCard key={post.id} post={post} accent={accent} level={3} />
))}
</ul>
)}
@ -231,7 +232,9 @@ function Capped<T>({
children: (shown: T[]) => ReactNode
}) {
const [all, setAll] = useState(false)
const more = !all && items.length > SHOW_FIRST
// Reading mode has no button to press: everything shows.
const reading = useReadingMode()
const more = !all && !reading && items.length > SHOW_FIRST
return (
<>
{children(more ? items.slice(0, SHOW_FIRST) : items)}
@ -253,6 +256,8 @@ function Capped<T>({
function Facts({ person, accent }: { person: PersonRecord; accent: string }) {
const photo = mediaUrl(person.photo)
// Each fact reads on a line of its own there, so it says what it is.
const reading = useReadingMode()
return (
<div className="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
@ -274,9 +279,16 @@ function Facts({ person, accent }: { person: PersonRecord; accent: string }) {
</span>
)}
{person.pronouns && <span style={{ color: BODY }}>{person.pronouns}</span>}
{person.pronouns && (
<span style={{ color: BODY }}>
{reading && 'Pronouns: '}
{person.pronouns}
</span>
)}
{person.org && (
<span>
{reading && 'Home organization: '}
<Link
to={orgHref(person.org.id, person.org.kind)}
className="font-medium hover:underline"
@ -284,12 +296,18 @@ function Facts({ person, accent }: { person: PersonRecord; accent: string }) {
>
{person.org.name}
</Link>
</span>
)}
{person.location_label && <span style={{ color: BODY }}>{person.location_label}</span>}
{person.location_label && (
<span style={{ color: BODY }}>
{reading && 'Based in: '}
{person.location_label}
</span>
)}
<Link to="/organization#leadership" className="ml-auto hover:underline" style={{ color: accentText(accent) }}>
Leadership
{reading ? 'All leadership' : 'Leadership'}
</Link>
</div>
)

View file

@ -91,7 +91,7 @@ export default function TeamDetail() {
sections.push({
id: 'members',
title: hasAbout ? 'Members' : team.name,
title: 'Members',
accent,
content: (
<div className="max-w-6xl mx-auto px-6 space-y-6">

View file

@ -35,8 +35,12 @@ const DEFAULTS = {
const EXCERPT_CHARS = 180
/* One post as a card; person pages list their posts with it too. */
export function PostCard({ post, accent }: { post: BlogPostSummary; accent: string }) {
/* One post as a card; person pages list their posts with it too.
`level` is the title's heading level, one under the heading above
the cards. The date line comes after the title in the page, so it
reads as this post's (not the one before), and is drawn above it. */
export function PostCard({ post, accent, level = 4 }: { post: BlogPostSummary; accent: string; level?: 3 | 4 }) {
const Title = level === 3 ? 'h3' : 'h4'
const cover = useSmallImage(mediaUrl(post.cover_image))
const date = postDate(post.published_on)
const authors = post.authors.map((author) => author.name).join(', ')
@ -49,19 +53,19 @@ export function PostCard({ post, accent }: { post: BlogPostSummary; accent: stri
<div className="aspect-video w-full bg-tint" />
)}
<div className="flex flex-1 flex-col p-6">
{(date || post.tags.length > 0) && (
<p className="text-sm font-semibold" style={{ color: accentText(accent) }}>
{[date, ...post.tags].filter(Boolean).join(' · ')}
</p>
)}
<h4 className="mt-2 font-display text-xl font-bold leading-snug text-ink">
<Title className="mt-2 font-display text-xl font-bold leading-snug text-ink">
<Link
to={blogHref(post.id)}
className="after:absolute after:inset-0 after:content-[''] hover:underline"
>
{post.title}
</Link>
</h4>
</Title>
{(date || post.tags.length > 0) && (
<p className="order-first text-sm font-semibold" style={{ color: accentText(accent) }}>
{[date, ...post.tags].filter(Boolean).join(' · ')}
</p>
)}
{post.excerpt && (
<p className="mt-2 leading-relaxed text-muted">{preview(post.excerpt, EXCERPT_CHARS)}</p>
)}
@ -137,7 +141,7 @@ export default function CommunityBlog({ accent = BRAND }: { accent?: string }) {
</div>
{external.cards.length > 0 && (
<div className="mt-6">
<FeaturedCards cards={external.cards} />
<FeaturedCards cards={external.cards} level={4} />
</div>
)}
</div>

View file

@ -10,6 +10,7 @@ import { mediaUrl } from "../../lib/media.ts";
import { useSmallImage } from "../../lib/useSmallImage.ts";
import Logo from "../../components/Logo.tsx";
import { accentText, withAlpha, readableOn, BRAND } from '../../lib/color.ts'
import { useReadingMode } from "../../lib/readingMode.ts";
/* ═══════════════════════════════════════════════════════════════
EVENT LIST: CARDS
@ -29,6 +30,10 @@ import { accentText, withAlpha, readableOn, BRAND } from '../../lib/color.ts'
off, the band takes every kind it finds and grows a row of chips
to narrow by, but only once it holds more than one, so a band of
nothing but retreats shows no control at all.
Reading mode (readingMode.ts) gets every event as the grid lists
them, carousel or not, with every past event shown and no
buttons to open or page through them.
═══════════════════════════════════════════════════════════════ */
@ -152,6 +157,11 @@ function TitleLink({ ev, linked, children }) {
`linked` is the one thing a caller turns off: a card on the
event's own page shouldn't link to the page it's already on.
`level` is the title's heading level, one under the heading the
card sits beneath. In reading mode the type badge (which would
read before the title, as if the last card's) and the "Event
details" link (the title already links there) are left out.
═══════════════════════════════════════════════════════════════ */
export function Card({
ev,
@ -161,7 +171,10 @@ export function Card({
interactive = true,
linked = true,
showType = false,
level = 3,
}) {
const reading = useReadingMode();
const Title = level === 4 ? "h4" : "h3";
const past = ev.status === "past";
const color = ev.color || defaultColor;
const orgLogo = mediaUrl(ev.org_logo) || DEFAULT_ORG_LOGO;
@ -177,7 +190,7 @@ export function Card({
on every card in a row of nothing but retreats is noise, and
the card can't tell on its own, it only ever sees one event. */
const typeBadge =
showType && ev.event_type ? (
showType && ev.event_type && !reading ? (
<span
className="inline-block px-3 py-0.5 mb-2 text-xs font-bold uppercase tracking-wide"
style={{ border: `1px solid ${color}`, color: INK }}
@ -222,11 +235,11 @@ export function Card({
<Logo src={orgLogo} className="ev-org h-11 w-auto mb-4" />
<div className="ev-info">
{typeBadge}
<h3 className="text-2xl sm:text-3xl font-bold leading-tight [overflow-wrap:anywhere]">
<Title className="text-2xl sm:text-3xl font-bold leading-tight [overflow-wrap:anywhere]">
<TitleLink ev={ev} linked={linked}>
{ev.title}
</TitleLink>
</h3>
</Title>
{ev.theme && (
<p className="text-lg sm:text-xl font-bold">"{ev.theme}"</p>
)}
@ -250,11 +263,11 @@ export function Card({
<div className="md:col-span-2">
<Logo src={orgLogo} className="h-15 w-auto mb-6" />
{typeBadge}
<h3 className="text-2xl sm:text-4xl font-bold [overflow-wrap:anywhere]">
<Title className="text-2xl sm:text-4xl font-bold [overflow-wrap:anywhere]">
<TitleLink ev={ev} linked={linked}>
{ev.title}
</TitleLink>
</h3>
</Title>
{ev.theme && (
<p className="text-lg sm:text-2xl font-bold">"{ev.theme}"</p>
)}
@ -338,7 +351,7 @@ export function Card({
)}
{/* Last, so Register reads first when there is one. */}
{linked && (
{linked && !reading && (
<Link
to={eventHref(ev.id)}
className={`font-bold transition-all duration-200 hover:scale-105 text-center ${
@ -471,6 +484,7 @@ export default function EventListCards({
const [showPast, setShowPast] = useState(false);
const [pastShown, setPastShown] = useState(PAST_PAGE);
const [activeType, setActiveType] = useState("all");
const reading = useReadingMode();
/* What this band holds, which is what the chips offer, not the
full list of declared types, three quarters of which would be
@ -522,7 +536,9 @@ export default function EventListCards({
// The list comes oldest first; the past grid reads newest first.
const { upcoming, past } = splitByStatus(events);
const pastEvents = past.reverse();
const pastDrawn = pastEvents.slice(0, showPast ? pastShown : MAX_COLS);
// Reading mode can't press "See past events": all of them, open.
const pastOpen = showPast || reading;
const pastDrawn = reading ? pastEvents : pastEvents.slice(0, showPast ? pastShown : MAX_COLS);
const prev = () => setIndex(i => Math.max(0, i - 1));
const next = () => setIndex(i => Math.min(events.length - 1, i + 1));
@ -595,7 +611,7 @@ export default function EventListCards({
? empty
: `· No ${eventTypeLabel(activeType).toLowerCase()} events in this section yet ·`,
)
) : view === "grid" ? (
) : view === "grid" || reading ? (
/* ── GRID VIEW: upcoming first, past events collapsed below ── */
<div className="mx-auto px-8 md:px-12 lg:px-16" style={{ maxWidth: GRID_MAX }}>
{upcoming.length > 0 && (
@ -630,16 +646,16 @@ export default function EventListCards({
<div
className="relative transition-all duration-500 ease-out"
style={{
maxHeight: showPast ? "none" : PAST_PEEK,
overflow: showPast ? "visible" : "hidden",
maskImage: showPast ? "none" : PAST_FADE,
WebkitMaskImage: showPast ? "none" : PAST_FADE,
maxHeight: pastOpen ? "none" : PAST_PEEK,
overflow: pastOpen ? "visible" : "hidden",
maskImage: pastOpen ? "none" : PAST_FADE,
WebkitMaskImage: pastOpen ? "none" : PAST_FADE,
}}
>
<div
className="grid gap-6 items-stretch"
style={{ gridTemplateColumns: GRID_TEMPLATE }}
aria-hidden={!showPast}
aria-hidden={!pastOpen}
>
{pastDrawn.map(ev => (
<Card
@ -648,13 +664,15 @@ export default function EventListCards({
defaultColor={cardColor}
accent={accent}
compact
interactive={showPast}
interactive={pastOpen}
showType={mixed}
level={4}
/>
))}
</div>
</div>
{!reading && (
<div className="flex flex-wrap justify-center gap-3 mt-6">
{showPast && pastShown < pastEvents.length && (
<button
@ -677,6 +695,7 @@ export default function EventListCards({
<CaretDown className="h-4 w-4 transition-transform duration-300" style={{ transform: showPast ? "rotate(180deg)" : "none" }} weight="bold" aria-hidden="true" />
</button>
</div>
)}
</div>
)}
</div>

View file

@ -1,4 +1,5 @@
import { ArrowUpRight } from '@phosphor-icons/react';
import { Link } from "react-router-dom";
import ArrowLink from "../../components/ArrowLink.tsx";
import OrgLogo from "../../components/OrgLogo.tsx";
import {
@ -7,6 +8,7 @@ import {
byName,
} from "../../lib/organizations.ts";
import { accentText } from '../../lib/color.ts'
import { useReadingMode } from '../../lib/readingMode.ts'
/* ═══════════════════════════════════════════════════════════════
ORGANIZATION LIST: CARDS
@ -33,9 +35,12 @@ const FALLBACK_COLOR = "#3b5456";
const CARD_MIN = "20rem";
const GRID_MAX = "88rem";
function OrgCard({ org, accent, pageLabel, siteLabel }) {
/* Under a block title the card names are a level below it. */
function OrgCard({ org, accent, pageLabel, siteLabel, titled }) {
const color = org.color || accent;
const path = orgPath(org);
const reading = useReadingMode();
const Name = titled ? "h4" : "h3";
// Tagline first, then where they are. Partners often have one and
// not the other, so this is the line that's most likely to say
@ -51,9 +56,9 @@ function OrgCard({ org, accent, pageLabel, siteLabel }) {
<OrgLogo org={org} color={color} size="h-10 w-10 sm:h-14 sm:w-14" />
<div className="min-w-0 flex-1">
<h3 className="text-lg sm:text-xl font-bold leading-tight [overflow-wrap:anywhere]" style={{ color }}>
{org.name}
</h3>
<Name className="text-lg sm:text-xl font-bold leading-tight [overflow-wrap:anywhere]" style={{ color }}>
{path ? <Link to={path}>{org.name}</Link> : org.name}
</Name>
{subtitle && (
<p className="text-sm mt-0.5" style={{ color: MUTED }}>
{subtitle}
@ -63,8 +68,9 @@ function OrgCard({ org, accent, pageLabel, siteLabel }) {
{/* Top-right rather than in the footer: the footer holds
outbound links, and the arrow goes somewhere different
in kind, deeper into this site. */}
{path && (
in kind, deeper into this site. Reading mode has the
name's link and leaves it out. */}
{path && !reading && (
<ArrowLink
to={path}
label={`${org.name}: ${pageLabel}`}
@ -135,6 +141,7 @@ function Block({ title, orgs, accent, pageLabel, siteLabel }) {
accent={accent}
pageLabel={pageLabel}
siteLabel={siteLabel}
titled={!!title}
/>
))}
</div>

View file

@ -1,5 +1,5 @@
import { CaretRight, MagnifyingGlass, X } from '@phosphor-icons/react';
import { useEffect, useMemo, useRef, useState } from "react";
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
import { useCommunity } from "../../lib/useCommunity.ts";
import { useOrganization } from "../../lib/useContent.ts";
import { Link } from "react-router-dom";
@ -9,6 +9,7 @@ import { orgPath } from "../../lib/organizations.ts";
import { AREAS, AREA_NAMES } from "../../data/mapGrid.ts";
import { accentText, readableOn } from '../../lib/color.ts'
import { scrollBehavior } from "../../lib/motion.ts";
import { useReadingMode } from "../../lib/readingMode.ts";
/* ═══════════════════════════════════════════════════════════════
ORGANIZATION LIST: MAP
@ -58,6 +59,7 @@ const GRID_CAP = 12;
const US_TITLE = "US Unity Regions";
const INTL_TITLE = "International Unity Regions";
const ONLINE_TITLE = "Online Unity Regions";
/* ── Body content ──────────────────────────────────────────────
A group's description is ordered blocks rather than one
@ -753,6 +755,65 @@ function GroupGrid({ regions, groups, groupsIn, subtextFor, openId, setOpenId })
);
}
/* ═══════════════════════════════════════════════════════════════
READING MODE
Either view as text: the regions grouped as the list groups them,
each with every one of its groups (no cap, no search), and no map.
═══════════════════════════════════════════════════════════════ */
function ReadingRegions({ domestic, international, virtual, groupsIn, subtextFor }) {
const region = r => {
const path = orgPath(r);
const subtext = subtextFor(r);
const list = groupsIn(r.id);
return (
<Fragment key={r.id}>
<h4>{path ? <Link to={path}>{r.name}</Link> : r.name}</h4>
{subtext && <p>{subtext}</p>}
{list.length === 0 ? (
<p>No groups yet. Interested in starting one?</p>
) : (
<ul>
{list.map(c => (
<li key={c.id}>
{orgPath(c) ? <Link to={orgPath(c)!}>{c.name}</Link> : c.name}
{[c.location_label, c.meets].filter(Boolean).map(part => `, ${part}`).join("")}
{c.website && (
<>
, <a href={c.website}>Website</a>
</>
)}
{c.email && (
<>
, <a href={`mailto:${c.email}`}>Contact</a>
</>
)}
</li>
))}
</ul>
)}
</Fragment>
);
};
return (
<>
{([
[US_TITLE, domestic],
[INTL_TITLE, international],
[ONLINE_TITLE, virtual],
] as [string, any[]][]).map(([title, list]) =>
list.length > 0 ? (
<Fragment key={title}>
<h3>{title}</h3>
{list.map(region)}
</Fragment>
) : null
)}
</>
);
}
/* The control for the section heading's action bar. */
export function OrgMapToggle({ view, setView, accent }) {
const btn = active => ({
@ -806,6 +867,7 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
const [hovered, setHovered] = useState<any>(null);
const [openId, setOpenId] = useState<any>(null); // no card open on arrival
const [query, setQuery] = useState("");
const reading = useReadingMode();
// The list scrolls itself to whatever the map or legend points at.
const listRef = useRef<any>(null);
@ -936,6 +998,18 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
);
}
if (reading) {
return shell(
<ReadingRegions
domestic={domestic}
international={international}
virtual={virtual}
groupsIn={groupsIn}
subtextFor={subtextFor}
/>
);
}
if (view === "grid") {
return (
<GroupGrid

View file

@ -1,5 +1,6 @@
import { ArrowUpRight, CaretRight } from '@phosphor-icons/react';
import { useId, useState } from "react";
import { Link } from "react-router-dom";
import ArrowLink from "../../components/ArrowLink.tsx";
import { mediaUrl } from "../../lib/media.ts";
import Logo from "../../components/Logo.tsx";
@ -12,6 +13,7 @@ import {
byName,
} from "../../lib/organizations.ts";
import { accentText } from '../../lib/color.ts'
import { useReadingMode } from '../../lib/readingMode.ts'
/* ═══════════════════════════════════════════════════════════════
ORGANIZATION LIST: VERTICAL
@ -78,9 +80,12 @@ function OrgMark({ org, color }) {
return <Logo src={mediaUrl(org.logo)} className="h-8 w-8 object-contain shrink-0" fallback={fallback} />;
}
function OrgRow({ org, pageLabel, siteLabel }) {
function OrgRow({ org, pageLabel, siteLabel, titled }) {
const [open, setOpen] = useState(false);
const panelId = useId();
const reading = useReadingMode();
// Under a block title the names are a level below it.
const Name = titled ? "h4" : "h3";
const color = org.color || FALLBACK_COLOR;
const path = orgPath(org);
@ -102,6 +107,14 @@ function OrgRow({ org, pageLabel, siteLabel }) {
return (
<div className="py-3" style={{ borderTop: `1px solid ${RULE}` }}>
<div className="flex flex-wrap items-center gap-3">
{/* Reading mode can't open the row (the panel reads anyway),
so the name is a heading linked to the page instead. */}
{reading ? (
<div>
<Name>{path ? <Link to={path}>{org.name}</Link> : org.name}</Name>
{summary && <p>{summary}</p>}
</div>
) : (
<button
onClick={() => setOpen(v => !v)}
aria-expanded={open}
@ -122,8 +135,8 @@ function OrgRow({ org, pageLabel, siteLabel }) {
</span>
)}
</span>
</button>
)}
<div className="flex items-center gap-2">
{org.website && (
@ -140,7 +153,7 @@ function OrgRow({ org, pageLabel, siteLabel }) {
{/* Last in the row, so the arrow lines up down the right
edge whether or not a row has an outbound site. */}
{path && (
{path && !reading && (
<ArrowLink
to={path}
label={`${org.name}: ${pageLabel}`}
@ -219,7 +232,7 @@ function Block({ title, orgs, pageLabel, siteLabel }) {
</h3>
)}
{orgs.map(org => (
<OrgRow key={org.id} org={org} pageLabel={pageLabel} siteLabel={siteLabel} />
<OrgRow key={org.id} org={org} pageLabel={pageLabel} siteLabel={siteLabel} titled={!!title} />
))}
</section>
);

View file

@ -3,6 +3,7 @@ import { MONTH_LABELS, type PersonRef, type TimelineItem } from '../../../lib/ti
import { hrefFor, logoSrc } from '../../../lib/timelineRefs.ts'
import { initials, mediaUrl } from '../../../lib/media.ts'
import { useSmallImage } from '../../../lib/useSmallImage.ts'
import { useReadingMode } from '../../../lib/readingMode.ts'
const KIND_NAMES: Record<TimelineItem['kind'], string> = {
milestone: 'Milestone',
@ -57,6 +58,7 @@ type Props = {
export default function TimelineEntry({ item, variant = 'inline' }: Props) {
const featured = variant === 'featured'
const reading = useReadingMode()
const href = hrefFor(item)
const logo = logoSrc(item)
@ -117,6 +119,23 @@ export default function TimelineEntry({ item, variant = 'inline' }: Props) {
// An explicit href may point off-site; Link is for in-app routes only.
const external = !!href && /^(https?:)?\/\//.test(href)
// Reading mode: the card's link has no heading to carry it, so the
// title would read twice and the date not at all. Plain lines instead.
if (reading) {
const title = !href ? item.title : external ? <a href={href}>{item.title}</a> : <Link to={href}>{item.title}</Link>
const facts = [item.precision === 'year' ? '' : fullMarker(item), item.meta].filter(Boolean)
return (
<li>
<p>
{title}
{facts.map((fact) => `, ${fact}`).join('')}
</p>
{item.blurb ? <p>{item.blurb}</p> : null}
{roster}
</li>
)
}
return (
<li className="site-tl__entryWrap">
{href && external ? (

View file

@ -2,6 +2,7 @@ import { CaretDown, CaretUp } from '@phosphor-icons/react'
import { useState } from 'react'
import type { GroupedYear, SortDirection } from '../../../lib/timeline.ts'
import TimelineYear from './TimelineYear.tsx'
import { useReadingMode } from '../../../lib/readingMode.ts'
type Props = {
years: GroupedYear[]
@ -28,7 +29,11 @@ export default function TimelineUpcoming({
openYears,
onToggleYear,
}: Props) {
const [open, setOpen] = useState(false)
const [chosen, setOpen] = useState(false)
// Reading mode can't press the button: the list is open, under a
// heading (its years are h4s, like a decade's) in place of it.
const reading = useReadingMode()
const open = chosen || reading
if (count === 0) return null
return (
@ -36,6 +41,7 @@ export default function TimelineUpcoming({
className={`site-tl__upcoming${open ? ' site-tl__upcoming--open' : ''}`}
aria-label="Upcoming"
>
{reading ? <h3>Still to come</h3> : (
<button
type="button"
className="site-tl__upcomingBtn"
@ -52,6 +58,7 @@ export default function TimelineUpcoming({
{open ? <CaretDown weight="bold" /> : <CaretUp weight="bold" />}
</span>
</button>
)}
{open ? (
<div className="site-tl__upcomingList">

View file

@ -1,6 +1,7 @@
import type { CSSProperties } from 'react'
import type { GroupedYear } from '../../../lib/timeline.ts'
import TimelineEntry from './TimelineEntry.tsx'
import { useReadingMode } from '../../../lib/readingMode.ts'
/** A solid teal dot per year, its size growing with the year's
* entries so the rail reads as a density chart. (A vine or tree
@ -15,8 +16,13 @@ type Props = {
onToggle: (year: number) => void
}
export default function TimelineYear({ year, open, onToggle }: Props) {
export default function TimelineYear({ year, open: chosen, onToggle }: Props) {
// Reading mode can't open a year, so every year is open, the year a
// heading in place of its button, and an empty year left out.
const reading = useReadingMode()
const open = chosen || reading
const empty = year.count === 0
const MonthLabel = reading ? 'h5' : 'h4'
const panelId = `site-tl-year-${year.year}`
const className = [
@ -28,8 +34,13 @@ export default function TimelineYear({ year, open, onToggle }: Props) {
.filter(Boolean)
.join(' ')
if (reading && empty) return null
return (
<div className={className}>
{reading ? (
<h4>{year.year}</h4>
) : (
<button
type="button"
className="site-tl__yearBtn"
@ -47,6 +58,7 @@ export default function TimelineYear({ year, open, onToggle }: Props) {
{empty ? '-' : `${year.count} ${year.count === 1 ? 'entry' : 'entries'}`}
</span>
</button>
)}
{open ? (
empty ? (
@ -65,7 +77,7 @@ export default function TimelineYear({ year, open, onToggle }: Props) {
{year.months.map((month) => (
<section className="site-tl__month" key={month.month}>
<h4 className="site-tl__monthLabel">{month.label}</h4>
<MonthLabel className="site-tl__monthLabel">{month.label}</MonthLabel>
<ul className="site-tl__list">
{month.items.map((item) => (
<TimelineEntry key={item.id} item={item} />
@ -76,7 +88,7 @@ export default function TimelineYear({ year, open, onToggle }: Props) {
{year.undated.length > 0 ? (
<section className="site-tl__month site-tl__undated">
<h4 className="site-tl__monthLabel">Elsewhere in {year.year}</h4>
<MonthLabel className="site-tl__monthLabel">Elsewhere in {year.year}</MonthLabel>
<ul className="site-tl__list">
{year.undated.map((item) => (
<TimelineEntry key={item.id} item={item} />

View file

@ -17,6 +17,9 @@
doesn't open it.
Nothing featured, and the section doesn't render at all.
Reading mode (readingMode.ts) gets the entries as text, oldest
first, each a linked heading with its date and words (ReadingRail).
═══════════════════════════════════════════════════════════════ */
import { ArrowRight, CaretRight, CaretLeft } from '@phosphor-icons/react';
@ -29,6 +32,7 @@ import { hrefFor, logoSrc } from '../../../lib/timelineRefs.ts'
import { MONTH_LABELS, type TimelineItem } from '../../../lib/timeline.ts'
import { accentText, BRAND } from '../../../lib/color.ts'
import { scrollBehavior } from '../../../lib/motion.ts';
import { useReadingMode } from '../../../lib/readingMode.ts'
const DRAG_SLOP = 6
@ -43,9 +47,29 @@ export default function FeaturedTimelineRail({ id, title, blurb }: RailProps) {
const railRef = useRef<HTMLOListElement>(null)
const drag = useRef({ x: 0, left: 0, moved: false, active: false })
const [dragging, setDragging] = useState(false)
const reading = useReadingMode()
if (!loading && !error && featured.length === 0) return null
if (reading) {
return (
<section id={id}>
<h2>{title}</h2>
{blurb && <p>{blurb}</p>}
{error ? (
<p>Couldn’t load the timeline. {error}</p>
) : loading ? (
<p>Loading the timeline…</p>
) : (
featured.map((item) => <ReadingEntry key={item.id} item={item} />)
)}
<p>
<Link to="/history">See the full history</Link>
</p>
</section>
)
}
const step = (direction: number) => {
const rail = railRef.current
const card = rail?.querySelector('li')
@ -182,6 +206,17 @@ function dateLabel(item: TimelineItem): string {
return y
}
function ReadingEntry({ item }: { item: TimelineItem }) {
const href = hrefFor(item)
return (
<>
<h3>{href ? <HomeLink url={href}>{item.title}</HomeLink> : item.title}</h3>
<p>{[dateLabel(item), item.meta].filter(Boolean).join(', ')}</p>
{item.blurb && <p>{item.blurb}</p>}
</>
)
}
function RailCard({ item, showYear }: { item: TimelineItem; showYear: boolean }) {
const href = hrefFor(item)
const logo = logoSrc(item)

View file

@ -32,6 +32,10 @@
`hero` is null while the page config loads or when it failed; the
stage still draws, empty, so the page doesn't jump when it
arrives. The error itself is shown by Home, not here.
Reading mode (readingMode.ts) gets it as text (ReadingHero): the
words and buttons, every photo's caption at once (no slideshow),
then the feature as a link, or the event's card.
═══════════════════════════════════════════════════════════════ */
import { ArrowRight, Play, Pause, Star } from '@phosphor-icons/react'
@ -47,6 +51,7 @@ import { livestreamEmbedUrl, videoSource, type VideoSource } from '../../../lib/
import { mediaUrl } from '../../../lib/media.ts'
import { prefersLessMotion } from '../../../lib/motion.ts'
import { focusOnMount } from '../../../lib/focus.ts'
import { useReadingMode } from '../../../lib/readingMode.ts'
import { eventHref } from '../../../lib/hrefs.ts'
import { seriesLabel } from '../../../lib/eventSeries.ts'
import type { Hero, HeroBackdrop, HeroEvent, HeroFeature, HeroSlide } from '../../../lib/useFrontPage.ts'
@ -73,6 +78,14 @@ export default function HeroStage({ hero }: { hero: Hero | null }) {
// Every feature shares a layout: words left, feature right.
const beside = feature !== 'none'
if (useReadingMode()) {
return (
<section id="hero">
{hero && <ReadingHero hero={hero} feature={feature} slides={backdrop === 'photos' ? slides : []} video={video} />}
</section>
)
}
return (
<section
id="hero"
@ -186,6 +199,73 @@ function Words({ hero, feature }: { hero: Hero; feature: HeroFeature }) {
)
}
/* ── Reading mode ──────────────────────────────────────────────
The hero as text: its words and buttons, the photos' captions
(all of them, not the one a timer is showing), then the feature:
a link out to the stream or the video, or the event's card,
which already reads plainly. */
type ReadingHeroProps = {
hero: Hero
feature: HeroFeature
slides: HeroSlide[]
video: VideoSource | null
}
function ReadingHero({ hero, feature, slides, video }: ReadingHeroProps) {
const captions = slides.filter((slide) => slide.caption)
return (
<>
{feature === 'none' && hero.eyebrow && <p>{hero.eyebrow}</p>}
<h1>{hero.headline}</h1>
{hero.subhead && <p>{hero.subhead}</p>}
{[hero.primary, hero.secondary].map(
(button) =>
button && (
<p key={button.url}>
<HomeLink url={button.url}>{button.label}</HomeLink>
</p>
),
)}
{captions.length > 0 && (
<ul>
{captions.map((slide, index) => (
<li key={`${slide.media}-${index}`}>
{slide.link_url ? <HomeLink url={slide.link_url}>{slide.caption}</HomeLink> : slide.caption}
</li>
))}
</ul>
)}
{feature === 'livestream' && hero.livestream && (
<p>
Live now{hero.livestream.title && `: ${hero.livestream.title}`}.{' '}
<HomeLink url={hero.livestream.url}>Watch live</HomeLink>
</p>
)}
{feature === 'video' && hero.video && (
<p>
Featured video:{' '}
{video?.kind === 'file' ? (
<a href={video.src}>{hero.video.title || 'Watch the video'}</a>
) : (
<HomeLink url={hero.video.url}>{hero.video.title || 'Watch the video'}</HomeLink>
)}
</p>
)}
{feature === 'event' && hero.event && (
<>
<p>Featured event</p>
<EventPanel event={hero.event} />
</>
)}
</>
)
}
/* ── The hero's buttons ──────────────────────────────────────────
Both set: one cell in two halves, the primary filled on the left
and the secondary clear on the right, split by a slash (the

View file

@ -19,6 +19,9 @@
paths are a strip of cells along the top, the chosen one filled
flat in its accent; under it, the path's blurb and its actions
are cells of the same block.
Reading mode (readingMode.ts) gets every path at once, no tabs:
its label as a heading, its blurb and a list of its actions.
═══════════════════════════════════════════════════════════════ */
import { ArrowRight, ArrowUpRight, BookOpen, Dot, CalendarBlank, ChatCircle, Compass, GraduationCap, HandHeart, Heart, House, MapPin, MusicNotes, Sparkle, Star, Tent, UsersThree, type Icon } from '@phosphor-icons/react'
@ -27,6 +30,7 @@ import { useId, useRef, useState, type CSSProperties, type KeyboardEvent } from
import HomeLink, { isExternal } from './HomeLink.tsx'
import type { FrontPagePath } from '../../../lib/useFrontPage.ts'
import { ACCENTS, accentText, readableOn } from '../../../lib/color.ts'
import { useReadingMode } from '../../../lib/readingMode.ts'
type PathfinderProps = {
id: string
@ -69,9 +73,33 @@ export default function Pathfinder({ id, title, blurb, paths }: PathfinderProps)
const [selected, setSelected] = useState(0)
const tabs = useRef<Array<HTMLButtonElement | null>>([])
const base = useId().replace(/:/g, '')
const reading = useReadingMode()
if (paths.length === 0) return null
if (reading) {
return (
<section id={id}>
<h2>{title}</h2>
{blurb && <p>{blurb}</p>}
{paths.map((option, index) => (
<div key={`${option.label}-${index}`}>
<h3>{option.label}</h3>
{option.blurb && <p>{option.blurb}</p>}
<ul>
{option.actions.map((action, i) => (
<li key={`${action.url}-${i}`}>
<HomeLink url={action.url}>{action.label}</HomeLink>
{action.description && `: ${action.description}`}
</li>
))}
</ul>
</div>
))}
</section>
)
}
const path = paths[Math.min(selected, paths.length - 1)]
const accent = PATH_ACCENTS[selected % PATH_ACCENTS.length]