Files
box-box/frontend/src/components/TabBar.tsx

44 lines
1.0 KiB
TypeScript
Raw Normal View History

2026-05-25 02:56:06 -04:00
export type Tab =
2026-05-25 12:35:08 -04:00
| 'overview'
| 'race_story'
2026-05-25 02:56:06 -04:00
| 'strategy'
| 'compare'
2026-05-25 12:35:08 -04:00
| 'lap_data'
| 'conditions'
2026-05-25 02:56:06 -04:00
| 'race_control'
2026-05-25 12:35:08 -04:00
| 'data_status'
2026-05-25 01:20:04 -04:00
const TABS: { id: Tab; label: string }[] = [
2026-05-25 12:35:08 -04:00
{ id: 'overview', label: 'Overview' },
{ id: 'race_story', label: 'Race Story' },
2026-05-25 01:20:04 -04:00
{ id: 'strategy', label: 'Strategy' },
{ id: 'compare', label: 'Compare' },
2026-05-25 12:35:08 -04:00
{ id: 'lap_data', label: 'Lap Data' },
{ id: 'conditions', label: 'Conditions' },
2026-05-25 02:56:06 -04:00
{ id: 'race_control', label: 'Race Control' },
2026-05-25 12:35:08 -04:00
{ id: 'data_status', label: 'Data Status' },
2026-05-25 01:20:04 -04:00
]
interface Props {
active: Tab
onChange: (tab: Tab) => void
}
export function TabBar({ active, onChange }: Props) {
return (
<div className="tab-bar" role="tablist">
{TABS.map((t) => (
<button
key={t.id}
role="tab"
aria-selected={active === t.id}
className={`tab-btn${active === t.id ? ' active' : ''}`}
onClick={() => onChange(t.id)}
>
{t.label}
</button>
))}
</div>
)
}