mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
54 lines
2.0 KiB
TypeScript
54 lines
2.0 KiB
TypeScript
import React from 'react'
|
|
import { CalendarDays, Route } from 'lucide-react'
|
|
import { useTranslation } from '../../i18n/TranslationContext'
|
|
import { NEUTRAL_TINT } from '../shared/DialogShell'
|
|
|
|
interface RoadtripModeSwitchProps {
|
|
active: boolean
|
|
onChange: (roadtrip: boolean) => void
|
|
}
|
|
|
|
/**
|
|
* Switches the plan view's left rail between the day plan and the road trip reading of
|
|
* the same trip. Only rendered while the road trip addon is on, so a trip that isn't
|
|
* driven anywhere never grows a control it has no use for. It opens the rail's tinted
|
|
* head band, so with the day plan's tools below it the two read as one band.
|
|
*/
|
|
export default function RoadtripModeSwitch({ active, onChange }: RoadtripModeSwitchProps): React.ReactElement {
|
|
const { t } = useTranslation()
|
|
const options: [boolean, string, typeof Route][] = [
|
|
[false, t('roadtrip.mode.days'), CalendarDays],
|
|
[true, t('roadtrip.mode.roadtrip'), Route],
|
|
]
|
|
return (
|
|
<div className="trek-desktop-panel flex-none px-3 pb-1 pt-3" style={{ background: NEUTRAL_TINT }}>
|
|
<div
|
|
role="tablist"
|
|
aria-label={t('roadtrip.mode.label')}
|
|
className="flex gap-1 rounded-xl border border-edge-faint bg-surface-tertiary p-1"
|
|
>
|
|
{options.map(([value, label, Icon]) => {
|
|
const selected = active === value
|
|
return (
|
|
<button
|
|
key={label}
|
|
type="button"
|
|
role="tab"
|
|
aria-selected={selected}
|
|
onClick={() => onChange(value)}
|
|
className={`flex h-[30px] min-w-0 flex-1 items-center justify-center gap-1.5 rounded-lg px-2 text-control transition-colors ${
|
|
selected
|
|
? 'bg-surface-card font-semibold text-content shadow-card'
|
|
: 'font-medium text-content-muted hover:bg-surface-hover hover:text-content'
|
|
}`}
|
|
>
|
|
<Icon size={13} strokeWidth={1.8} aria-hidden />
|
|
<span className="truncate">{label}</span>
|
|
</button>
|
|
)
|
|
})}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|