feat(mobile): two calm round controls a side on the map, no extra buttons

The phone map stacked four controls on the right and one on the left, in
three different looks. Now each side has two at most, all in one frosted
style, 20px off the edge and 8px apart: the whole-trip overview and locate on
the right, the base layer and the Dawarich route on the left, with the compass
appearing only while the map is turned off north.

The map's own places filter button and sheet are gone: the places tab carries
the same filter, and the map's pins follow it. The jump-to-today button beside
the day rail is gone too, since today's chip is already marked.

Also fixes a leftover of the segmented-control change that broke the parse.
This commit is contained in:
Maurice
2026-11-06 12:31:57 +01:00
parent b07b38b5b7
commit 01ddcc63bb
13 changed files with 73 additions and 374 deletions
@@ -954,39 +954,9 @@ describe('MMapArea and a booked night at the edge of the stage', () => {
})
describe('MMapArea — places filter', () => {
it('FE-MOB-MAPAREA-046: the plan map offers the places filter, and a tap opens its sheet', () => {
const { shell } = renderArea({ trTab: 'plan' })
const pill = screen.getByTestId('places-filter-pill')
expect(pill).toHaveAccessibleName('Filters')
// It opens a sheet: a dialog to announce, not an on/off state.
expect(pill).toHaveAttribute('aria-haspopup', 'dialog')
expect(pill).not.toHaveAttribute('aria-pressed')
act(() => { pill.click() })
expect(shell.openSheet).toHaveBeenCalledWith('placesFilter')
})
it('FE-MOB-MAPAREA-047: the pill lights up and counts the filters narrowing the pins', () => {
it('FE-MOB-MAPAREA-046: the map has no filter button of its own; the places tab sets the filter its pins follow', () => {
seedStore(useTripStore, { placesFilter: 'unplanned', placesRatingFilter: 4 })
renderArea({ trTab: 'plan' })
const pill = screen.getByTestId('places-filter-pill')
expect(pill).toHaveClass('text-accent')
expect(pill).not.toHaveAttribute('aria-pressed')
expect(pill).toHaveAttribute('aria-haspopup', 'dialog')
expect(pill).toHaveAccessibleName('Filters (2)')
expect(screen.getByText('2')).toHaveAttribute('aria-hidden', 'true')
})
it('FE-MOB-MAPAREA-049: a road trip keeps the places filter on its plan map, Dawarich or not', () => {
// The stack used to stand down in road-trip mode unless Dawarich had a pill in
// it; the plan map still shows the trip's places there, so its filter stays.
renderArea({ trTab: 'plan' }, { roadtripActive: true, dawarichEnabled: false })
expect(screen.getByTestId('places-filter-pill')).toBeInTheDocument()
})
it('FE-MOB-MAPAREA-048: the stage draws its own pins, so it has no places filter, and neither has a covered map', () => {
renderArea({ trTab: 'roadtrip', mapFront: true })
expect(screen.queryByTestId('places-filter-pill')).not.toBeInTheDocument()
renderArea({ view: 'plan', mapFront: false })
expect(screen.queryByTestId('places-filter-pill')).not.toBeInTheDocument()
})
})
@@ -1,128 +0,0 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { fireEvent, render, screen, within } from '../../../helpers/render'
import MPlacesFilterSheet from '../../../../src/mobile/screens/trip/places/MPlacesFilterSheet'
import { useTripStore } from '../../../../src/store/tripStore'
import { resetAllStores, seedStore } from '../../../helpers/store'
import { buildPlace } from '../../../helpers/factories'
import type { Category, Place } from '../../../../src/types'
// FE-MOB-PFSHEET-001 to FE-MOB-PFSHEET-009
const CATEGORIES = [
{ id: 1, name: 'Sights', color: '#123456', icon: 'landmark' },
{ id: 2, name: 'Food', color: '', icon: 'utensils' },
] as unknown as Category[]
const TAGGED = buildPlace({ id: 1, category_id: 1 })
const BARE = buildPlace({ id: 2, category_id: null })
const TRACK = buildPlace({ id: 3, category_id: 2, route_geometry: '[[1,2],[3,4]]' })
function renderSheet({ places = [TAGGED, BARE], categories = CATEGORIES, open = true, toursEnabled = false }: {
places?: Place[]
categories?: Category[]
open?: boolean
toursEnabled?: boolean
} = {}) {
const onClose = vi.fn()
render(<MPlacesFilterSheet open={open} onClose={onClose} places={places} categories={categories} toursEnabled={toursEnabled} />)
return { onClose }
}
const group = (name: string) => screen.getByRole('group', { name })
describe('MPlacesFilterSheet', () => {
beforeEach(() => {
resetAllStores()
})
it('FE-MOB-PFSHEET-001: shows the pool, the rating floors and the categories under one title', async () => {
renderSheet()
const sheet = await screen.findByRole('dialog', { name: 'Filters' })
expect(within(sheet).getByText('Show')).toBeInTheDocument()
expect(within(group('Show')).getAllByRole('button').map(b => b.textContent)).toEqual(['All', 'Unplanned', 'Planned'])
expect(within(group('Filter by rating')).getAllByRole('button').map(b => b.textContent))
.toEqual(['All', '5+', '4+', '3+', '2+', '1+'])
expect(screen.getByRole('checkbox', { name: 'Sights' })).toBeInTheDocument()
expect(screen.getByRole('checkbox', { name: 'Food' })).toBeInTheDocument()
expect(screen.getByRole('checkbox', { name: 'No Category' })).toBeInTheDocument()
})
it('FE-MOB-PFSHEET-002: the tracks pool only shows once a place carries a track', async () => {
renderSheet({ places: [TAGGED, TRACK] })
await screen.findByRole('dialog', { name: 'Filters' })
expect(within(group('Show')).getByRole('button', { name: 'Tracks' })).toBeInTheDocument()
expect(screen.queryByRole('checkbox', { name: 'No Category' })).not.toBeInTheDocument()
})
it('hides Tracks from the map filter while Tours is enabled', async () => {
const tourTrack = buildPlace({ id: 4, route_geometry: '[[5,6],[7,8]]' })
renderSheet({ places: [TAGGED, TRACK, tourTrack], toursEnabled: true })
await screen.findByRole('dialog', { name: 'Filters' })
expect(within(group('Show')).queryByRole('button', { name: 'Tracks' })).not.toBeInTheDocument()
})
it('FE-MOB-PFSHEET-003: picking a pool writes it to the trip store', async () => {
renderSheet()
await screen.findByRole('dialog', { name: 'Filters' })
const show = group('Show')
expect(within(show).getByRole('button', { name: 'All' })).toHaveAttribute('aria-pressed', 'true')
fireEvent.click(within(show).getByRole('button', { name: 'Unplanned' }))
expect(useTripStore.getState().placesFilter).toBe('unplanned')
// The chosen chip says so to a screen reader, and only that one.
expect(within(show).getByRole('button', { name: 'Unplanned' })).toHaveAttribute('aria-pressed', 'true')
expect(within(show).getByRole('button', { name: 'All' })).toHaveAttribute('aria-pressed', 'false')
})
it('FE-MOB-PFSHEET-004: picking a floor writes the rating filter to the trip store', async () => {
renderSheet()
await screen.findByRole('dialog', { name: 'Filters' })
const floors = group('Filter by rating')
fireEvent.click(within(floors).getByRole('button', { name: '3+' }))
expect(useTripStore.getState().placesRatingFilter).toBe(3)
expect(within(floors).getByRole('button', { name: '3+' })).toHaveAttribute('aria-pressed', 'true')
expect(within(floors).getByRole('button', { name: 'All' })).toHaveAttribute('aria-pressed', 'false')
})
it('FE-MOB-PFSHEET-005: categories toggle in and out of the shared set, "no category" included', async () => {
renderSheet()
await screen.findByRole('dialog', { name: 'Filters' })
fireEvent.click(screen.getByRole('checkbox', { name: 'Food' }))
fireEvent.click(screen.getByRole('checkbox', { name: 'No Category' }))
expect([...useTripStore.getState().placesCategoryFilter]).toEqual(['2', 'uncategorized'])
expect(screen.getByRole('checkbox', { name: 'Food' })).toHaveAttribute('aria-checked', 'true')
fireEvent.click(screen.getByRole('checkbox', { name: 'Food' }))
expect([...useTripStore.getState().placesCategoryFilter]).toEqual(['uncategorized'])
})
it('FE-MOB-PFSHEET-006: reset lifts every filter, and stays off while nothing filters', async () => {
seedStore(useTripStore, { placesFilter: 'planned', placesCategoryFilter: new Set(['1']), placesRatingFilter: 5 })
renderSheet()
await screen.findByRole('dialog', { name: 'Filters' })
const reset = screen.getByRole('button', { name: 'Reset' })
expect(reset).toBeEnabled()
fireEvent.click(reset)
const s = useTripStore.getState()
expect(s.placesFilter).toBe('all')
expect(s.placesCategoryFilter.size).toBe(0)
expect(s.placesRatingFilter).toBe('all')
expect(screen.getByRole('button', { name: 'Reset' })).toBeDisabled()
})
it('FE-MOB-PFSHEET-007: without any category to choose, the categories section is left out', async () => {
renderSheet({ places: [TAGGED], categories: [] })
const sheet = await screen.findByRole('dialog', { name: 'Filters' })
expect(within(sheet).queryByText('Categories')).not.toBeInTheDocument()
expect(screen.queryByRole('checkbox')).not.toBeInTheDocument()
})
it('FE-MOB-PFSHEET-008: the close button hands back to the caller', async () => {
const { onClose } = renderSheet()
fireEvent.click(within(await screen.findByRole('dialog', { name: 'Filters' })).getByRole('button', { name: 'Close' }))
expect(onClose).toHaveBeenCalledTimes(1)
})
it('FE-MOB-PFSHEET-009: nothing is rendered while closed', () => {
renderSheet({ open: false })
expect(screen.queryByRole('dialog', { name: 'Filters' })).not.toBeInTheDocument()
})
})
@@ -11,7 +11,7 @@ import { useSettingsStore } from '../../../../src/store/settingsStore'
import { useTripStore } from '../../../../src/store/tripStore'
import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'
import { resetAllStores, seedStore } from '../../../helpers/store'
import { fireEvent, render, screen, waitFor, within } from '../../../helpers/render'
import { fireEvent, render, screen, waitFor } from '../../../helpers/render'
// FE-MOB-SHOST-001 to FE-MOB-SHOST-029 and FE-MOB-SHOST-032 to FE-MOB-SHOST-034 (030 and 031 live in MTripSheets.members.test.tsx)
//
@@ -240,15 +240,8 @@ describe('MTripSheets', () => {
}
})
it('FE-MOB-SHOST-033: the map\'s places filter opens for its own id and closes through the shell', async () => {
const { shell } = renderHost({}, { sheet: { id: 'placesFilter' } })
const sheet = await screen.findByRole('dialog', { name: 'Filters' })
fireEvent.click(within(sheet).getByRole('button', { name: 'Close' }))
expect(shell.closeSheet).toHaveBeenCalledTimes(1)
})
it('FE-MOB-SHOST-033b: no places filter while another sheet is open', () => {
renderHost({}, { sheet: { id: 'day' } })
it('FE-MOB-SHOST-033: hosts no places filter of its own any more; the places tab carries it', () => {
renderHost({}, { sheet: { id: 'placesFilter' } })
expect(screen.queryByRole('dialog', { name: 'Filters' })).not.toBeInTheDocument()
})
@@ -668,31 +668,25 @@ describe('MTripShell', () => {
{ id: 22, day_number: 2, date: todayIso() },
{ id: 23, day_number: 3, date: shift(1) },
] as unknown as Day[]
const jump = () => screen.getByRole('button', { name: 'mobileTrip.jumpToToday' })
const jump = () => screen.queryByRole('button', { name: 'mobileTrip.jumpToToday' })
it('FE-MOB-SHELL-090: marks today and jumps back to it from another day', () => {
const { planner, container } = renderShell({ days: running(), selectedDayId: 21 } as Partial<TripPlanner>)
it('FE-MOB-SHELL-090: marks today on its chip, and puts no extra button beside the rail', () => {
const { container } = renderShell({ days: running(), selectedDayId: 21 } as Partial<TripPlanner>)
const marked = container.querySelectorAll('[data-today]')
expect(marked).toHaveLength(1)
expect(marked[0].className).toContain('ring-inset')
expect(marked[0]).toHaveTextContent('mobileTrip.today')
expect(jump()).toBeEnabled()
fireEvent.click(jump())
expect(planner.handleSelectDay).toHaveBeenLastCalledWith(22, true)
expect(jump()).toBeNull()
})
it('FE-MOB-SHELL-091: with today open the button stays, dimmed, so the rail does not move', () => {
it('FE-MOB-SHELL-091: with today open the active chip keeps its own look, the dot says which day is today', () => {
const { container } = renderShell({ days: running(), selectedDayId: 22 } as Partial<TripPlanner>)
expect(jump()).toBeDisabled()
// The active chip keeps its own look; the dot still says which day is today.
expect(container.querySelector('[data-today]')?.className).not.toContain('ring-inset')
})
it('FE-MOB-SHELL-092: outside the trip dates there is no today and no button', () => {
it('FE-MOB-SHELL-092: outside the trip dates there is no today', () => {
const { container } = renderShell()
expect(container.querySelector('[data-today]')).toBeNull()
expect(screen.queryByRole('button', { name: 'mobileTrip.jumpToToday' })).toBeNull()
})
})