import { Route } from 'lucide-react' import { useTranslation } from '../../i18n' import { Tooltip } from '../shared/Tooltip' import { profileIcon } from '../Planner/DayPlanSidebarRouteConnector' import { formatDistance } from '../../utils/units' import { MAP_CONTROL_SHADOW } from './mapControlShadow' import type { TripRouteOverview as Overview } from './useTripRouteOverview' import type { DistanceUnit } from '../../types' /** * Toggle for the whole-trip route overview (#1736). Same frosted shell as the other * map controls, so it lines up with the compass and the layer switcher. */ export function TripRouteOverviewPill({ active, onToggle }: { active: boolean; onToggle: () => void }) { const { t } = useTranslation() const label = active ? t('map.overview.hide') : t('map.overview.show') return (
{/* TREK's own tooltip, not the browser's — the native one ignores the colour scheme, waits a second and a half, and cannot be read on a touch device at all. `left`, because these controls hug the right edge of the map and a tooltip to the right would hang off it. */}
) } /** * The trip's stages and its total distance, read off the overview the map is drawing. * * One component for both shells: the phone and the desktop place it differently but the * rows are the same rows, and a second copy of them is a second thing to keep in step. */ export function TripRouteOverviewPanel({ overview, unit, selectedDayId, onSelectDay, maxWidth = 320 }: { overview: Overview unit: DistanceUnit selectedDayId?: number | null onSelectDay?: (dayId: number) => void /** How wide the card may grow before day names start to ellipsize. */ maxWidth?: number }) { const { t } = useTranslation() if (!overview.days.length) return null return (
{t('map.overview.total')} {/* Same tier as the label beside it: the two read as one line rather than as a heading with a number stuck under it. */} {formatDistance(overview.totalDistance / 1000, unit)} {/* Still routing: the number is a partial sum, and saying so beats a total that silently grows while you read it. */} {overview.loading && {' '}…}
{overview.days.map(day => { const label = day.title || t('dayplan.dayN', { n: day.dayNumber }) const row = ( <> {label} {day.modes.map(mode => { const Icon = profileIcon(mode) return })} {formatDistance(day.distance / 1000, unit)} ) const style = { display: 'flex', alignItems: 'center', gap: 8, width: '100%', padding: '7px 14px', textAlign: 'left' as const, fontSize: 'calc(12px * var(--fs-scale-body, 1))', background: day.dayId === selectedDayId ? 'var(--bg-hover)' : 'transparent', border: 'none', } return onSelectDay ? ( ) : (
{row}
) })}
) }