Reading mode: text versions of the front page's bands

- Stats: one line per number, no longer stuck at 0 (the count waited
  for the band to scroll into view, which the hidden page never
  does); reduced motion shows the numbers at once too.
- Calendar: the next six weeks from today as a list (date, linked
  title, time, type, place), wherever a calendar is drawn.
- Featured cards: a linked heading and its words each; a video card
  links to its video.
- Countdown: left out, the retreats band shows the same event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-03 16:54:55 -05:00
parent 502a294940
commit c79910ef8d
5 changed files with 95 additions and 5 deletions

View file

@ -23,6 +23,9 @@
fall outside), 4px thick. With three or more cards the first is the large
one, two rows tall, and the next two stack beside it, so it no
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.
═══════════════════════════════════════════════════════════════ */
@ -31,6 +34,7 @@ import VideoPlayer from './VideoPlayer.tsx'
import { refHref } from '../lib/hrefs.ts'
import { mediaUrl } from '../lib/media.ts'
import type { FeaturedCard } from '../lib/useFrontPage.ts'
import { useReadingMode } from '../lib/readingMode.ts'
import { useSmallImage } from '../lib/useSmallImage.ts'
/* Image kinds that are photographs, drawn edge to edge. Anything
@ -131,7 +135,26 @@ function Card({ card, large }: { card: FeaturedCard; large: boolean }) {
)
}
function ReadingCards({ cards }: { cards: FeaturedCard[] }) {
return (
<>
{cards.map((card, index) => {
const href = card.kind === 'video' ? card.url : hrefFor(card)
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.blurb && <p>{card.blurb}</p>}
</div>
)
})}
</>
)
}
export default function FeaturedCards({ cards }: { cards: FeaturedCard[] }) {
const reading = useReadingMode()
if (reading) return <ReadingCards cards={cards} />
const leadLarge = cards.length >= 3
return (
<div className="overflow-hidden shadow-md">

View file

@ -39,6 +39,9 @@
Below md the grid would be seven unreadable slivers, so the month
view shows the list there instead. The toggle still works; it
just has one answer on a phone.
Reading mode (readingMode.ts) gets no grid or controls: the next
six weeks from today as a list, one line per event (ReadingList).
═══════════════════════════════════════════════════════════════ */
import { ArrowRight, ArrowLeft, CaretRight, CaretLeft } from '@phosphor-icons/react'
@ -52,6 +55,7 @@ import { eventHref } from '../../lib/hrefs.ts'
import type { EventListItem } from '../../lib/useContent.ts'
import { withAlpha, accentText, readableOn, BRAND } from '../../lib/color.ts'
import { localISO } from '../../lib/timeline.ts'
import { useReadingMode } from '../../lib/readingMode.ts'
export type CalendarControl = 'scope' | 'type' | 'online' | 'search'
export type CalendarView = 'month' | 'list'
@ -225,7 +229,43 @@ function nextDateAfter(events: EventListItem[], after: string): string | null {
/* ── Component ───────────────────────────────────────────────── */
export default function EventCalendar({
export default function EventCalendar(props: EventCalendarProps) {
return useReadingMode() ? <ReadingList {...props} /> : <CalendarGrid {...props} />
}
/* How many days from today the reading mode list covers. */
const READING_DAYS = 42
/* Reading mode: what's on from today for six weeks, as text. */
function ReadingList({ scope, host, status, type }: EventCalendarProps) {
const today = iso(new Date())
const to = addDays(today, READING_DAYS - 1)
const { events, loading, error } = useEvents({ scope, host, status, type, from: today, to })
const items = useMemo(() => occurrencesIn(events, today, to), [events, today, to])
if (error) return <p>Couldn’t load the calendar. {error}</p>
if (loading && items.length === 0) return <p>Loading the calendar…</p>
if (items.length === 0) return <p>Nothing on the calendar in the next six weeks.</p>
return (
<ul>
{items.map((item) => {
const { event } = item
const when = item.start !== item.end ? rangeLabel(item.start, item.end) : longDay(item.start)
const where = event.location_label || (event.is_online ? 'Online' : null)
return (
<li key={item.key}>
{when}: <Link to={eventHref(event.id)}>{event.title}</Link>
{event.status === 'cancelled' && ' (canceled)'}
{[item.time, eventTypeLabel(event.event_type), where].filter(Boolean).map((part) => `, ${part}`)}
</li>
)
})}
</ul>
)
}
function CalendarGrid({
scope,
host,
status,

View file

@ -26,6 +26,7 @@ import { eventHref } from '../../../lib/hrefs.ts'
import { upcomingOccurrences } from '../../../lib/eventSeries.ts'
import type { CountdownEvent } from '../../../lib/useFrontPage.ts'
import { withAlpha, accentText, BRAND } from '../../../lib/color.ts'
import { useReadingMode } from '../../../lib/readingMode.ts'
/* Local midnight (or HH:MM) on a 'YYYY-MM-DD'. */
@ -63,6 +64,7 @@ export default function NextEventCountdown({
event: CountdownEvent
overlap: boolean
}) {
const reading = useReadingMode()
const now = useNow(1000)
const when = target(event)
const accent = event.color || BRAND
@ -79,6 +81,9 @@ export default function NextEventCountdown({
const where = event.location_label || (event.is_online ? 'Online' : null)
// Reading mode: the event is already in the retreats band.
if (reading) return null
return (
<section
aria-label="Next event"

View file

@ -6,13 +6,15 @@
band scrolls into view; a value that isn't a plain number
("Since 2004", "Coast to coast") just appears.
Reduced motion skips the count and shows the number.
Reduced motion skips the count and shows the number. Reading mode
(readingMode.ts) gets one line per number: "1,200+ Members".
═══════════════════════════════════════════════════════════════ */
import { useEffect, useRef, useState } from 'react'
import type { FrontPageStat } from '../../../lib/useFrontPage.ts'
import { prefersLessMotion } from '../../../lib/motion.ts'
import { useReadingMode } from '../../../lib/readingMode.ts'
const COUNT_MS = 1400
@ -25,7 +27,9 @@ type StatsBandProps = {
export default function StatsBand({ id, title, blurb, stats }: StatsBandProps) {
const ref = useRef<HTMLElement>(null)
const [seen, setSeen] = useState(false)
// Less motion: no wait for the band to scroll into view (reading
// mode's hidden page never does).
const [seen, setSeen] = useState(prefersLessMotion)
useEffect(() => {
const el = ref.current
@ -43,6 +47,24 @@ export default function StatsBand({ id, title, blurb, stats }: StatsBandProps) {
return () => observer.disconnect()
}, [seen])
if (useReadingMode()) {
return (
<section id={id}>
<h2>{title}</h2>
{blurb && <p>{blurb}</p>}
<ul>
{stats.map((stat, index) => (
<li key={`${stat.label}-${index}`}>
{stat.value}
{stat.suffix} {stat.label}
{stat.note && `: ${stat.note}`}
</li>
))}
</ul>
</section>
)
}
return (
<section
id={id}
@ -107,7 +129,7 @@ function CountUp({ value, run }: { value: string; run: boolean }) {
if (!numeric) return <>{value}</>
const n = reduced || !run ? (run ? target : 0) : shown
const n = reduced ? target : run ? shown : 0
return (
<span className="tabular-nums">
{n.toLocaleString(undefined, {