mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
feat(assistant): hike, walk and route cards with their lines on the map, and "Plan this"
This commit is contained in:
@@ -12,6 +12,7 @@ import { HIKE_FACETS, type HikeFacet } from './hikeFacetSpecs';
|
||||
import { facetPaint, isUnknownClass, type FacetRow } from './hikeFacets';
|
||||
import { hikePaintCss } from './hikePaint';
|
||||
import { sacStepOfClass } from './sacGrades';
|
||||
import { GradeChip } from './SacStepChip';
|
||||
import type { HikeWays } from './useHikeWays';
|
||||
|
||||
const percent = (share: number) => `${Math.round(share * 100)} %`;
|
||||
@@ -52,20 +53,8 @@ const writtenTags = (facet: HikeFacet, row: FacetRow) => row.tags.map((tag) => `
|
||||
function ClassChip({ facet, row }: { facet: HikeFacet; row: FacetRow }) {
|
||||
const step = sacStepOfClass(row.key);
|
||||
const unknown = isUnknownClass(row.key);
|
||||
return (
|
||||
<span className="inline-flex h-[18px] w-[34px] flex-none items-center justify-center gap-1 rounded-full bg-surface-card font-geist font-semibold tabular-nums text-content shadow-sm ring-1 ring-inset ring-edge-faint">
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="h-2 w-2 flex-none rounded-full"
|
||||
style={{ background: paintOf(facet, row.key) }}
|
||||
/>
|
||||
{(step !== null || unknown) && (
|
||||
<span className={unknown ? 'text-content-faint' : ''} style={fs(10.5)}>
|
||||
{step === null ? '?' : stepName(step)}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
const text = step !== null ? stepName(step) : unknown ? '?' : null;
|
||||
return <GradeChip color={paintOf(facet, row.key)} text={text} faint={unknown} />;
|
||||
}
|
||||
|
||||
/** Where a row's class comes from, said in its tooltip: what OpenStreetMap wrote, or why it is unknown. */
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* FE-TOUR-SAC-CHIP-001 to FE-TOUR-SAC-CHIP-002
|
||||
*
|
||||
* A grade as the hike's chip: a dot in its map colour beside its short name,
|
||||
* the highest SAC step with a question mark when too little is graded, and a
|
||||
* lone question mark in the grey of the unknown when nothing is.
|
||||
*/
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { GradeChip, SacStepChip } from './SacStepChip';
|
||||
|
||||
const dotOf = (container: HTMLElement) => container.querySelector<HTMLElement>('[aria-hidden="true"]');
|
||||
|
||||
describe('SacStepChip', () => {
|
||||
it('FE-TOUR-SAC-CHIP-001: names the step in its colour, uncertain with a question mark', () => {
|
||||
const { container } = render(<SacStepChip step={3} />);
|
||||
expect(screen.getByText('T3')).toBeInTheDocument();
|
||||
expect(dotOf(container)?.style.background).toBe('var(--hike-sac-t3)');
|
||||
render(<SacStepChip step={4} uncertain />);
|
||||
expect(screen.getByText('T4?')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-TOUR-SAC-CHIP-002: no known step reads as a faint question mark in the grey of the unknown, never as easy', () => {
|
||||
const { container } = render(<SacStepChip step={null} />);
|
||||
expect(screen.getByText('?')).toHaveClass('text-content-faint');
|
||||
expect(dotOf(container)?.style.background).toBe('var(--bike-surface-unknown)');
|
||||
const plain = render(<GradeChip color="var(--hike-way-path)" text={null} />);
|
||||
expect(plain.container.textContent).toBe('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
import { fs } from '../../shared/DialogShell';
|
||||
import { bikePaintCss } from '../bike/bikePaint';
|
||||
import { hikePaintCss } from './hikePaint';
|
||||
|
||||
/**
|
||||
* A grade as the small white chip the hike's card shows it with: a dot in the
|
||||
* colour the map draws it in, and its short name beside it. The classes of a
|
||||
* hike's facets and the SAC step a route reaches share it, so a grade reads
|
||||
* the same in the planner and in the chat.
|
||||
*/
|
||||
|
||||
/** The SAC steps' paints, by step: T1 first. */
|
||||
const SAC_PAINTS = ['t1', 't2', 't3', 't4', 't5', 't6'] as const;
|
||||
|
||||
/** A step's colour as a CSS variable: its own for T1 to T6, the grey of the unknown otherwise. */
|
||||
function sacStepPaint(step: number | null): string {
|
||||
const paint = step === null ? undefined : SAC_PAINTS[step - 1];
|
||||
return paint ? hikePaintCss(paint) : bikePaintCss('unknown');
|
||||
}
|
||||
|
||||
/** The chip: the dot, and the short name when there is one; faint for what the data does not say. */
|
||||
export function GradeChip({ color, text, faint = false }: { color: string; text: string | null; faint?: boolean }) {
|
||||
const width = text !== null && text.length > 2 ? 'px-1.5' : 'w-[34px]';
|
||||
return (
|
||||
<span
|
||||
className={`inline-flex h-[18px] flex-none items-center justify-center gap-1 rounded-full bg-surface-card font-geist font-semibold tabular-nums text-content shadow-sm ring-1 ring-inset ring-edge-faint ${width}`}
|
||||
>
|
||||
<span aria-hidden="true" className="h-2 w-2 flex-none rounded-full" style={{ background: color }} />
|
||||
{text !== null && (
|
||||
<span className={faint ? 'text-content-faint' : ''} style={fs(10.5)}>
|
||||
{text}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The highest SAC step a route reaches ("T3"), with a question mark when too
|
||||
* little of the way is graded to be sure ("T3?"), or a lone question mark
|
||||
* when no step is known at all: an ungraded way never reads as an easy one.
|
||||
*/
|
||||
export function SacStepChip({ step, uncertain = false }: { step: number | null; uncertain?: boolean }) {
|
||||
if (step === null) return <GradeChip color={sacStepPaint(null)} text="?" faint />;
|
||||
return <GradeChip color={sacStepPaint(step)} text={uncertain ? `T${step}?` : `T${step}`} />;
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { SoftPill, WhiteBadge } from '../../Planner/planParts';
|
||||
import { DialogSection, fs } from '../../shared/DialogShell';
|
||||
import { CardAction, TourNotice } from '../tourParts';
|
||||
import { linkName } from './packingLinkName';
|
||||
import { CategoryDot, DimmedLink } from './packingLinkParts';
|
||||
import { CheckCircle, DimmedLink, PackedBar, PackTile } from './packingLinkParts';
|
||||
import { TourPackingLinkDialog } from './TourPackingLinkDialog';
|
||||
import { useTourPackingLink, type TourPackingLinkController } from './useTourPackingLink';
|
||||
|
||||
@@ -30,36 +30,11 @@ function SectionPill({ onClick, icon, children }: { onClick: () => void; icon: R
|
||||
);
|
||||
}
|
||||
|
||||
/** The backpack tile with the item count on its corner, the way a waypoint's number carries its marks. */
|
||||
function PackTile({ count, color }: { count: number; color: string | null }) {
|
||||
return (
|
||||
<span className="relative grid h-9 w-9 flex-none place-items-center rounded-full bg-surface-secondary text-content-muted">
|
||||
<Backpack size={16} strokeWidth={2} aria-hidden="true" />
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute -end-1.5 -top-1.5 grid h-[18px] min-w-[18px] place-items-center rounded-full bg-accent px-1 font-geist font-semibold tabular-nums text-accent-text ring-2 ring-surface-card"
|
||||
style={fs(9.5)}
|
||||
>
|
||||
{count}
|
||||
</span>
|
||||
{color && (
|
||||
<span className="absolute -bottom-0.5 -start-0.5 grid h-3.5 w-3.5 place-items-center rounded-full bg-surface-card">
|
||||
<CategoryDot color={color} />
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/** One item as Packing keeps it, read only: ticked off or not, its name and how many. */
|
||||
function ItemRow({ item }: { item: PackingItem }) {
|
||||
return (
|
||||
<li className="flex min-w-0 items-center gap-2 py-1">
|
||||
<span
|
||||
className={`grid h-4 w-4 flex-none place-items-center rounded-full ${item.checked ? 'bg-accent text-accent-text' : 'ring-1 ring-inset ring-edge'}`}
|
||||
>
|
||||
{!!item.checked && <Check size={10} strokeWidth={3} aria-hidden="true" />}
|
||||
</span>
|
||||
<CheckCircle done={!!item.checked} />
|
||||
<span
|
||||
className={`min-w-0 flex-1 truncate ${item.checked ? 'text-content-faint line-through' : 'text-content-secondary'}`}
|
||||
style={fs(12, 'body')}
|
||||
@@ -109,12 +84,7 @@ function LinkedCard({ packing, onOpenPacking }: { packing: TourPackingLinkContro
|
||||
</div>
|
||||
{total > 0 ? (
|
||||
<>
|
||||
<div className="h-1 overflow-hidden rounded-full bg-surface-secondary" aria-hidden="true">
|
||||
<div
|
||||
className="h-full rounded-full bg-accent transition-[width] duration-300"
|
||||
style={{ width: `${(linked.packed / total) * 100}%` }}
|
||||
/>
|
||||
</div>
|
||||
<PackedBar packed={linked.packed} total={total} />
|
||||
<ul className="m-0 flex list-none flex-col p-0">
|
||||
{linked.items.slice(0, SHOWN_ITEMS).map((item) => (
|
||||
<ItemRow key={item.id} item={item} />
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { TourPackingLink } from '@trek/shared';
|
||||
import { Package, PowerOff } from 'lucide-react';
|
||||
import { Backpack, Check, type LucideIcon, Package, PowerOff } from 'lucide-react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { tintOf, WhiteBadge } from '../../Planner/planParts';
|
||||
import { fs } from '../../shared/DialogShell';
|
||||
import { TourNotice } from '../tourParts';
|
||||
import { linkName } from './packingLinkName';
|
||||
|
||||
@@ -40,3 +41,65 @@ export function CountBadge({ count }: { count: number }) {
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The round tile of a list with its item count on the corner, the way a
|
||||
* waypoint's number carries its marks: a backpack for packing, another glyph
|
||||
* for another list (the chat's to-dos). A category colour sits on the other
|
||||
* corner when the list is one category of it.
|
||||
*/
|
||||
export function PackTile({
|
||||
count,
|
||||
color,
|
||||
icon: Icon = Backpack,
|
||||
}: {
|
||||
count: number;
|
||||
color: string | null;
|
||||
icon?: LucideIcon;
|
||||
}) {
|
||||
return (
|
||||
<span className="relative grid h-9 w-9 flex-none place-items-center rounded-full bg-surface-secondary text-content-muted">
|
||||
<Icon size={16} strokeWidth={2} aria-hidden="true" />
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute -end-1.5 -top-1.5 grid h-[18px] min-w-[18px] place-items-center rounded-full bg-accent px-1 font-geist font-semibold tabular-nums text-accent-text ring-2 ring-surface-card"
|
||||
style={fs(9.5)}
|
||||
>
|
||||
{count}
|
||||
</span>
|
||||
{color && (
|
||||
<span className="absolute -bottom-0.5 -start-0.5 grid h-3.5 w-3.5 place-items-center rounded-full bg-surface-card">
|
||||
<CategoryDot color={color} />
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The round check of a list row: filled once it is done, an empty ring before.
|
||||
* `pending` draws a dashed accent ring around it, for a tick a change has not
|
||||
* made yet.
|
||||
*/
|
||||
export function CheckCircle({ done, pending = false }: { done: boolean; pending?: boolean }) {
|
||||
return (
|
||||
<span
|
||||
className={`grid h-4 w-4 flex-none place-items-center rounded-full ${done ? 'bg-accent text-accent-text' : 'ring-1 ring-inset ring-edge'} ${pending ? 'outline-dashed outline-1 outline-offset-2 outline-accent' : ''}`}
|
||||
>
|
||||
{done && <Check size={10} strokeWidth={3} aria-hidden="true" />}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/** How much of a list is packed, as a thin bar in the accent colour. */
|
||||
export function PackedBar({ packed, total }: { packed: number; total: number }) {
|
||||
const share = total > 0 ? Math.min(1, packed / total) : 0;
|
||||
return (
|
||||
<div className="h-1 overflow-hidden rounded-full bg-surface-secondary" aria-hidden="true">
|
||||
<div
|
||||
className="h-full rounded-full bg-accent transition-[width] duration-300"
|
||||
style={{ width: `${share * 100}%` }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,17 +27,23 @@ function endName(stop: number | undefined, t: Translate): string {
|
||||
return stop === undefined ? t('tours.planner.shapingPoint') : t('tours.planner.waypointLabel', { n: stop });
|
||||
}
|
||||
|
||||
/** How another way differs from the one taken now, in length and time; nothing it cannot say. */
|
||||
function VariantDelta({
|
||||
/**
|
||||
* How another way differs from the one taken now, in length and time; nothing
|
||||
* it cannot say. `hint` names what it is compared with, the way taken now
|
||||
* unless said otherwise.
|
||||
*/
|
||||
export function VariantDelta({
|
||||
variant,
|
||||
current,
|
||||
unit,
|
||||
t,
|
||||
hint,
|
||||
}: {
|
||||
variant: LegVariant;
|
||||
current: LegVariant;
|
||||
unit: DistanceUnit;
|
||||
t: Translate;
|
||||
hint?: string;
|
||||
}) {
|
||||
const delta = variantDelta(variant, current);
|
||||
const parts = [
|
||||
@@ -51,7 +57,7 @@ function VariantDelta({
|
||||
].filter((part) => part.text !== null);
|
||||
if (parts.length === 0) return null;
|
||||
return (
|
||||
<Tooltip label={t('tours.variants.deltaHint')}>
|
||||
<Tooltip label={hint ?? t('tours.variants.deltaHint')}>
|
||||
<span className="flex flex-wrap gap-1" data-testid="leg-variant-delta">
|
||||
{parts.map(({ key, Icon, text }) => (
|
||||
<SoftPill key={key} icon={<Icon size={10} strokeWidth={2.2} aria-hidden="true" />}>
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Day } from '../../../types'
|
||||
import { useTranslation } from '../../../i18n'
|
||||
import { useSettingsStore } from '../../../store/settingsStore'
|
||||
import { useTourFerrataCrossingStore } from '../../../store/tourFerrataCrossingStore'
|
||||
import { formatDistance, formatElevation } from '../../../utils/units'
|
||||
import { formatDistance } from '../../../utils/units'
|
||||
import ConfirmDialog from '../../shared/ConfirmDialog'
|
||||
import { NEUTRAL_TINT, fs } from '../../shared/DialogShell'
|
||||
import EmptyState from '../../shared/EmptyState'
|
||||
@@ -15,7 +15,7 @@ import { BOX } from '../../Planner/bookings/bookingParts'
|
||||
import { BarButton, SoftPill } from '../../Planner/planParts'
|
||||
import TourListRow from '../TourListRow'
|
||||
import ElevationProfile from '../../shared/ElevationProfile'
|
||||
import { formatPlannedTourDuration, hikeSourceBadgeLabel, tourSource } from '../tourPresentation'
|
||||
import { formatPlannedTourDuration, hikeSourceBadgeLabel, profileFocusLabel, tourSource } from '../tourPresentation'
|
||||
import { CardAction, FoldButton, RailCard, RailFacts, TourDayMenu, TourListCard, TourNotice, TourSection, type TourMetricField } from '../tourParts'
|
||||
import { movingTimeLabel, tourMetricFacts, withoutHeights } from '../tourFacts'
|
||||
import { TourDetailsSection, TourNameField } from './TourEditorFields'
|
||||
@@ -40,7 +40,7 @@ import { stageKeysOfTour } from '../stages/stageSpread'
|
||||
import { TourStageOverview } from '../stages/TourStageOverview'
|
||||
import { useTourStageRail } from '../stages/useTourStageRail'
|
||||
import { useTripStore } from '../../../store/tripStore'
|
||||
import type { DistanceIndexedProfileSample, RouteProfileFocus } from '../../../utils/routeGeometry'
|
||||
import type { DistanceIndexedProfileSample } from '../../../utils/routeGeometry'
|
||||
import type { TourPlannerController } from './useTourPlanner'
|
||||
import { RailStatusBadges } from './TourRailStatus'
|
||||
import type { Translate } from './railStatusText'
|
||||
@@ -76,13 +76,6 @@ import { walkTimeFields } from '../walk/walkTimeFields'
|
||||
/** The tinted head band both rails open with, like every panel head in the planner. */
|
||||
export const RAIL_HEAD = 'flex flex-none items-start gap-2 border-b border-edge-faint px-3 py-2.5'
|
||||
|
||||
function profileFocusLabel(focus: RouteProfileFocus, t: Translate, unit: 'metric' | 'imperial'): string {
|
||||
return t('tours.planner.inspector.profileFocus', {
|
||||
distance: formatDistance(focus.distanceMeters / 1000, unit),
|
||||
elevation: focus.elevationMeters == null ? '-' : formatElevation(focus.elevationMeters, unit),
|
||||
})
|
||||
}
|
||||
|
||||
/** The title of a rail's head band, with an optional line under it. */
|
||||
export function RailTitle({ title, sub, aside }: { title: string; sub?: ReactNode; aside?: ReactNode }) {
|
||||
return (
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// FE-TOUR-LEG-VARIANT-PAINT-001 to FE-TOUR-LEG-VARIANT-PAINT-004: the ways of a compared section
|
||||
// FE-TOUR-LEG-VARIANT-PAINT-001 to FE-TOUR-LEG-VARIANT-PAINT-005: the ways of a compared section
|
||||
// and the round hikes offered on the planner map, each in its colour, the one in focus on top
|
||||
// (RTE-02, RTE-03).
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
||||
import { drawOrder, useLegVariantLines, variantPaintCss } from './legVariantPaint';
|
||||
import { drawOrder, useLegVariantLines, useVariantPaint, variantPaintCss } from './legVariantPaint';
|
||||
import type { LegVariant } from './legVariants';
|
||||
|
||||
const variant = (key: LegVariant['key'], lat: number): LegVariant => ({
|
||||
@@ -87,4 +87,15 @@ describe('legVariantPaint', () => {
|
||||
const empty = renderHook(() => useLegVariantLines([], null, null, rounds, null));
|
||||
expect(empty.result.current.route).toEqual([WAYS[1].coordinates, WAYS[2].coordinates]);
|
||||
});
|
||||
|
||||
it('FE-TOUR-LEG-VARIANT-PAINT-005: hands the colours of the ways and their rim resolved, for a map outside the planner', () => {
|
||||
const { result } = renderHook(() => useVariantPaint());
|
||||
expect(result.current).toEqual({
|
||||
current: '#0a84ff',
|
||||
a: '#f97316',
|
||||
b: '#d946ef',
|
||||
c: '#14b8a6',
|
||||
casing: '#ffffff',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,6 +23,11 @@ export function variantPaintCss(key: LegVariantKey): string {
|
||||
return `var(${VARIANT_PAINT_TOKENS[key]})`;
|
||||
}
|
||||
|
||||
/** The ways' colours and their rim resolved for map paint, again whenever the theme changes. */
|
||||
export function useVariantPaint(): Readonly<Record<LegVariantKey | 'casing', string>> {
|
||||
return useMapPaint(VARIANT_PAINT_TOKENS);
|
||||
}
|
||||
|
||||
type Drawn = Parameters<typeof withRouteHighlight>;
|
||||
/** A way as the map draws it: its line and the key its colour goes by. */
|
||||
type DrawnWay = Pick<LegVariant, 'key' | 'coordinates'>;
|
||||
@@ -60,7 +65,7 @@ export function useLegVariantLines(
|
||||
variants: readonly DrawnWay[] | null,
|
||||
focus: LegVariantKey | null
|
||||
) {
|
||||
const paint = useMapPaint(VARIANT_PAINT_TOKENS);
|
||||
const paint = useVariantPaint();
|
||||
return useMemo(() => {
|
||||
const ordered = variants ? drawOrder(variants, focus) : [];
|
||||
const highlight = ordered.length
|
||||
|
||||
@@ -48,7 +48,7 @@ export function StopDisc({ stop }: { stop: number | undefined }) {
|
||||
* the route's own icon, the others by their letter. The chosen one carries a
|
||||
* tick at its corner.
|
||||
*/
|
||||
function VariantMark({ variant, chosen }: { variant: Pick<LegVariant, 'key' | 'current'>; chosen: boolean }) {
|
||||
export function VariantMark({ variant, chosen }: { variant: Pick<LegVariant, 'key' | 'current'>; chosen: boolean }) {
|
||||
return (
|
||||
<span
|
||||
className="relative grid h-7 w-7 flex-none place-items-center rounded-full font-geist font-bold uppercase shadow-sm"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { estimateBadgeText, estimateLabel, filterTours, formatPlannedTourDuration, hikeSourceBadgeLabel, plannedTotalText, tourDayMinutes, tourPlannedTimes, tourSource, tourWebsitePresentation } from './tourPresentation'
|
||||
import { estimateBadgeText, estimateLabel, filterTours, formatPlannedTourDuration, hikeSourceBadgeLabel, plannedTotalText, profileFocusLabel, tourDayMinutes, tourPlannedTimes, tourSource, tourWebsitePresentation } from './tourPresentation'
|
||||
|
||||
describe('tourPresentation', () => {
|
||||
it('formats planned Tour totals using the shared compact duration formatter', () => {
|
||||
@@ -128,4 +128,11 @@ describe('tourPresentation', () => {
|
||||
('does not classify unsafe URL %s', value => {
|
||||
expect(tourWebsitePresentation(value)).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-TOUR-PRES-001: says a spot of the profile by how far along and how high, without a height where none is known', () => {
|
||||
const t = vi.fn((key: string, params?: Record<string, unknown>) => `${key} ${params?.distance} ${params?.elevation}`)
|
||||
const focus = { distanceMeters: 2500, elevationMeters: 1234.4, lat: 47.6, lng: 12.6, sampleIndex: 3 }
|
||||
expect(profileFocusLabel(focus, t, 'metric')).toBe('tours.planner.inspector.profileFocus 2.5 km 1234 m')
|
||||
expect(profileFocusLabel({ ...focus, elevationMeters: null }, t, 'metric')).toBe('tours.planner.inspector.profileFocus 2.5 km -')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { TourListItem, TourOrigin } from '@trek/shared'
|
||||
import { tourTimeEstimate, tourWebsiteSchema, type TourTimeEstimate } from '@trek/shared'
|
||||
import { formatDurationShort } from '@trek/shared/roadtrip'
|
||||
import type { RouteProfileFocus } from '../../utils/routeGeometry'
|
||||
import { formatDistance, formatElevation } from '../../utils/units'
|
||||
import { walkTimesOf, type WalkTimes } from './planner/stationModel'
|
||||
import type { TourMetricField } from './tourParts'
|
||||
|
||||
@@ -207,3 +209,15 @@ export function statusLabel(status: TourFilter, t: Translate): string {
|
||||
if (status === 'planned') return t('places.planned')
|
||||
return t('places.all')
|
||||
}
|
||||
|
||||
/**
|
||||
* A spot of a route's height profile in words, as the planner's profile and
|
||||
* the chat's tour card both say it: how far along, and how high where the
|
||||
* heights are known.
|
||||
*/
|
||||
export function profileFocusLabel(focus: RouteProfileFocus, t: Translate, unit: 'metric' | 'imperial'): string {
|
||||
return t('tours.planner.inspector.profileFocus', {
|
||||
distance: formatDistance(focus.distanceMeters / 1000, unit),
|
||||
elevation: focus.elevationMeters == null ? '-' : formatElevation(focus.elevationMeters, unit),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user