- The timeline's ngu-tl classes and keyframes are site-tl; nguLogo is siteLogo; the event card's ngu grid area is org; window.__NGU_SITE__ is window.__SITE__; QR downloads are qr-<page>.png - Browser keys (theme, closed banner and privacy notice, chunk reload) start site-; the page's first script moves any old ngu- values over once, so nobody loses their theme or sees a closed notice again - Session and Google sign-in cookies are site_session and site_oauth (__Host- over https); everyone signs in again once Record ids, server paths, the service and the database file keep their names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
147 lines
4.4 KiB
TypeScript
147 lines
4.4 KiB
TypeScript
import { Link } from 'react-router-dom'
|
|
import { MONTH_LABELS, type PersonRef, type TimelineItem } from '../../../lib/timeline.ts'
|
|
import { hrefFor, logoSrc } from '../../../lib/timelineRefs.ts'
|
|
import { initials, mediaUrl } from '../../../lib/media.ts'
|
|
import { useSmallImage } from '../../../lib/useSmallImage.ts'
|
|
|
|
const KIND_NAMES: Record<TimelineItem['kind'], string> = {
|
|
milestone: 'Milestone',
|
|
event: 'Event',
|
|
organization: 'Organization',
|
|
award: 'Award',
|
|
people: 'People',
|
|
}
|
|
|
|
/** Day number only, the month node above already carries the month. */
|
|
function dayMarker(item: TimelineItem): string {
|
|
if (item.precision !== 'day') return ''
|
|
const day = Number(item.date.split('-')[2])
|
|
return Number.isFinite(day) ? String(day) : ''
|
|
}
|
|
|
|
/** Featured entries sit above the month nodes, so they spell out their date. */
|
|
function fullMarker(item: TimelineItem): string {
|
|
const [, m, d] = item.date.split('-')
|
|
if (item.precision === 'year' || !m) return 'Date unrecorded'
|
|
const month = MONTH_LABELS[Number(m) - 1] ?? ''
|
|
if (item.precision === 'month' || !d) return month
|
|
return `${month} ${Number(d)}`
|
|
}
|
|
|
|
function PersonChip({ person }: { person: PersonRef }) {
|
|
const img = useSmallImage(mediaUrl(person.photo))
|
|
return (
|
|
<li className="site-tl__person">
|
|
{!img.failed ? (
|
|
<img className="site-tl__personPhoto" src={img.src} alt="" loading="lazy" onError={img.onError} />
|
|
) : (
|
|
<span className="site-tl__personPhoto site-tl__personPhoto--blank" aria-hidden="true">
|
|
{initials(person.name)}
|
|
</span>
|
|
)}
|
|
<span className="site-tl__personName">
|
|
{person.name}
|
|
{person.title ? (
|
|
<span className="site-tl__personTitle">{person.title}</span>
|
|
) : null}
|
|
</span>
|
|
</li>
|
|
)
|
|
}
|
|
|
|
type Props = {
|
|
item: TimelineItem
|
|
/** Featured entries render larger and lead the year. */
|
|
variant?: 'inline' | 'featured'
|
|
}
|
|
|
|
export default function TimelineEntry({ item, variant = 'inline' }: Props) {
|
|
const featured = variant === 'featured'
|
|
const href = hrefFor(item)
|
|
const logo = logoSrc(item)
|
|
|
|
const className = [
|
|
'site-tl__entry',
|
|
featured ? 'site-tl__entry--featured' : '',
|
|
href ? 'site-tl__entry--linked' : '',
|
|
]
|
|
.filter(Boolean)
|
|
.join(' ')
|
|
|
|
const marker = (
|
|
<span className="site-tl__entryDay">
|
|
{featured ? fullMarker(item) : dayMarker(item)}
|
|
</span>
|
|
)
|
|
|
|
const body = (
|
|
<span className="site-tl__entryBody">
|
|
<span className="site-tl__entryTitle">
|
|
{logo ? (
|
|
<img className="site-tl__logo logo-plate" src={logo} alt="" loading="lazy" />
|
|
) : (
|
|
<span
|
|
className={`site-tl__kind site-tl__kind--${item.kind}`}
|
|
aria-hidden="true"
|
|
/>
|
|
)}
|
|
{item.title}
|
|
</span>
|
|
{item.meta ? <span className="site-tl__entryMeta">{item.meta}</span> : null}
|
|
{item.blurb ? <p className="site-tl__entryBlurb">{item.blurb}</p> : null}
|
|
</span>
|
|
)
|
|
|
|
// The people list sits outside the link: each name is its own
|
|
// destination, and nesting anchors is invalid markup anyway.
|
|
const roster =
|
|
item.kind === 'people' && item.people && item.people.length > 0 ? (
|
|
<div
|
|
className={`site-tl__roster${featured ? ' site-tl__roster--featured' : ''}`}
|
|
>
|
|
{item.team ? (
|
|
<span className="site-tl__rosterTeam">
|
|
{item.team.name}
|
|
{item.team.orgName ? ` · ${item.team.orgName}` : ''}
|
|
</span>
|
|
) : null}
|
|
<ul className="site-tl__people">
|
|
{item.people.map((person) => (
|
|
<PersonChip key={person.id} person={person} />
|
|
))}
|
|
</ul>
|
|
</div>
|
|
) : null
|
|
|
|
const label = `${KIND_NAMES[item.kind]}: ${item.title}`
|
|
// An explicit href may point off-site; Link is for in-app routes only.
|
|
const external = !!href && /^(https?:)?\/\//.test(href)
|
|
|
|
return (
|
|
<li className="site-tl__entryWrap">
|
|
{href && external ? (
|
|
<a
|
|
href={href}
|
|
className={className}
|
|
aria-label={label}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
>
|
|
{marker}
|
|
{body}
|
|
</a>
|
|
) : href ? (
|
|
<Link to={href} className={className} aria-label={label}>
|
|
{marker}
|
|
{body}
|
|
</Link>
|
|
) : (
|
|
<div className={className}>
|
|
{marker}
|
|
{body}
|
|
</div>
|
|
)}
|
|
{roster}
|
|
</li>
|
|
)
|
|
}
|