v1.5 - history and timeline as well as many datastructure updates added, polished, fixes
This commit is contained in:
parent
1f0aa3078f
commit
1d84400aef
63 changed files with 7927 additions and 208 deletions
90
src/pages/sections/history/TimelineYear.tsx
Normal file
90
src/pages/sections/history/TimelineYear.tsx
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import type { CSSProperties } from 'react'
|
||||
import type { GroupedYear } from '../../../lib/timeline'
|
||||
import TimelineEntry from './TimelineEntry'
|
||||
|
||||
/** Dot diameter scales with volume, so the rail reads as a density chart. */
|
||||
function dotSize(count: number): string {
|
||||
return `${(7 + Math.min(count, 14) * 0.55).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 = `ngu-tl-year-${year.year}`
|
||||
|
||||
const className = [
|
||||
'ngu-tl__year',
|
||||
year.featured ? 'ngu-tl__year--featured' : '',
|
||||
open ? 'ngu-tl__year--open' : '',
|
||||
empty ? 'ngu-tl__year--empty' : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<button
|
||||
type="button"
|
||||
className="ngu-tl__yearBtn"
|
||||
aria-expanded={open}
|
||||
aria-controls={panelId}
|
||||
onClick={() => onToggle(year.year)}
|
||||
>
|
||||
<span
|
||||
className="ngu-tl__dot"
|
||||
style={{ '--tl-dot': dotSize(year.count) } as CSSProperties}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="ngu-tl__yearLabel">{year.year}</span>
|
||||
<span className="ngu-tl__yearCount">
|
||||
{empty ? '—' : `${year.count} ${year.count === 1 ? 'entry' : 'entries'}`}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{open ? (
|
||||
empty ? (
|
||||
<div className="ngu-tl__empty" id={panelId}>
|
||||
Nothing recorded for {year.year} yet.
|
||||
</div>
|
||||
) : (
|
||||
<div className="ngu-tl__panel" id={panelId}>
|
||||
{year.featuredItems.length > 0 ? (
|
||||
<ul className="ngu-tl__featured ngu-tl__list">
|
||||
{year.featuredItems.map((item) => (
|
||||
<TimelineEntry key={item.id} item={item} variant="featured" />
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
|
||||
{year.months.map((month) => (
|
||||
<section className="ngu-tl__month" key={month.month}>
|
||||
<h4 className="ngu-tl__monthLabel">{month.label}</h4>
|
||||
<ul className="ngu-tl__list">
|
||||
{month.items.map((item) => (
|
||||
<TimelineEntry key={item.id} item={item} />
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
))}
|
||||
|
||||
{year.undated.length > 0 ? (
|
||||
<section className="ngu-tl__month ngu-tl__undated">
|
||||
<h4 className="ngu-tl__monthLabel">Elsewhere in {year.year}</h4>
|
||||
<ul className="ngu-tl__list">
|
||||
{year.undated.map((item) => (
|
||||
<TimelineEntry key={item.id} item={item} />
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue