NGU-Web/src/pages/sections/history/TimelineUpcoming.tsx
Zaldimmar 706abf6a03 Replace the last glyph icons with Phosphor
The editor's insert, duplicate and remove buttons, the image
library's close button and audio tile, the schedule's fold-out caret,
the admin menu's caret, the history timeline's caret and gap marker,
and the QR page's copied tick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:43:48 -05:00

70 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 } 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__upcomingDot" aria-hidden="true" />
<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>
)
}