v1.5 - history and timeline as well as many datastructure updates added, polished, fixes

This commit is contained in:
Zaldimmar 2026-09-25 02:38:51 -05:00
parent 1f0aa3078f
commit 1d84400aef
63 changed files with 7927 additions and 208 deletions

View file

@ -0,0 +1,155 @@
import { Link } from 'react-router-dom'
import { MONTH_LABELS, type PersonRef, type TimelineItem } from '../../../lib/timeline'
import { hrefFor, logoSrc, photoSrc } from '../../../lib/timelineRefs'
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)}`
}
/** Initials stand in when a person has no photo on file. */
function initials(name: string): string {
return name
.split(/\s+/)
.slice(0, 2)
.map((part) => part[0] ?? '')
.join('')
.toUpperCase()
}
function PersonChip({ person }: { person: PersonRef }) {
const src = photoSrc(person.photo)
return (
<li className="ngu-tl__person">
{src ? (
<img className="ngu-tl__personPhoto" src={src} alt="" loading="lazy" />
) : (
<span className="ngu-tl__personPhoto ngu-tl__personPhoto--blank" aria-hidden="true">
{initials(person.name)}
</span>
)}
<span className="ngu-tl__personName">
{person.name}
{person.title ? (
<span className="ngu-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 = [
'ngu-tl__entry',
featured ? 'ngu-tl__entry--featured' : '',
href ? 'ngu-tl__entry--linked' : '',
]
.filter(Boolean)
.join(' ')
const marker = (
<span className="ngu-tl__entryDay">
{featured ? fullMarker(item) : dayMarker(item)}
</span>
)
const body = (
<span className="ngu-tl__entryBody">
<span className="ngu-tl__entryTitle">
{logo ? (
<img className="ngu-tl__logo" src={logo} alt="" loading="lazy" />
) : (
<span
className={`ngu-tl__kind ngu-tl__kind--${item.kind}`}
aria-hidden="true"
/>
)}
{item.title}
</span>
{item.meta ? <span className="ngu-tl__entryMeta">{item.meta}</span> : null}
{item.blurb ? <p className="ngu-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={`ngu-tl__roster${featured ? ' ngu-tl__roster--featured' : ''}`}
>
{item.team ? (
<span className="ngu-tl__rosterTeam">
{item.team.name}
{item.team.orgName ? ` · ${item.team.orgName}` : ''}
</span>
) : null}
<ul className="ngu-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="ngu-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>
)
}