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
69
src/pages/sections/history/TimelineUpcoming.tsx
Normal file
69
src/pages/sections/history/TimelineUpcoming.tsx
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import { useState } from 'react'
|
||||
import type { GroupedYear, SortDirection } from '../../../lib/timeline'
|
||||
import TimelineYear from './TimelineYear'
|
||||
|
||||
type Props = {
|
||||
years: GroupedYear[]
|
||||
count: number
|
||||
direction?: SortDirection
|
||||
openYears: Set<number>
|
||||
onToggleYear: (year: number) => void
|
||||
}
|
||||
|
||||
/**
|
||||
* Scheduled but not yet happened. Sits above the most recent decade and
|
||||
* opens upward: the toggle is first in the DOM and the list is rendered
|
||||
* after it, with `flex-direction: column-reverse` flipping the visual
|
||||
* order. That keeps the button anchored next to the decade marker
|
||||
* instead of drifting up the page as items appear.
|
||||
*
|
||||
* Membership is decided by date, not by a flag — see partitionByDate.
|
||||
* An event moves into the record on its own, with nothing to update.
|
||||
*/
|
||||
export default function TimelineUpcoming({
|
||||
years,
|
||||
count,
|
||||
direction = 'desc',
|
||||
openYears,
|
||||
onToggleYear,
|
||||
}: Props) {
|
||||
const [open, setOpen] = useState(false)
|
||||
if (count === 0) return null
|
||||
|
||||
return (
|
||||
<section
|
||||
className={`ngu-tl__upcoming${open ? ' ngu-tl__upcoming--open' : ''}`}
|
||||
aria-label="Upcoming"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className="ngu-tl__upcomingBtn"
|
||||
aria-expanded={open}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
>
|
||||
<span className="ngu-tl__upcomingDot" aria-hidden="true" />
|
||||
<span className="ngu-tl__upcomingLabel">
|
||||
{open
|
||||
? 'Hide what’s scheduled'
|
||||
: `${count} ${count === 1 ? 'thing' : 'things'} still to come`}
|
||||
</span>
|
||||
<span className="ngu-tl__chevron" aria-hidden="true">
|
||||
{open ? '▾' : '▴'}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{open ? (
|
||||
<div className="ngu-tl__upcomingList">
|
||||
{years.map((year) => (
|
||||
<TimelineYear
|
||||
key={year.year}
|
||||
year={year}
|
||||
open={openYears.has(year.year)}
|
||||
onToggle={onToggleYear}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue