OpenDataVisualizer/client/src/components/watercraft/YearControls.tsx
Claudio Schaad 39a62255af Add Thurgau watercraft map (#2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
2026-11-06 21:10:01 +00:00

56 lines
1.4 KiB
TypeScript

import type { YearInfo } from '../../api/watercraft';
import { formatDate } from '../../traffic/format';
interface YearControlsProps {
years: YearInfo[];
year: number;
playing: boolean;
onYearChange: (year: number) => void;
onPlayingChange: (playing: boolean) => void;
}
export function YearControls({
years,
year,
playing,
onYearChange,
onPlayingChange,
}: YearControlsProps) {
const current = years.find((y) => y.year === year);
return (
<div className="time-controls year-controls">
<button
type="button"
className="play-button"
onClick={() => onPlayingChange(!playing)}
disabled={years.length < 2}
aria-label={playing ? 'Pause' : 'Jahre abspielen'}
title={playing ? 'Pause' : 'Jahre abspielen'}
>
{playing ? '❚❚' : '▶'}
</button>
<div className="year-buttons" role="radiogroup" aria-label="Jahr">
{years.map((y) => (
<button
key={y.year}
type="button"
role="radio"
aria-checked={y.year === year}
className={y.year === year ? 'active' : ''}
onClick={() => onYearChange(y.year)}
>
{y.year}
</button>
))}
</div>
<span className="year-reference">
{current?.referenceDate
? `Stichtag ${formatDate(current.referenceDate, { weekday: undefined })}`
: ''}
</span>
</div>
);
}