From 305b00ae013120a722ad3626d228eab67b2532ef Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 8 Nov 2026 12:30:12 +0100 Subject: [PATCH] fix(mobile): on a narrow 3D map the flyover controls and grade legend stand as a column of icons on the side, the layer pill keeps the bottom row; and the lint ratchets the last push tipped --- client/src/components/Map/MapView.tsx | 2 +- client/src/components/Map/MapViewGL.tsx | 2 +- .../src/components/Map/VectorBasemap.test.tsx | 6 +- client/src/components/Map/VectorBasemap.tsx | 3 +- .../Tours/terrain/TourTerrainMap.tsx | 162 ++++++++++++++---- 5 files changed, 138 insertions(+), 37 deletions(-) diff --git a/client/src/components/Map/MapView.tsx b/client/src/components/Map/MapView.tsx index ba016d915..3a1792e45 100644 --- a/client/src/components/Map/MapView.tsx +++ b/client/src/components/Map/MapView.tsx @@ -1126,7 +1126,7 @@ export const MapView = memo(function MapView({ {/* 20px off the sidebar, not 12: the pill is round and frosted, so at the smaller gap its shadow ran into the sidebar edge and the two read as one surface. */} -
+
{onToggleFollow && } {hasViewBaseLayer ? { const { findByTestId, queryByTestId } = render() await waitFor(() => expect(maplibreGL).toHaveBeenCalledTimes(1)) const { layer, gl } = lastLayer() - const onError = gl.on.mock.calls.find(([name]) => name === 'error')![1] as (e: { error?: unknown }) => void + const onError = gl.on.mock.calls.find(([name]) => name === 'error')?.[1] as (e: { error?: unknown }) => void expect(gl.once).toHaveBeenCalledWith('style.load', expect.any(Function)) expect(queryByTestId('raster-basemap')).toBeNull() @@ -146,8 +146,8 @@ describe('VectorBasemap', () => { render() await waitFor(() => expect(maplibreGL).toHaveBeenCalledTimes(2)) const second = lastLayer() - const secondError = second.gl.on.mock.calls.find(([name]) => name === 'error')![1] as (e: { error?: unknown }) => void - ;(second.gl.once.mock.calls.find(([name]) => name === 'style.load')![1] as () => void)() + const secondError = second.gl.on.mock.calls.find(([name]) => name === 'error')?.[1] as (e: { error?: unknown }) => void + ;(second.gl.once.mock.calls.find(([name]) => name === 'style.load')?.[1] as () => void)() act(() => secondError({ error: new Error('one tile') })) expect(second.layer.remove).not.toHaveBeenCalled() warn.mockRestore() diff --git a/client/src/components/Map/VectorBasemap.tsx b/client/src/components/Map/VectorBasemap.tsx index eeca7fdbb..daba7db29 100644 --- a/client/src/components/Map/VectorBasemap.tsx +++ b/client/src/components/Map/VectorBasemap.tsx @@ -118,10 +118,9 @@ function onStyleFailure(layer: GlLeafletLayer, fail: () => void): void { gl.once('style.load', () => { loaded = true }) - const onError = (event: { error?: unknown }) => { + const onError = () => { if (loaded) return gl.off('error', onError) - console.warn('[basemap] the vector style did not load, drawing raster tiles', event.error) fail() } gl.on('error', onError) diff --git a/client/src/components/Tours/terrain/TourTerrainMap.tsx b/client/src/components/Tours/terrain/TourTerrainMap.tsx index 52d345d48..b10ae8fa5 100644 --- a/client/src/components/Tours/terrain/TourTerrainMap.tsx +++ b/client/src/components/Tours/terrain/TourTerrainMap.tsx @@ -90,8 +90,9 @@ export default function TourTerrainMap(props: TourTerrainMapProps) { terrain.canReplay && !props.water ? ( ) : null; - const legendAbove = fit === 'stacked' || fit === 'side'; - const layerSwitcher = (vertical: boolean) => ( + const side = fit === 'side'; + const legendAbove = fit === 'stacked'; + const layerSwitcher = ( ); @@ -127,28 +127,38 @@ export default function TourTerrainMap(props: TourTerrainMapProps) { insetInlineEnd: rightWidth + MAP_LAYER_SWITCHER_INSET, }} > - {fit === 'side' && layerSwitcher(true)} + {/* Too narrow for one row (an iPad beside the tour pane): the flyover controls + and the grade legend stand on the trailing edge as one column of icons, and + the bottom row keeps the layer pill alone. */} + {side && ( +
+ {legend} + {terrain.canReplay && } +
+ )} {legendAbove && legend}
- {fit !== 'side' &&
{layerSwitcher(false)}
} -
- - {terrain.canReplay ? ( - - ) : touchShell ? ( - // A tablet's map is short on room, and its user learns the gestures by touch: no how-to line. +
{layerSwitcher}
+ {!side && ( +
- ) : ( -
- -
- )} -
{!legendAbove && legend}
-
+ {terrain.canReplay ? ( + + ) : touchShell ? ( + // A tablet's map is short on room, and its user learns the gestures by touch: no how-to line. + + ) : ( +
+ +
+ )} +
{!legendAbove && legend}
+
+ )}
@@ -214,21 +224,89 @@ function IconButton({ ); } -function Divider() { - return ; +function Divider({ vertical = false }: { vertical?: boolean }) { + return ; +} + +type TerrainControls = Omit, 'setContainer'>; + +/** The relief steps the column's relief button goes through, a tap each. */ +const RELIEF_STEPS = [1, 1.5, 2, 3] as const; + +/** The next step after `value` in `steps`, round again after the last. */ +function nextStep(steps: readonly T[], value: number): T { + const at = steps.findIndex((step) => step >= value - 0.001); + return steps[at < 0 || at === steps.length - 1 ? 0 : at + 1]; +} + +/** The column's half after play, restart and overview: speed and relief a tap each, the grade switch as its icon. */ +function DockColumnTail({ terrain, water }: { terrain: TerrainControls; water?: boolean }) { + const { t } = useTranslation(); + const grade = terrain.colorMode === 'grade'; + return ( + <> + + + + + + + + {!water && ( + <> + + + + + + )} + + ); } /** One pill like the layer switcher: play, restart, overview · speed · relief · colour (not on water). */ function TerrainDock({ terrain, water, + vertical = false, }: { - terrain: Omit, 'setContainer'>; + terrain: TerrainControls; water?: boolean; + /** A column of icons on the map's trailing edge (the `side` fit). */ + vertical?: boolean; }) { const { t } = useTranslation(); return ( -
+
{terrain.preloaded < 1 ? ( + {vertical ? : } +
+ ); +} + +/** The row's half after play, restart and overview: the speeds, the relief slider and the grade switch. */ +function DockRowTail({ terrain, water }: { terrain: TerrainControls; water?: boolean }) { + const { t } = useTranslation(); + return ( + <>
{SPEEDS.map((speed) => ( @@ -283,7 +371,7 @@ function TerrainDock({ {!water && } -
+ ); } @@ -409,7 +497,7 @@ function GradeLegend({
{compact && ( @@ -439,12 +527,26 @@ function GradeLegend({ aria-expanded={open} aria-controls="tour-terrain-grades" aria-label={t('tours.terrain.gradeMix')} - className="flex h-[42px] items-center gap-2 rounded-full pe-2 ps-3" + className={ + compact + ? 'flex w-[42px] flex-col items-center gap-2 rounded-full pb-1 pt-3' + : 'flex h-[42px] items-center gap-2 rounded-full pe-2 ps-3' + } style={GLASS} > - + {GRADE_BANDS.map((band) => ( - + ))} {!compact && }