import { useTranslation } from '../../i18n' import { Tooltip } from '../shared/Tooltip' import DawarichIcon from '../shared/DawarichIcon' import { MAP_CONTROL_SHADOW } from './mapControlShadow' import type { DawarichTrailStatus } from './useDawarichTrail' /** * Toggle for the recorded-route overlay (#2279), in the same frosted shell as * the compass, the layer switcher and the trip-route overview so the map's * controls stay one family. * * The status rides on the button rather than in a banner: the states that * matter — loading, nothing recorded for these dates, instance unreachable, * device offline — are all answers to "why is there no line", and the place * someone looks for that answer is the control they just pressed. */ export function DawarichTrailPill({ active, status, onToggle, }: { active: boolean status: DawarichTrailStatus onToggle: () => void }) { const { t } = useTranslation() const label = !active ? t('dawarich.trail.show') : status === 'loading' ? t('dawarich.trail.loading') : status === 'empty' ? t('dawarich.trail.empty') : status === 'offline' ? t('dawarich.trail.offline') : status === 'unavailable' ? t('dawarich.trail.unavailable') : t('dawarich.trail.hide') // A problem worth seeing without reading the tooltip: the layer is on and // there is nothing to show. const muted = active && (status === 'empty' || status === 'offline' || status === 'unavailable') // Loading has to be visible too. A first fetch from somebody's own server can // take a while, and with nothing on the button it looked exactly like "done, // but no line", so testers reloaded the page to find out. const loading = active && status === 'loading' return (