fix(maps): the phone map carries no credit and no night pause labels

The credit was a round (i) under the locate button, and on a full-bleed phone map a
lone control there is the first thing the eye lands on. It is off on the phone now:
one rule in mobile.css against both engines' containers, so Leaflet, MapLibre and
Mapbox cannot drift apart. The desktop map is untouched and still shows the full
credit with its links. Owner's call, made knowingly.

With the credit gone the band the round controls floated on had nothing under it to
clear, so the 38px credit row comes out of --bottom-nav-h and out of the camera
padding the offered roads are framed with. The controls now stand on the map floor.

The night pause pills go with it. On the desktop one is a drag handle with a hint;
a phone has neither hover to explain it nor room to drag, and the markers come from
the whole drive rather than the stage on screen, so day 1 drew day 2's pill as well.
Both via lists go through the same filter, because the plan tab carries them too.
This commit is contained in:
Maurice
2026-09-17 12:43:45 +02:00
parent 222313d198
commit 782bb365b5
7 changed files with 97 additions and 327 deletions
@@ -1,45 +0,0 @@
// FE-MAP-ATTRIB-001 to FE-MAP-ATTRIB-003
import { fireEvent, render } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import MapAttributionToggle from './MapAttributionToggle'
// Outside a TranslationProvider t(key) echoes the key, so the label is asserted as its key.
const BAND = 'calc(var(--bottom-nav-h, 84px) + 12px)'
describe('MapAttributionToggle', () => {
it('FE-MAP-ATTRIB-001: it follows a credit corner where the map has one, and keeps the locate band where it has not', () => {
const { getByRole } = render(<MapAttributionToggle open={false} onToggle={() => {}} bottomOffset={BAND} />)
const style = getByRole('button').style
// Both numbers come from the map around it first. A map without a credit corner
// defines neither variable, so the fallbacks are the old slot beside the locate button.
expect(style.right).toBe('var(--m-credit-right, 62px)')
expect(style.bottom).toBe(`var(--m-credit-bottom, ${BAND})`)
})
it('FE-MAP-ATTRIB-002: it is labelled, says whether the credit is open, and toggles once per tap', () => {
const onToggle = vi.fn()
const { getByRole, rerender } = render(<MapAttributionToggle open={false} onToggle={onToggle} bottomOffset={BAND} />)
const button = getByRole('button')
expect(button.getAttribute('title')).toBe('map.attribution')
expect(button.getAttribute('aria-label')).toBe('map.attribution')
expect(button.getAttribute('aria-expanded')).toBe('false')
fireEvent.click(button)
expect(onToggle).toHaveBeenCalledTimes(1)
rerender(<MapAttributionToggle open onToggle={onToggle} bottomOffset={BAND} />)
expect(getByRole('button').getAttribute('aria-expanded')).toBe('true')
})
it('FE-MAP-ATTRIB-003: wherever it sits, it stays above the Leaflet control corners', () => {
const { getByRole } = render(<MapAttributionToggle open={false} onToggle={() => {}} bottomOffset={BAND} />)
const style = getByRole('button').style
// index.css pins `.leaflet-bottom` to z-index 1, and the open credit lives in that
// corner. The (i) sits in the same row now, so it has to stay the one on top.
expect(style.position).toBe('absolute')
expect(style.zIndex).toBe('1000')
})
})
@@ -1,64 +0,0 @@
import { Info } from 'lucide-react'
import { MAP_CONTROL_SHADOW } from './mapControlShadow'
import { useTranslation } from '../../i18n'
interface MapAttributionToggleProps {
open: boolean
onToggle: () => void
/**
* Where the (i) sits on a map that defines no credit corner: the locate button's band,
* so the two share a line.
*/
bottomOffset: string
}
/**
* The little (i) that stands in for the credit on a phone.
*
* Both GL engines ship one of these: below 640px they collapse their attribution to a
* button and open it on a tap. Leaflet has no such mode, so on a screen the map fills,
* its credit is a white two-line block parked in the middle of the picture. This is the
* missing half of that pattern, and it is a React button rather than surgery on
* Leaflet's own container because Leaflet rewrites that container's markup from scratch
* whenever a layer with an attribution is added or removed.
*
* Nothing is hidden that cannot be read: one tap shows the full credit, every link in
* it included, which is the same bargain the GL engines strike.
*/
export default function MapAttributionToggle({ open, onToggle, bottomOffset }: MapAttributionToggleProps) {
const { t } = useTranslation()
const label = t('map.attribution')
return (
<button
type="button"
onClick={onToggle}
title={label}
aria-label={label}
aria-expanded={open}
style={{
position: 'absolute',
// A map that gives the credit a corner of its own (the phone trip map, see
// `m-credit-corner` in mobile.css) places the (i) through these two variables, the
// same two its GL engines are placed by. Every other map defines neither, so the
// fallbacks keep the button where it always was: in the locate button's band,
// clear of that button at right: 12 plus its 42, with a gap.
bottom: `var(--m-credit-bottom, ${bottomOffset})`,
right: 'var(--m-credit-right, 62px)',
zIndex: 1000,
width: 30,
height: 30,
borderRadius: '50%',
border: 'none',
cursor: 'pointer',
background: 'var(--bg-card, white)',
color: 'var(--text-muted, #6b7280)',
boxShadow: MAP_CONTROL_SHADOW,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Info size={15} strokeWidth={2.2} aria-hidden="true" />
</button>
)
}
+6 -16
View File
@@ -989,29 +989,19 @@ describe('MapView live location', () => {
expect(geoMock.cycleMode).toHaveBeenCalled()
})
it('FE-COMP-MAPVIEW-077: the credit (i) is a phone control, and it opens the credit through a class on the wrapper', () => {
it('FE-COMP-MAPVIEW-077: the map draws no credit control of its own, on either width', () => {
const desktop = render(<MapView />)
// The desktop credit is Leaflet's own, in its own container; this component adds none.
expect(screen.queryByRole('button', { name: 'Map credits' })).toBeNull()
desktop.unmount()
Object.defineProperty(window, 'innerWidth', { configurable: true, writable: true, value: 420 })
const { container } = render(<MapView />)
const toggle = screen.getByRole('button', { name: 'Map credits' })
// The phone used to get an (i) here that opened the credit through a class on the
// wrapper. The phone map now carries no visible credit at all (mobile.css), so neither
// the button nor the class it toggled is left behind.
expect(screen.queryByRole('button', { name: 'Map credits' })).toBeNull()
const wrapper = container.querySelector('div.w-full.h-full.relative') as HTMLElement
// Starts closed: on a phone the map is the screen, and the credit is one tap away.
expect(toggle.getAttribute('aria-expanded')).toBe('false')
expect(wrapper.classList.contains('m-attrib-open')).toBe(false)
// The locate button's band is only the fallback; a credit corner around the map wins.
expect(toggle.style.bottom).toBe('var(--m-credit-bottom, calc(var(--bottom-nav-h, 84px) + 12px))')
// A class on the wrapper rather than markup in Leaflet's own container, which Leaflet
// rewrites whenever a layer with an attribution comes or goes.
fireEvent.click(toggle)
expect(toggle.getAttribute('aria-expanded')).toBe('true')
expect(wrapper.classList.contains('m-attrib-open')).toBe(true)
fireEvent.click(toggle)
expect(toggle.getAttribute('aria-expanded')).toBe('false')
expect(wrapper.classList.contains('m-attrib-open')).toBe(false)
})
})
+1 -21
View File
@@ -34,7 +34,6 @@ function alternativeLabelIcon(label: string, note: string, background: string, a
})
}
import L from 'leaflet'
import MapAttributionToggle from './MapAttributionToggle'
import 'leaflet.markercluster/dist/MarkerCluster.css'
import 'leaflet.markercluster/dist/MarkerCluster.Default.css'
import { mapsApi } from '../../api/client'
@@ -999,16 +998,6 @@ export const MapView = memo(function MapView({
? 'calc(var(--bottom-nav-h, 84px) + 20px + var(--day-panel-h, 0px) + 12px)'
: 'calc(var(--bottom-nav-h, 84px) + 12px)'
/**
* Whether the credit is showing, on a phone where it starts as the (i).
*
* Held here rather than pushed into Leaflet's own container: Leaflet rewrites that
* container's markup from scratch whenever a layer with an attribution is added or
* removed, so anything injected into it dies on the next basemap switch. A class on
* the wrapper survives that, and the CSS lives with the rest of the mobile chrome.
*/
const [attribOpen, setAttribOpen] = useState(false)
const baseLayer = useSettingsStore(s => s.settings.map_base_layer) || 'default'
const updateSetting = useSettingsStore(s => s.updateSetting)
const isSatellite = baseLayer === 'satellite'
@@ -1027,7 +1016,7 @@ export const MapView = memo(function MapView({
return (
<>
<div className={`w-full h-full relative${isMobile && attribOpen ? ' m-attrib-open' : ''}`}>
<div className="w-full h-full relative">
<MapContainer
// The datum is in the element's identity, because react-leaflet builds the
// map once and Leaflet cannot change a CRS afterwards. Settings can arrive
@@ -1246,15 +1235,6 @@ export const MapView = memo(function MapView({
onClick={cycleTrackingMode}
bottomOffset={locationButtonBottom as unknown as number}
/>}
{/* The credit as the little (i), which is what both GL engines do on a narrow map
and Leaflet has no mode for. */}
{isMobile && (
<MapAttributionToggle
open={attribOpen}
onToggle={() => setAttribOpen(v => !v)}
bottomOffset={locationButtonBottom}
/>
)}
{/* 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. */}