NGU-Web/src/pages/sections/history/TimelineUpcoming.tsx
Zaldimmar d5428297a4 Timeline years as leaves, green now and turning autumn going back; notices instead of dashed boxes
A year's leaf eases from green to gold to autumn between this year
and 2000 (leafColor in color.ts); every year before 2000 is fully
turned. Empty-section and form notes use one notice style, a flat
tinted panel with a solid left bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 14:53:50 -05:00

72 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { CaretDown, CaretUp, Leaf } from '@phosphor-icons/react'
import { useState } from 'react'
import type { GroupedYear, SortDirection } from '../../../lib/timeline.ts'
import TimelineYear from './TimelineYear.tsx'
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={`site-tl__upcoming${open ? ' site-tl__upcoming--open' : ''}`}
aria-label="Upcoming"
>
<button
type="button"
className="site-tl__upcomingBtn"
aria-expanded={open}
onClick={() => setOpen((v) => !v)}
>
<span className="site-tl__upcomingLeaf" aria-hidden="true">
<Leaf weight="bold" />
</span>
<span className="site-tl__upcomingLabel">
{open
? 'Hide what’s scheduled'
: `${count} ${count === 1 ? 'thing' : 'things'} still to come`}
</span>
<span className="site-tl__chevron" aria-hidden="true">
{open ? <CaretDown weight="bold" /> : <CaretUp weight="bold" />}
</span>
</button>
{open ? (
<div className="site-tl__upcomingList">
{years.map((year) => (
<TimelineYear
key={year.year}
year={year}
open={openYears.has(year.year)}
onToggle={onToggleYear}
/>
))}
</div>
) : null}
</section>
)
}