mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
fix(mobile): the rail, the docks and the top-level screens on a large screen
From the large-screen review (visual findings of the shell and the top-level screens): - Rail: 80px wide, one caption size for every name (no shrinking per item), balanced two-line names with every entry as tall as the tallest, short rail names where a language's word is too long (mobileNav.rail*, all locales), and near-opaque glass so a map's colours no longer smear through it. - Rail head: always one 56px circle, so the entries never jump between pages: the create action, the screen's own action (the vacation calendar's year/editor switch moves there instead of floating over the days) or the quiet logo on settings and administration. It stays put while a short rail scrolls. - Vacation calendar: weekday letters over each month on a wide window; the editor's mode switch sits at the foot with room kept for it. - Docks: More is marked with a ring rather than the centre button's fill, the dock glass is denser, and lists fade out under the dock instead of showing in the gap below it. - Dashboard: trip names get the card's width with the dates under them, the hero's facts wrap as whole chips, the filter chips scroll with a fade, the hero ends above the dock on a phone on its side and its buttons sit on a dark ground; the header bar stands in the content's column. - Journeys: on a wide window the header is the same glass bar, in the column of the cards, and the other journeys' label starts with them. - Notifications: the round chevron back button, in the list's column. - Settings and administration share one frame and width. Admin's new-user action sits under the section list's title, the users card header wraps inside the card, stat labels ellipsize, role badges read in dark mode. - Collections: one card per place with the status inside it, worded in a readable mix of its colour. - Atlas and the journey map frame clear of the rail and the header; the journey's day bar sits on a glass plate, and a phone on its side gets smaller cards. - Rail label tests rewritten for the new rule; FE-MOB-PANES-016 duplicate renumbered to 017.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-COMP-JOURNEYMAP-001 to FE-COMP-JOURNEYMAP-062
|
||||
// FE-COMP-JOURNEYMAP-001 to FE-COMP-JOURNEYMAP-063
|
||||
|
||||
vi.mock('../../api/websocket', () => ({
|
||||
connect: vi.fn(),
|
||||
@@ -592,6 +592,28 @@ describe('JourneyMap', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('FE-COMP-JOURNEYMAP-063: paddingStart keeps the journey clear of a rail on the leading side, either way round', () => {
|
||||
const origRAF = globalThis.requestAnimationFrame;
|
||||
globalThis.requestAnimationFrame = (cb: FrameRequestCallback) => { cb(0); return 0; };
|
||||
try {
|
||||
const { unmount } = render(<JourneyMap checkins={[]} entries={entriesWithCoords} paddingBottom={200} paddingStart={100} />);
|
||||
expect(mockedMap().fitBounds).toHaveBeenLastCalledWith(
|
||||
expect.anything(),
|
||||
expect.objectContaining({ paddingTopLeft: [150, 50], paddingBottomRight: [50, 200] }),
|
||||
);
|
||||
unmount();
|
||||
document.documentElement.dir = 'rtl';
|
||||
render(<JourneyMap checkins={[]} entries={entriesWithCoords} paddingBottom={200} paddingStart={100} />);
|
||||
expect(mockedMap().fitBounds).toHaveBeenLastCalledWith(
|
||||
expect.anything(),
|
||||
expect.objectContaining({ paddingTopLeft: [50, 50], paddingBottomRight: [150, 200] }),
|
||||
);
|
||||
} finally {
|
||||
document.documentElement.dir = '';
|
||||
globalThis.requestAnimationFrame = origRAF;
|
||||
}
|
||||
});
|
||||
|
||||
it('FE-COMP-JOURNEYMAP-026: dark mode picks the dark basemap', async () => {
|
||||
render(<JourneyMap checkins={[]} entries={entriesWithCoords} dark />);
|
||||
// The default basemap is a vector style now, so it arrives as a style option
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, useImperativeHandle, useCallback, type CSSProperties, type Ref, type RefObject } from 'react'
|
||||
import { useEffect, useLayoutEffect, useRef, useImperativeHandle, useCallback, type CSSProperties, type Ref, type RefObject } from 'react'
|
||||
import { clusterPhotos, photoMarkerHtml, type MapPhoto } from './journeyPhotoLayer'
|
||||
import L from 'leaflet'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
@@ -76,6 +76,12 @@ interface Props {
|
||||
*/
|
||||
onMarkerCardClick?: (entryId: string) => void
|
||||
paddingBottom?: number
|
||||
/**
|
||||
* How much of the map's leading edge a bar laid over it covers (the touch
|
||||
* shell's rail), in px: framing keeps the journey clear of it. Read when the
|
||||
* map frames, so a change alone does not rebuild the map.
|
||||
*/
|
||||
paddingStart?: number
|
||||
/** CARTO key from the share payload: the public journey has no settings store to read. */
|
||||
cartoApiKey?: string
|
||||
/**
|
||||
@@ -281,13 +287,23 @@ function markCoords(marks: JourneyMapMark[] | undefined): L.LatLngTuple[] {
|
||||
return (marks ?? []).map(mark => [mark.lat, mark.lng] as L.LatLngTuple)
|
||||
}
|
||||
|
||||
function fitOptions(paddingBottom: number | undefined): L.FitBoundsOptions {
|
||||
return { paddingTopLeft: [50, 50], paddingBottomRight: [50, paddingBottom || 50], maxZoom: 16 }
|
||||
function fitOptions(paddingBottom: number | undefined, paddingStart = 0): L.FitBoundsOptions {
|
||||
const rtl = typeof document !== 'undefined' && document.documentElement.dir === 'rtl'
|
||||
return {
|
||||
paddingTopLeft: [50 + (rtl ? 0 : paddingStart), 50],
|
||||
paddingBottomRight: [50 + (rtl ? paddingStart : 0), paddingBottom || 50],
|
||||
maxZoom: 16,
|
||||
}
|
||||
}
|
||||
|
||||
function JourneyMap(
|
||||
{ entries, photos, onPhotoClick, trail, tracks, height = 220, dark, activeMarkerId, onMarkerClick, fullScreen, paddingBottom, cartoApiKey, onMarkerCardClick, layerVisibility = EVERY_LAYER, marks, onMarksPick, plannedEntryIds = NO_PLANNED, ref }: Props,
|
||||
{ entries, photos, onPhotoClick, trail, tracks, height = 220, dark, activeMarkerId, onMarkerClick, fullScreen, paddingBottom, paddingStart = 0, cartoApiKey, onMarkerCardClick, layerVisibility = EVERY_LAYER, marks, onMarksPick, plannedEntryIds = NO_PLANNED, ref }: Props,
|
||||
) {
|
||||
// The leading inset is read when the map frames, not a reason to rebuild it.
|
||||
const paddingStartRef = useRef(paddingStart)
|
||||
useLayoutEffect(() => {
|
||||
paddingStartRef.current = paddingStart
|
||||
})
|
||||
// Read through a ref: the handler is fixed per surface, and putting it in the
|
||||
// marker effect's deps would rebuild every marker for nothing.
|
||||
const onMarkerCardClickRef = useRef(onMarkerCardClick)
|
||||
@@ -536,7 +552,7 @@ function JourneyMap(
|
||||
const pointCoords = [...allCoords, ...markCoords(marksRef.current)]
|
||||
const fitCoords = pointCoords.length > 0 ? pointCoords : trackCoords
|
||||
marksFramedRef.current = (marksRef.current?.length ?? 0) > 0
|
||||
if (fitCoords.length > 0) map.fitBounds(L.latLngBounds(fitCoords), fitOptions(paddingBottom))
|
||||
if (fitCoords.length > 0) map.fitBounds(L.latLngBounds(fitCoords), fitOptions(paddingBottom, paddingStartRef.current))
|
||||
else map.setView([30, 0], 2)
|
||||
} catch {}
|
||||
})
|
||||
@@ -652,7 +668,7 @@ function JourneyMap(
|
||||
const coords = markCoords(marks)
|
||||
if (!marksFramedRef.current && coords.length > 0) {
|
||||
marksFramedRef.current = true
|
||||
if (!readerMovedRef.current) map.fitBounds(L.latLngBounds([...entryCoordsRef.current, ...coords]), fitOptions(paddingBottom))
|
||||
if (!readerMovedRef.current) map.fitBounds(L.latLngBounds([...entryCoordsRef.current, ...coords]), fitOptions(paddingBottom, paddingStartRef.current))
|
||||
}
|
||||
|
||||
draw()
|
||||
|
||||
@@ -39,6 +39,12 @@ interface Props {
|
||||
onMarkerClick?: (id: string, type?: string) => void
|
||||
fullScreen?: boolean
|
||||
paddingBottom?: number
|
||||
/**
|
||||
* How much of the map's leading edge a bar laid over it covers (the touch
|
||||
* shell's rail), in px: framing keeps the journey clear of it. Read when the
|
||||
* map frames, so a change alone does not rebuild the map.
|
||||
*/
|
||||
paddingStart?: number
|
||||
/** Open the entry a marker card names when the card is tapped, both renderers. */
|
||||
onMarkerCardClick?: (entryId: string) => void
|
||||
/** Open an entry's photos from the marker card's thumbnail strip. GL renderer only. */
|
||||
|
||||
@@ -317,6 +317,14 @@ describe('JourneyMapGL', () => {
|
||||
expect(gl.map.addLayer).toHaveBeenCalledWith(expect.objectContaining({ id: 'journey-route-line' }))
|
||||
})
|
||||
|
||||
it('FE-COMP-JMAPGL-049: paddingStart widens the fit on the side of the rail', () => {
|
||||
withToken()
|
||||
render(<JourneyMapGL checkins={[]} entries={entries} paddingBottom={200} paddingStart={100} fullScreen />)
|
||||
expect(gl.map.fitBounds).toHaveBeenCalledWith(gl.boundsList[0], expect.objectContaining({
|
||||
padding: { top: 50, bottom: 200, left: 150, right: 50 },
|
||||
}))
|
||||
})
|
||||
|
||||
it('FE-COMP-JMAPGL-010: the camera fits entries and trail with the requested bottom padding', () => {
|
||||
withToken()
|
||||
render(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, useImperativeHandle, useCallback, type Ref } from 'react'
|
||||
import { useEffect, useLayoutEffect, useRef, useImperativeHandle, useCallback, type Ref } from 'react'
|
||||
import type mapboxgl from 'mapbox-gl'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
import { isStandardFamily, supportsCustom3d, wantsTerrain, addCustom3dBuildings, addTerrainAndSky } from '../Map/mapboxSetup'
|
||||
@@ -57,6 +57,12 @@ interface Props {
|
||||
photos?: MapPhoto[]
|
||||
onPhotoClick?: (photoIds: string[]) => void
|
||||
paddingBottom?: number
|
||||
/**
|
||||
* How much of the map's leading edge a bar laid over it covers (the touch
|
||||
* shell's rail), in px: framing keeps the journey clear of it. Read when the
|
||||
* map frames, so a change alone does not rebuild the map.
|
||||
*/
|
||||
paddingStart?: number
|
||||
/** See the Leaflet twin (JRN-04): hidden layers go off the map in place. */
|
||||
layerVisibility?: JourneyMapLayerVisibility
|
||||
marks?: JourneyMapMark[]
|
||||
@@ -185,9 +191,10 @@ function markBounds(gl: Props['gl'], marks: JourneyMapMark[], points: [number, n
|
||||
return bounds
|
||||
}
|
||||
|
||||
function fitOptions(paddingBottom: number | undefined, tilted: boolean | undefined) {
|
||||
function fitOptions(paddingBottom: number | undefined, tilted: boolean | undefined, paddingStart = 0) {
|
||||
const rtl = typeof document !== 'undefined' && document.documentElement.dir === 'rtl'
|
||||
return {
|
||||
padding: { top: 50, bottom: paddingBottom || 50, left: 50, right: 50 },
|
||||
padding: { top: 50, bottom: paddingBottom || 50, left: 50 + (rtl ? 0 : paddingStart), right: 50 + (rtl ? paddingStart : 0) },
|
||||
maxZoom: 16,
|
||||
pitch: tilted ? 45 : 0,
|
||||
duration: 0,
|
||||
@@ -195,8 +202,13 @@ function fitOptions(paddingBottom: number | undefined, tilted: boolean | undefin
|
||||
}
|
||||
|
||||
function JourneyMapGL(
|
||||
{ entries, trail, tracks, height = 220, dark, activeMarkerId, onMarkerClick, fullScreen, paddingBottom, glProvider = 'mapbox-gl', gl, onMarkerCardClick, onMarkerPhotoClick, photos, onPhotoClick, layerVisibility = EVERY_LAYER, marks, onMarksPick, plannedEntryIds = NO_PLANNED, ref }: Props,
|
||||
{ entries, trail, tracks, height = 220, dark, activeMarkerId, onMarkerClick, fullScreen, paddingBottom, paddingStart = 0, glProvider = 'mapbox-gl', gl, onMarkerCardClick, onMarkerPhotoClick, photos, onPhotoClick, layerVisibility = EVERY_LAYER, marks, onMarksPick, plannedEntryIds = NO_PLANNED, ref }: Props,
|
||||
) {
|
||||
// The leading inset is read when the map frames, not a reason to rebuild it.
|
||||
const paddingStartRef = useRef(paddingStart)
|
||||
useLayoutEffect(() => {
|
||||
paddingStartRef.current = paddingStart
|
||||
})
|
||||
const onMarkerCardClickRef = useRef(onMarkerCardClick)
|
||||
onMarkerCardClickRef.current = onMarkerCardClick
|
||||
const onMarkerPhotoClickRef = useRef(onMarkerPhotoClick)
|
||||
@@ -526,7 +538,7 @@ function JourneyMapGL(
|
||||
known.forEach(mark => bounds.extend([mark.lng, mark.lat]))
|
||||
if (hasPoints || known.length > 0) {
|
||||
try {
|
||||
map.fitBounds(bounds, fitOptions(paddingBottom, enableMapbox3d && fullScreen))
|
||||
map.fitBounds(bounds, fitOptions(paddingBottom, enableMapbox3d && fullScreen, paddingStartRef.current))
|
||||
} catch { /* empty bounds */ }
|
||||
}
|
||||
})
|
||||
@@ -631,7 +643,7 @@ function JourneyMapGL(
|
||||
marksFramedRef.current = true
|
||||
if (!readerMovedRef.current) {
|
||||
try {
|
||||
map.fitBounds(markBounds(gl, marks, entryPointsRef.current), fitOptions(paddingBottom, enableMapbox3d && fullScreen))
|
||||
map.fitBounds(markBounds(gl, marks, entryPointsRef.current), fitOptions(paddingBottom, enableMapbox3d && fullScreen, paddingStartRef.current))
|
||||
} catch { /* empty bounds */ }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user