PageBackdrop draws flat, overlapping palette circles behind the public site and eases them to a new tone as each section reaches the middle of the window, so sections no longer paint their own bands (PageShell's background field is gone). The hero's brand backdrop is a flat teal with the dove, its two buttons one cell cut by a slash, and the countdown straddles the hero and the band below. No glows: the drifting blobs, rings, live-dot pulse and the stats band's blurred circle are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
378 lines
12 KiB
TypeScript
378 lines
12 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
||
PERSON DETAIL: /people/:id
|
||
|
||
Everything public that points at one person, gathered by
|
||
GET /people/:id in people.js. Visibility is decided there, the
|
||
same way each list's own page decides it, so nothing here
|
||
filters.
|
||
|
||
Roles are current and past. A roster only ever wants who holds
|
||
a seat now; a person's record is also where "served on the board
|
||
2018–2022" belongs, so ended affiliations list under Previously.
|
||
|
||
public_phone is never sent. The email is the one contact detail
|
||
the page offers.
|
||
|
||
Sections after About alternate background in the order they
|
||
appear, so a person with no roles doesn't get two tinted bands
|
||
in a row.
|
||
═══════════════════════════════════════════════════════════════ */
|
||
|
||
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 { PostCard } from './sections/CommunityBlog.tsx'
|
||
import {
|
||
usePerson,
|
||
type PersonEvent,
|
||
type PersonRecord,
|
||
type PersonRole,
|
||
} from '../lib/useContent.ts'
|
||
import { awardHref, eventHref, orgHref, teamHref } from '../lib/hrefs.ts'
|
||
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'
|
||
|
||
const BODY = 'var(--color-muted)'
|
||
|
||
/* affiliations.role, for a row with no title of its own. */
|
||
const ROLE_LABEL: Record<string, string> = {
|
||
lead: 'Lead',
|
||
board: 'Board member',
|
||
staff: 'Staff',
|
||
volunteer: 'Volunteer',
|
||
member: 'Member',
|
||
}
|
||
|
||
|
||
export default function PersonDetail() {
|
||
const { id } = useParams()
|
||
const { data: person, loading, error, notFound, reload } = usePerson(id)
|
||
|
||
if (!person) {
|
||
return (
|
||
<PageState
|
||
loading={loading}
|
||
error={error}
|
||
notFound={notFound}
|
||
onRetry={reload}
|
||
noun="person"
|
||
backTo="/leadership"
|
||
backLabel="Leadership"
|
||
/>
|
||
)
|
||
}
|
||
|
||
const accent = BRAND
|
||
const current = person.roles.filter((role) => !role.ended_on)
|
||
const previous = person.roles.filter((role) => role.ended_on)
|
||
|
||
const sections: ShellSection[] = [
|
||
{
|
||
id: 'about',
|
||
title: 'About',
|
||
accent,
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6 space-y-8">
|
||
<Facts person={person} accent={accent} />
|
||
|
||
{[...person.bio, ...person.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={person.blocks} accent={accent} />
|
||
</div>
|
||
|
||
<Contact person={person} accent={accent} />
|
||
</div>
|
||
),
|
||
},
|
||
]
|
||
|
||
if (person.roles.length > 0) {
|
||
sections.push({
|
||
id: 'roles',
|
||
title: 'Roles',
|
||
accent,
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6 space-y-8">
|
||
{current.length > 0 && <RoleList roles={current} accent={accent} />}
|
||
|
||
{previous.length > 0 && (
|
||
<div>
|
||
{current.length > 0 && (
|
||
<h3 className="mb-4 text-lg font-bold" style={{ color: accentText(accent) }}>
|
||
Previously
|
||
</h3>
|
||
)}
|
||
<RoleList roles={previous} accent={accent} />
|
||
</div>
|
||
)}
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
if (person.events.length > 0) {
|
||
sections.push({
|
||
id: 'events',
|
||
title: 'Events',
|
||
accent,
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6">
|
||
<ul className="space-y-5">
|
||
{person.events.map((event) => (
|
||
<li key={event.id}>
|
||
<EventRow event={event} accent={accent} />
|
||
</li>
|
||
))}
|
||
</ul>
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
if (person.awards.length > 0) {
|
||
sections.push({
|
||
id: 'awards',
|
||
title: 'Awards',
|
||
accent,
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6 space-y-6">
|
||
{person.awards.map((entry, index) => (
|
||
<div
|
||
key={`${entry.award.id}:${entry.awarded_on ?? index}`}
|
||
className="border-l-2 pl-5"
|
||
style={{ borderColor: accent }}
|
||
>
|
||
<p className="font-semibold" style={{ color: accentText(accent) }}>
|
||
<Link to={awardHref(entry.award.id)} className="hover:underline">
|
||
{entry.award.name}
|
||
</Link>
|
||
</p>
|
||
{(entry.awarded_on || entry.event) && (
|
||
<p className="text-sm" style={{ color: BODY }}>
|
||
{year(entry.awarded_on)}
|
||
{entry.event && (
|
||
<>
|
||
{entry.awarded_on && ' · '}
|
||
<Link
|
||
to={eventHref(entry.event.id)}
|
||
className="hover:underline"
|
||
style={{ color: accentText(accent) }}
|
||
>
|
||
{entry.event.title}
|
||
</Link>
|
||
</>
|
||
)}
|
||
</p>
|
||
)}
|
||
{entry.citation && (
|
||
<p className="mt-1 max-w-2xl italic leading-relaxed" style={{ color: BODY }}>
|
||
{entry.citation}
|
||
</p>
|
||
)}
|
||
</div>
|
||
))}
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
if (person.posts?.length > 0) {
|
||
sections.push({
|
||
id: 'posts',
|
||
title: 'Blog posts',
|
||
accent,
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6">
|
||
<ul className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||
{person.posts.map((post) => (
|
||
<PostCard key={post.id} post={post} accent={accent} />
|
||
))}
|
||
</ul>
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
return (
|
||
<PageShell title={person.name} intro={person.tagline ?? undefined} sections={sections} />
|
||
)
|
||
}
|
||
|
||
/* ── The strip of facts under the heading ────────────────────── */
|
||
|
||
function Facts({ person, accent }: { person: PersonRecord; accent: string }) {
|
||
const photo = mediaUrl(person.photo)
|
||
|
||
return (
|
||
<div className="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
|
||
{photo ? (
|
||
<img
|
||
src={photo}
|
||
alt=""
|
||
loading="lazy"
|
||
decoding="async"
|
||
className="h-24 w-24 shrink-0 object-cover"
|
||
/>
|
||
) : (
|
||
<span
|
||
aria-hidden="true"
|
||
className="flex h-24 w-24 shrink-0 items-center justify-center text-2xl font-bold text-white"
|
||
style={{ background: accent }}
|
||
>
|
||
{initials(person.name)}
|
||
</span>
|
||
)}
|
||
|
||
{person.pronouns && <span style={{ color: BODY }}>{person.pronouns}</span>}
|
||
|
||
{person.org && (
|
||
<Link
|
||
to={orgHref(person.org.id, person.org.kind)}
|
||
className="font-medium hover:underline"
|
||
style={{ color: accentText(accent) }}
|
||
>
|
||
{person.org.name}
|
||
</Link>
|
||
)}
|
||
|
||
{person.location_label && <span style={{ color: BODY }}>{person.location_label}</span>}
|
||
|
||
<Link to="/leadership" className="ml-auto hover:underline" style={{ color: accentText(accent) }}>
|
||
Leadership
|
||
</Link>
|
||
</div>
|
||
)
|
||
}
|
||
|
||
function Contact({ person, accent }: { person: PersonRecord; accent: string }) {
|
||
const outlined = [
|
||
person.website ? { url: person.website, label: 'Website', platform: null } : null,
|
||
person.public_email
|
||
? { url: `mailto:${person.public_email}`, label: person.public_email, platform: null }
|
||
: null,
|
||
...person.socials,
|
||
].filter((link): link is NonNullable<typeof link> => Boolean(link))
|
||
|
||
if (person.links.length === 0 && outlined.length === 0) return null
|
||
|
||
return (
|
||
<div className="flex flex-wrap gap-3">
|
||
{person.links.map((link) => (
|
||
<a
|
||
key={link.url}
|
||
href={link.url}
|
||
target="_blank"
|
||
rel="noreferrer"
|
||
className="inline-flex items-center gap-2 btn px-5 py-2 text-sm text-white transition-transform hover:scale-105"
|
||
style={{ background: accent }}
|
||
>
|
||
<PlatformIcon platform={link.platform} />
|
||
{link.label}
|
||
</a>
|
||
))}
|
||
|
||
{outlined.map((link) => (
|
||
<a
|
||
key={link.url}
|
||
href={link.url}
|
||
target="_blank"
|
||
rel="noreferrer"
|
||
className="inline-flex items-center gap-2 btn border px-4 py-1.5 text-sm transition-colors hover:bg-tint"
|
||
style={{ borderColor: accent, color: accentText(accent) }}
|
||
>
|
||
<PlatformIcon platform={link.platform} />
|
||
{link.label}
|
||
</a>
|
||
))}
|
||
</div>
|
||
)
|
||
}
|
||
|
||
/* ── Roles ───────────────────────────────────────────────────── */
|
||
|
||
function RoleList({ roles, accent }: { roles: PersonRole[]; accent: string }) {
|
||
return (
|
||
<ul className="grid gap-4 sm:grid-cols-2">
|
||
{roles.map((role, index) => (
|
||
<li
|
||
key={`${role.org.id}:${role.team?.id ?? ''}:${role.title ?? role.role}:${index}`}
|
||
className="border-l-4 bg-surface px-5 py-3"
|
||
style={{ borderColor: accent }}
|
||
>
|
||
<p className="font-semibold" style={{ color: accentText(accent) }}>
|
||
{role.title || ROLE_LABEL[role.role] || capitalize(role.role)}
|
||
</p>
|
||
<p className="text-sm" style={{ color: BODY }}>
|
||
{role.team && (
|
||
<>
|
||
<Link to={teamHref(role.team.id)} className="hover:underline">
|
||
{role.team.name}
|
||
</Link>
|
||
{' · '}
|
||
</>
|
||
)}
|
||
<Link to={orgHref(role.org.id, role.org.kind)} className="hover:underline">
|
||
{role.org.name}
|
||
</Link>
|
||
</p>
|
||
{tenure(role) && (
|
||
<p className="text-xs" style={{ color: BODY }}>
|
||
{tenure(role)}
|
||
</p>
|
||
)}
|
||
</li>
|
||
))}
|
||
</ul>
|
||
)
|
||
}
|
||
|
||
/* "2018 – 2022", "Since 2021", "Until 2019", or null. Years only:
|
||
affiliation dates are often backfilled from memory. */
|
||
function tenure(role: PersonRole): string | null {
|
||
const from = year(role.started_on)
|
||
const to = year(role.ended_on)
|
||
if (from && to) return from === to ? from : `${from} – ${to}`
|
||
if (from) return `Since ${from}`
|
||
if (to) return `Until ${to}`
|
||
return null
|
||
}
|
||
|
||
/* ── Events ──────────────────────────────────────────────────── */
|
||
|
||
function EventRow({ event, accent }: { event: PersonEvent; accent: string }) {
|
||
const when = event.date_label || year(event.starts_on)
|
||
const capacities = event.roles
|
||
.map((role) => role.title || capitalize(role.role))
|
||
.join(', ')
|
||
|
||
return (
|
||
<div className="border-l-2 pl-5" style={{ borderColor: accent }}>
|
||
<p className="font-semibold" style={{ color: accentText(accent) }}>
|
||
<Link to={eventHref(event.id)} className="hover:underline">
|
||
{event.title}
|
||
</Link>
|
||
</p>
|
||
<p className="text-sm" style={{ color: BODY }}>
|
||
{[capacities, eventTypeLabel(event.event_type), when].filter(Boolean).join(' · ')}
|
||
</p>
|
||
</div>
|
||
)
|
||
}
|
||
|
||
/* Dates here may be partial ('2019', '2019-06'), so take the
|
||
leading year rather than parsing. */
|
||
function year(date?: string | null): string | null {
|
||
if (!date) return null
|
||
const match = /^(\d{4})/.exec(date)
|
||
return match ? match[1] : date
|
||
}
|