- Dark mode: the countdown card, timeline section, Giving text, error text, the Leadership button, skeletons and the admin's dark text all follow the tokens; logos get a light plate in dark mode - One BRAND accent (the button token, so the admin palette reaches every page) and one ACCENTS family in color.ts, replacing 20 local teal constants and the purple, ochre and rust section colours; neon green and gold become mint and brand green - Shadows are tinted with the site's ink; glow shadows are gone - One giving label, Give, in the nav, footer and Giving page - Phosphor icons replace the hand-drawn SVGs and the glyph icons; Pathfinder paths pick a named icon (emoji still shown) and lose the watermark - Home keeps two eyebrows; StatsBand's title is a real heading; section headings step down under the page title - Nav links switch to the menu below lg, so they never wrap; jump links land clear of the header; press feedback on buttons - Empty sections say what's coming and who to ask; loading is a skeleton; form placeholders and borders are readable; one corner-radius rule; theme-color for both modes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
401 lines
13 KiB
TypeScript
401 lines
13 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
||
EVENT DETAIL: /retreats/:id
|
||
|
||
Reached from the cards on Retreats.tsx. The API has already
|
||
resolved the fallbacks, `color` is the event's own or its first
|
||
host's, `status` is derived from the dates when nobody set it,
|
||
so nothing here reimplements those rules.
|
||
|
||
Hosts arrive as a list in billing order, each one either an
|
||
organization or a person. refHref takes the kind and works out
|
||
the route, which is why this file doesn't branch on it.
|
||
|
||
People are grouped by their billing role rather than listed flat.
|
||
A retreat with four speakers and eleven volunteers reads as two
|
||
different things, and v_event_people already sorts within a role
|
||
by sort_order.
|
||
═══════════════════════════════════════════════════════════════ */
|
||
|
||
import { Link, useParams } from 'react-router-dom'
|
||
|
||
import PageShell, { type ShellSection } from '../components/PageShell.tsx'
|
||
import PageState from '../components/PageState.tsx'
|
||
import PlatformIcon from '../components/PlatformIcon.tsx'
|
||
import ContentBlocks from '../components/ContentBlocks.tsx'
|
||
import PeopleTiles, { type PeopleGroupInput } from '../components/PeopleTiles.tsx'
|
||
import {
|
||
useEvent,
|
||
type EventHost,
|
||
type EventPerson,
|
||
type EventRecord,
|
||
} from '../lib/useContent.ts'
|
||
import { awardHref, personHref, refHref } from '../lib/hrefs.ts'
|
||
import { mediaUrl } from '../lib/media.ts'
|
||
import { eventTypeLabel } from '../lib/eventTypes.ts'
|
||
import { occurrenceLabel, seriesLabel, seriesTimes, upcomingOccurrences } from '../lib/eventSeries.ts'
|
||
import { capitalize } from '../lib/text.ts'
|
||
import { accentText, readableOn, BRAND } from '../lib/color.ts'
|
||
|
||
const BODY = 'var(--color-muted)'
|
||
|
||
/* Billing order. A role missing from here still renders, at the
|
||
end, under its own name, better than a speaker vanishing
|
||
because somebody added a role to the CHECK and not to this list. */
|
||
const ROLE_ORDER = [
|
||
'speaker',
|
||
'leader',
|
||
'facilitator',
|
||
'host',
|
||
'musician',
|
||
'volunteer',
|
||
'attendee',
|
||
] as const
|
||
|
||
const ROLE_LABEL: Record<string, string> = {
|
||
speaker: 'Speakers',
|
||
leader: 'Leaders',
|
||
facilitator: 'Facilitators',
|
||
host: 'Hosts',
|
||
musician: 'Music',
|
||
volunteer: 'Volunteers',
|
||
attendee: 'Also there',
|
||
}
|
||
|
||
const STATUS_LABEL: Record<string, string> = {
|
||
upcoming: 'Upcoming',
|
||
past: 'Past',
|
||
cancelled: 'Cancelled',
|
||
}
|
||
|
||
export default function EventDetail() {
|
||
const { id } = useParams()
|
||
const { data: event, loading, error, notFound, reload } = useEvent(id)
|
||
|
||
if (!event) {
|
||
return (
|
||
<PageState
|
||
loading={loading}
|
||
error={error}
|
||
notFound={notFound}
|
||
onRetry={reload}
|
||
noun="retreat"
|
||
backTo="/retreats"
|
||
backLabel="All retreats"
|
||
/>
|
||
)
|
||
}
|
||
|
||
const accent = event.color || BRAND
|
||
const groups = peopleGroups(event.people, accent)
|
||
|
||
const sections: ShellSection[] = [
|
||
{
|
||
id: 'about',
|
||
title: event.theme || 'About',
|
||
blurb: event.theme ? event.tagline ?? undefined : undefined,
|
||
accent,
|
||
background: 'var(--color-surface)',
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6 space-y-8">
|
||
<Facts event={event} accent={accent} />
|
||
|
||
{event.description.map((paragraph, index) => (
|
||
<p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}>
|
||
{paragraph}
|
||
</p>
|
||
))}
|
||
|
||
<div className="max-w-3xl">
|
||
<ContentBlocks blocks={event.blocks} accent={accent} />
|
||
</div>
|
||
|
||
{event.links.length > 0 && (
|
||
<div className="flex flex-wrap gap-3">
|
||
{event.links.map((link) => (
|
||
<a
|
||
key={link.url}
|
||
href={link.url}
|
||
target="_blank"
|
||
rel="noreferrer"
|
||
className="inline-flex items-center gap-2 rounded-full px-5 py-2 text-sm font-semibold text-white transition-transform hover:scale-105"
|
||
style={{ background: accent }}
|
||
>
|
||
<PlatformIcon platform={link.platform} />
|
||
{link.label}
|
||
</a>
|
||
))}
|
||
</div>
|
||
)}
|
||
</div>
|
||
),
|
||
},
|
||
]
|
||
|
||
// A cancelled series has no next meeting, whatever its dates say.
|
||
const upcoming =
|
||
event.status === 'cancelled'
|
||
? []
|
||
: upcomingOccurrences(event.series, event.starts_on, event.ends_on)
|
||
|
||
if (upcoming.length > 0) {
|
||
const times = seriesTimes(event.series)
|
||
|
||
sections.push({
|
||
id: 'dates',
|
||
title: 'Upcoming dates',
|
||
blurb: seriesLabel(event.series, event.starts_on) ?? undefined,
|
||
accent,
|
||
background: 'var(--color-tint)',
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6">
|
||
<ul className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||
{upcoming.map((date) => (
|
||
<li
|
||
key={date}
|
||
className="rounded-xl border-l-4 bg-surface px-5 py-3"
|
||
style={{ borderColor: accent }}
|
||
>
|
||
<p className="font-semibold" style={{ color: accentText(accent) }}>
|
||
{occurrenceLabel(date)}
|
||
</p>
|
||
{times && (
|
||
<p className="text-sm" style={{ color: BODY }}>
|
||
{times}
|
||
</p>
|
||
)}
|
||
</li>
|
||
))}
|
||
</ul>
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
if (groups.length > 0) {
|
||
sections.push({
|
||
id: 'people',
|
||
title: 'Who’s there',
|
||
accent,
|
||
background: 'var(--color-tint)',
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6">
|
||
<PeopleTiles size="lg" groups={groups} accent={accent} />
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
if (event.awards.length > 0) {
|
||
sections.push({
|
||
id: 'awards',
|
||
title: 'Presented here',
|
||
blurb: 'Awards given at this gathering.',
|
||
accent,
|
||
background: 'var(--color-surface)',
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6 space-y-6">
|
||
{event.awards.map((entry, index) => (
|
||
<div
|
||
key={`${entry.award.id}:${entry.person.id}:${index}`}
|
||
className="flex gap-4 border-l-2 pl-5"
|
||
style={{ borderColor: accent }}
|
||
>
|
||
<div>
|
||
<p className="font-semibold" style={{ color: accentText(accent) }}>
|
||
<Link to={awardHref(entry.award.id)} className="hover:underline">
|
||
{entry.award.name}
|
||
</Link>
|
||
</p>
|
||
<p style={{ color: BODY }}>
|
||
<Link to={personHref(entry.person.id)} className="hover:underline">
|
||
{entry.person.name}
|
||
</Link>
|
||
</p>
|
||
{entry.citation && (
|
||
<p className="mt-1 text-sm italic opacity-80" style={{ color: BODY }}>
|
||
{entry.citation}
|
||
</p>
|
||
)}
|
||
</div>
|
||
</div>
|
||
))}
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
return (
|
||
<PageShell
|
||
title={event.title}
|
||
intro={event.theme ? event.tagline ?? undefined : event.tagline ?? undefined}
|
||
sections={sections}
|
||
/>
|
||
)
|
||
}
|
||
|
||
/* ── The strip of facts under the heading ────────────────────── */
|
||
|
||
function Facts({ event, accent }: { event: EventRecord; accent: string }) {
|
||
const where =
|
||
event.location_label ||
|
||
[event.locality, event.state_code].filter(Boolean).join(', ') ||
|
||
(event.is_online ? 'Online' : null)
|
||
|
||
const schedule = seriesLabel(event.series, event.starts_on)
|
||
// A series with no label of its own is described by its schedule
|
||
// rather than by a start-to-end range that reads like one long
|
||
// gathering.
|
||
const when =
|
||
event.date_label || (schedule ? null : dateRange(event.starts_on, event.ends_on))
|
||
|
||
return (
|
||
<div className="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
|
||
<span
|
||
className="rounded-full px-3 py-1 font-semibold uppercase tracking-wide"
|
||
style={{
|
||
background: event.status === 'cancelled' ? '#b3261e' : accent,
|
||
color: event.status === 'cancelled' ? '#ffffff' : readableOn(accent),
|
||
}}
|
||
>
|
||
{STATUS_LABEL[event.status] ?? event.status}
|
||
</span>
|
||
|
||
{/* Outlined rather than filled: the status pill is the one
|
||
thing in this strip that should read as loud, and two
|
||
solid blocks side by side would compete. Shown
|
||
unconditionally, a card suppresses its own type badge in
|
||
a band of one kind, but here there is no band to make it
|
||
redundant. */}
|
||
{event.event_type && (
|
||
<span
|
||
className="rounded-full px-3 py-1 font-semibold uppercase tracking-wide"
|
||
style={{ border: `1px solid ${accent}`, color: accentText(accent) }}
|
||
>
|
||
{eventTypeLabel(event.event_type)}
|
||
</span>
|
||
)}
|
||
|
||
{when && <span style={{ color: BODY }}>{when}</span>}
|
||
{schedule && <span style={{ color: BODY }}>{schedule}</span>}
|
||
{where && <span style={{ color: BODY }}>{where}</span>}
|
||
{event.is_online && where !== 'Online' && (
|
||
<span style={{ color: BODY }}>Online too</span>
|
||
)}
|
||
|
||
{(event.hosts?.length ?? 0) > 0 && (
|
||
<span style={{ color: BODY }}>
|
||
Hosted by <HostList hosts={event.hosts} accent={accent} />
|
||
</span>
|
||
)}
|
||
|
||
<Link to="/retreats" className="ml-auto hover:underline" style={{ color: accentText(accent) }}>
|
||
All retreats
|
||
</Link>
|
||
</div>
|
||
)
|
||
}
|
||
|
||
/* One host reads as "Hosted by Northwest"; several read as a
|
||
sentence, so they're joined with commas and an "and" rather than
|
||
stacked. A host whose id didn't resolve to a route renders as
|
||
plain text, refHref returns null for that, because a dead link
|
||
is worse than a name. */
|
||
function HostList({ hosts, accent }: { hosts: EventHost[]; accent: string }) {
|
||
return (
|
||
<>
|
||
{hosts.map((host, index) => {
|
||
const to = refHref(host.kind, host.id, host.org_kind)
|
||
|
||
return (
|
||
<span key={`${host.kind}:${host.id}`}>
|
||
{index > 0 && (hosts.length > 2 ? ', ' : ' ')}
|
||
{index > 0 && index === hosts.length - 1 && 'and '}
|
||
{to ? (
|
||
<Link
|
||
to={to}
|
||
className="font-medium hover:underline"
|
||
style={{ color: accentText(accent) }}
|
||
>
|
||
{host.name}
|
||
</Link>
|
||
) : (
|
||
<span className="font-medium">{host.name}</span>
|
||
)}
|
||
</span>
|
||
)
|
||
})}
|
||
</>
|
||
)
|
||
}
|
||
|
||
/* date_label is what a card shows and is free text, "March/April
|
||
2026" is legitimate. This is only the fallback for an event that
|
||
has dates and no label. */
|
||
function dateRange(start?: string | null, end?: string | null): string | null {
|
||
if (!start) return null
|
||
const from = new Date(`${start}T00:00:00`)
|
||
if (Number.isNaN(from.getTime())) return start
|
||
|
||
const full: Intl.DateTimeFormatOptions = {
|
||
month: 'long',
|
||
day: 'numeric',
|
||
year: 'numeric',
|
||
}
|
||
|
||
if (!end || end === start) return from.toLocaleDateString(undefined, full)
|
||
|
||
const to = new Date(`${end}T00:00:00`)
|
||
if (Number.isNaN(to.getTime())) return from.toLocaleDateString(undefined, full)
|
||
|
||
const sameYear = from.getFullYear() === to.getFullYear()
|
||
const sameMonth = sameYear && from.getMonth() === to.getMonth()
|
||
|
||
const left = from.toLocaleDateString(
|
||
undefined,
|
||
sameMonth
|
||
? { month: 'long', day: 'numeric' }
|
||
: sameYear
|
||
? { month: 'long', day: 'numeric' }
|
||
: full,
|
||
)
|
||
|
||
return `${left} – ${to.toLocaleDateString(undefined, full)}`
|
||
}
|
||
|
||
/* ── v_event_people → PeopleTiles groups ─────────────────────── */
|
||
|
||
function peopleGroups(people: EventPerson[], accent: string): PeopleGroupInput[] {
|
||
if (!people.length) return []
|
||
|
||
const byRole = new Map<string, EventPerson[]>()
|
||
for (const person of people) {
|
||
const role = person.role || 'attendee'
|
||
const list = byRole.get(role)
|
||
if (list) list.push(person)
|
||
else byRole.set(role, [person])
|
||
}
|
||
|
||
// Known roles in billing order, then anything the CHECK has
|
||
// gained since this file was written.
|
||
const roles = [
|
||
...ROLE_ORDER.filter((role) => byRole.has(role)),
|
||
...[...byRole.keys()].filter((role) => !ROLE_ORDER.includes(role as never)),
|
||
]
|
||
|
||
return roles.map((role) => ({
|
||
id: `role-${role}`,
|
||
label: ROLE_LABEL[role] ?? capitalize(role),
|
||
accent,
|
||
people: (byRole.get(role) ?? []).map((person) => ({
|
||
id: person.person_id,
|
||
name: person.display_name,
|
||
title: person.title,
|
||
tagline: person.tagline,
|
||
pronouns: person.pronouns,
|
||
// PeopleTiles resolves a bare filename itself; this is here
|
||
// so a hand-written entry elsewhere can't diverge.
|
||
photo: mediaUrl(person.photo),
|
||
})),
|
||
}))
|
||
}
|
||
|