- A still that fails or comes back as YouTube's 120 x 90 "no thumbnail" image gives way to the next; with none left the player is a flat teal panel with the play button showing. - Timeline: solid teal dots, a solid teal rail and teal decade tags (still on their branch), one color throughout, until a vine or tree drawing replaces them. The leaf colors are gone. - People tiles fill each row with as many as fit (2 to 10), one fewer only when the last row would be a single tile, instead of evening rows out (8 where 6 fit had come out 4 and 4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
92 lines
2.9 KiB
TypeScript
92 lines
2.9 KiB
TypeScript
import type { CSSProperties } from 'react'
|
|
import type { GroupedYear } from '../../../lib/timeline.ts'
|
|
import TimelineEntry from './TimelineEntry.tsx'
|
|
|
|
/** A solid teal dot per year, its size growing with the year's
|
|
* entries so the rail reads as a density chart. (A vine or tree
|
|
* drawing may replace the dots later.) */
|
|
function dotSize(count: number): string {
|
|
return `${(9 + Math.min(count, 14) * 0.6).toFixed(2)}px`
|
|
}
|
|
|
|
type Props = {
|
|
year: GroupedYear
|
|
open: boolean
|
|
onToggle: (year: number) => void
|
|
}
|
|
|
|
export default function TimelineYear({ year, open, onToggle }: Props) {
|
|
const empty = year.count === 0
|
|
const panelId = `site-tl-year-${year.year}`
|
|
|
|
const className = [
|
|
'site-tl__year',
|
|
year.featured ? 'site-tl__year--featured' : '',
|
|
open ? 'site-tl__year--open' : '',
|
|
empty ? 'site-tl__year--empty' : '',
|
|
]
|
|
.filter(Boolean)
|
|
.join(' ')
|
|
|
|
return (
|
|
<div className={className}>
|
|
<button
|
|
type="button"
|
|
className="site-tl__yearBtn"
|
|
aria-expanded={open}
|
|
aria-controls={panelId}
|
|
onClick={() => onToggle(year.year)}
|
|
>
|
|
<span
|
|
className="site-tl__dot"
|
|
style={{ '--tl-dot': dotSize(year.count) } as CSSProperties}
|
|
aria-hidden="true"
|
|
/>
|
|
<span className="site-tl__yearLabel">{year.year}</span>
|
|
<span className="site-tl__yearCount">
|
|
{empty ? '-' : `${year.count} ${year.count === 1 ? 'entry' : 'entries'}`}
|
|
</span>
|
|
</button>
|
|
|
|
{open ? (
|
|
empty ? (
|
|
<div className="site-tl__empty" id={panelId}>
|
|
Nothing recorded for {year.year} yet.
|
|
</div>
|
|
) : (
|
|
<div className="site-tl__panel" id={panelId}>
|
|
{year.featuredItems.length > 0 ? (
|
|
<ul className="site-tl__featured site-tl__list">
|
|
{year.featuredItems.map((item) => (
|
|
<TimelineEntry key={item.id} item={item} variant="featured" />
|
|
))}
|
|
</ul>
|
|
) : null}
|
|
|
|
{year.months.map((month) => (
|
|
<section className="site-tl__month" key={month.month}>
|
|
<h4 className="site-tl__monthLabel">{month.label}</h4>
|
|
<ul className="site-tl__list">
|
|
{month.items.map((item) => (
|
|
<TimelineEntry key={item.id} item={item} />
|
|
))}
|
|
</ul>
|
|
</section>
|
|
))}
|
|
|
|
{year.undated.length > 0 ? (
|
|
<section className="site-tl__month site-tl__undated">
|
|
<h4 className="site-tl__monthLabel">Elsewhere in {year.year}</h4>
|
|
<ul className="site-tl__list">
|
|
{year.undated.map((item) => (
|
|
<TimelineEntry key={item.id} item={item} />
|
|
))}
|
|
</ul>
|
|
</section>
|
|
) : null}
|
|
</div>
|
|
)
|
|
) : null}
|
|
</div>
|
|
)
|
|
}
|