mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
feat(planner): bring the plan tab and every trip dialog into the new look
The Plan tab was the last trip tab still in the old design. It now reads like Bookings, Costs, Lists, Files and Collab, without losing a function: - Day plan: each day is a card with a head band (day tile with weather, stay and rental pills, a "+" menu for place, stay, transport, transit and note), rows with "..." menus, white badges and a white route bar. - Places column: add, search and filters in three rows, a show dropdown, category and rating filters, and a selection bar at the foot. - Place inspector, day details and the stay editor on the shared dialog frame; the place form in the editor look with the name in the head band. - Clicking a booking or transport anywhere on the plan opens the booking detail popup first; Edit leads to the editor. The popup is one host shared with the Bookings and Transports tabs. - Files and Collab dialogs, notes, polls, links and chat moved to the same frame; shared DialogShell and dialogParts hold the building blocks. - The map hover card shows the place photo and follows the theme. Every new and reworded string is translated into all locales, and a few older English leftovers (help center, cost split, import hints) with them. Phone screens keep their own look.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React from 'react'
|
||||
import { CalendarDays, Route } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n/TranslationContext'
|
||||
import { NEUTRAL_TINT } from '../shared/DialogShell'
|
||||
|
||||
interface RoadtripModeSwitchProps {
|
||||
active: boolean
|
||||
@@ -10,7 +11,8 @@ interface RoadtripModeSwitchProps {
|
||||
/**
|
||||
* Switches the plan view's left rail between the day plan and the road trip reading of
|
||||
* the same trip. Only rendered while the road trip addon is on, so a trip that isn't
|
||||
* driven anywhere never grows a control it has no use for.
|
||||
* driven anywhere never grows a control it has no use for. It opens the rail's tinted
|
||||
* head band, so with the day plan's tools below it the two read as one band.
|
||||
*/
|
||||
export default function RoadtripModeSwitch({ active, onChange }: RoadtripModeSwitchProps): React.ReactElement {
|
||||
const { t } = useTranslation()
|
||||
@@ -19,10 +21,11 @@ export default function RoadtripModeSwitch({ active, onChange }: RoadtripModeSwi
|
||||
[true, t('roadtrip.mode.roadtrip'), Route],
|
||||
]
|
||||
return (
|
||||
<div className="flex-none px-3 pb-1 pt-3" style={{ background: NEUTRAL_TINT }}>
|
||||
<div
|
||||
role="tablist"
|
||||
aria-label={t('roadtrip.mode.label')}
|
||||
className="mx-3.5 mb-0 mt-3 flex gap-1 rounded-xl border border-edge-faint bg-surface-tertiary p-1"
|
||||
className="flex gap-1 rounded-xl border border-edge-faint bg-surface-tertiary p-1"
|
||||
>
|
||||
{options.map(([value, label, Icon]) => {
|
||||
const selected = active === value
|
||||
@@ -48,5 +51,6 @@ export default function RoadtripModeSwitch({ active, onChange }: RoadtripModeSwi
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from 'react'
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { fireEvent, render, screen } from '../../../tests/helpers/render'
|
||||
import { fireEvent, render, screen, within } from '../../../tests/helpers/render'
|
||||
import ServiceStopSection from './ServiceStopSection'
|
||||
import type { ServiceStopMode } from './manualStop'
|
||||
|
||||
/**
|
||||
* FE-SERVICESTOP-011..016, 022..024: the place form, asked for a stop on a drive.
|
||||
* FE-SERVICESTOP-011..016, 022..026: the place form, asked for a stop on a drive.
|
||||
*
|
||||
* What the section itself owes the reader: the two questions a service stop answers,
|
||||
* the leg it will land on preselected from where the place is, how far off that leg the
|
||||
@@ -88,9 +88,9 @@ describe('ServiceStopSection', () => {
|
||||
expect(screen.getByText('Add between')).toBeInTheDocument()
|
||||
// Each row names only the two stops it sits between: the word the caption carries
|
||||
// does not need repeating down the list.
|
||||
const trigger = screen.getByRole('button', { name: /Berlin · Dresden/ })
|
||||
const trigger = screen.getByRole('button', { name: /Berlin\s+Dresden/ })
|
||||
fireEvent.click(trigger)
|
||||
fireEvent.click(screen.getByText(/Bremen · Berlin/))
|
||||
fireEvent.click(screen.getByText(/Bremen\s+Berlin/))
|
||||
|
||||
expect(props.onLeg).toHaveBeenCalledWith('5:1')
|
||||
})
|
||||
@@ -100,7 +100,7 @@ describe('ServiceStopSection', () => {
|
||||
|
||||
expect(screen.getByText(/check which leg it belongs on/)).toBeInTheDocument()
|
||||
// Still a leg to land on: the note is the reason to change it, not a refusal.
|
||||
expect(screen.getByRole('button', { name: /Bremen · Berlin/ })).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /Bremen\s+Berlin/ })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-SERVICESTOP-016: with nothing routed it says which day it will be added to', () => {
|
||||
@@ -116,7 +116,7 @@ describe('ServiceStopSection', () => {
|
||||
|
||||
expect(screen.getByTestId('service-stop-needs-point')).toBeInTheDocument()
|
||||
expect(screen.queryByText('Add between')).toBeNull()
|
||||
expect(screen.queryByRole('button', { name: /Hamburg · Bremen/ })).toBeNull()
|
||||
expect(screen.queryByRole('button', { name: /Hamburg\s+Bremen/ })).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-SERVICESTOP-023: every leg says how far off it the place lies, nearest first', () => {
|
||||
@@ -139,9 +139,9 @@ describe('ServiceStopSection', () => {
|
||||
|
||||
// The nearest stretch is the one on offer, and it says why it is: the trigger shows
|
||||
// the preselected row, distance and all.
|
||||
expect(screen.getByRole('button', { name: /Bremen · Berlin · 11\.1 km off the route/ })).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /Bremen\s+Berlin\s+11\.1 km off the route/ })).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /Bremen · Berlin/ }))
|
||||
fireEvent.click(screen.getByRole('button', { name: /Bremen\s+Berlin/ }))
|
||||
// The trigger repeats the preselected row, so the menu itself starts one along.
|
||||
const rows = screen.getAllByRole('button')
|
||||
.map(b => b.textContent ?? '')
|
||||
@@ -149,8 +149,8 @@ describe('ServiceStopSection', () => {
|
||||
.slice(1)
|
||||
// Nearest first, so the preselected one is visibly the nearest and an override is an
|
||||
// informed choice rather than a guess.
|
||||
expect(rows[0]).toMatch(/Bremen · Berlin · 11\.1 km/)
|
||||
expect(rows[1]).toMatch(/Hamburg · Bremen · 100\.2 km/)
|
||||
expect(rows[0]).toMatch(/Bremen\s+Berlin\s+11\.1 km/)
|
||||
expect(rows[1]).toMatch(/Hamburg\s+Bremen\s+100\.2 km/)
|
||||
})
|
||||
|
||||
it('FE-SERVICESTOP-024: the day the panel is on is offered even once the others have routed', () => {
|
||||
@@ -161,9 +161,33 @@ describe('ServiceStopSection', () => {
|
||||
mode: mode({ appendDay: { dayId: 7, dayNumber: 3, position: 2 } }),
|
||||
})
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /Hamburg · Bremen/ }))
|
||||
fireEvent.click(screen.getByRole('button', { name: /Hamburg\s+Bremen/ }))
|
||||
fireEvent.click(screen.getByText(/Day 3, as stop 3/))
|
||||
|
||||
expect(props.onLeg).toHaveBeenCalledWith('7:end')
|
||||
})
|
||||
|
||||
it('FE-SERVICESTOP-025: each caption names what it is over, and no row is held apart by a dot', () => {
|
||||
draw({ lat: 51.05, lng: 13.7, mode: mode({ targetFor: () => ({ dayId: 6, position: 1, offRouteKm: 0.4 }) }) })
|
||||
|
||||
const kinds = screen.getByRole('group', { name: 'Kind of stop' })
|
||||
expect(within(kinds).getByRole('button', { name: 'Fuel' })).toBeInTheDocument()
|
||||
const stay = screen.getByRole('group', { name: 'Time at this stop' })
|
||||
expect(within(stay).getByRole('button', { name: /45 min/ })).toBeInTheDocument()
|
||||
// The leg picker keeps the chosen stretch as its own name; the caption names the group.
|
||||
const legs = screen.getByRole('group', { name: 'Add between' })
|
||||
const trigger = within(legs).getByRole('button', { name: /Berlin\s+Dresden/ })
|
||||
expect(trigger.textContent).not.toContain('\u00b7')
|
||||
fireEvent.click(trigger)
|
||||
for (const row of screen.getAllByText(/Bremen\s+Berlin/)) expect(row.textContent).not.toContain('\u00b7')
|
||||
})
|
||||
|
||||
it('FE-SERVICESTOP-026: the pills not chosen are white, as on the rest of the place form', () => {
|
||||
draw()
|
||||
|
||||
expect(screen.getByRole('button', { name: 'Charging' })).toHaveClass('bg-surface-card', 'ring-edge-faint')
|
||||
expect(screen.getByRole('button', { name: /45 min/ })).toHaveClass('bg-surface-card', 'ring-edge-faint')
|
||||
// The chosen one keeps the accent fill.
|
||||
expect(screen.getByRole('button', { name: 'Fuel' })).toHaveClass('bg-accent')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useMemo } from 'react'
|
||||
import React, { useId, useMemo } from 'react'
|
||||
import CustomSelect from '../shared/CustomSelect'
|
||||
import { useTranslation } from '../../i18n/TranslationContext'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
@@ -33,12 +33,14 @@ const ROW = 'flex flex-wrap gap-1.5'
|
||||
/**
|
||||
* What holds the pieces of one option apart.
|
||||
*
|
||||
* A separator rather than a sentence, and deliberately not a word: the caption above
|
||||
* already says these are the stretches to add between, so a row only has to name the two
|
||||
* stops and how far off them the place lies. It also reads the same way in a language
|
||||
* written right to left, which an arrow would not.
|
||||
* Space rather than a sentence, and deliberately not a word or a glyph: the caption
|
||||
* above already says these are the stretches to add between, so a row only has to name
|
||||
* the two stops and how far off them the place lies. It also reads the same way in a
|
||||
* language written right to left, which an arrow would not. An em space, because an
|
||||
* option label is plain text and a single space would run a stop's name into the next
|
||||
* one's.
|
||||
*/
|
||||
const SEP = ' · '
|
||||
const GAP = ' '
|
||||
|
||||
interface ServiceStopSectionProps {
|
||||
mode: ServiceStopMode
|
||||
@@ -62,6 +64,9 @@ export default function ServiceStopSection({
|
||||
const { t } = useTranslation()
|
||||
const distanceUnit = useSettingsStore(s => s.settings.distance_unit)
|
||||
const choice = useMemo(() => serviceStopChoice(mode, lat, lng, leg), [mode, lat, lng, leg])
|
||||
const kindId = useId()
|
||||
const stayId = useId()
|
||||
const legId = useId()
|
||||
|
||||
/**
|
||||
* The stretches on offer, each naming what it is and how far the place lies from it.
|
||||
@@ -73,11 +78,11 @@ export default function ServiceStopSection({
|
||||
const options = useMemo(() => [
|
||||
...choice.legs.map(item => ({
|
||||
value: item.value,
|
||||
label: item.offRouteKm === null
|
||||
? `${item.from}${SEP}${item.to}`
|
||||
: `${item.from}${SEP}${item.to}${SEP}${t('roadtrip.poi.offRoute', {
|
||||
distance: formatDistance(item.offRouteKm, distanceUnit),
|
||||
})}`,
|
||||
label: [
|
||||
item.from,
|
||||
item.to,
|
||||
item.offRouteKm === null ? null : t('roadtrip.poi.offRoute', { distance: formatDistance(item.offRouteKm, distanceUnit) }),
|
||||
].filter(Boolean).join(GAP),
|
||||
badge: t('roadtrip.day', { number: item.dayNumber }),
|
||||
})),
|
||||
...(choice.end
|
||||
@@ -93,17 +98,19 @@ export default function ServiceStopSection({
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<label className={LABEL}>{t('roadtrip.stop.kind')}</label>
|
||||
<label id={kindId} className={LABEL}>{t('roadtrip.stop.kind')}</label>
|
||||
<StopKindChips
|
||||
value={stopType}
|
||||
onPick={(kind, wasChosen) => { if (!wasChosen) onStopType(kind) }}
|
||||
className={ROW}
|
||||
labelledBy={kindId}
|
||||
white
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className={LABEL}>{t('roadtrip.stop.stay')}</label>
|
||||
<StopStayChips value={minutes} onPick={onMinutes} className={ROW} />
|
||||
<label id={stayId} className={LABEL}>{t('roadtrip.stop.stay')}</label>
|
||||
<StopStayChips value={minutes} onPick={onMinutes} className={ROW} labelledBy={stayId} white />
|
||||
</div>
|
||||
|
||||
{/* Where it goes. Preselected from the projection, and changeable.
|
||||
@@ -115,8 +122,11 @@ export default function ServiceStopSection({
|
||||
{t('roadtrip.poi.manualNoCoords')}
|
||||
</p>
|
||||
) : choice.legs.length > 0 ? (
|
||||
<div>
|
||||
<label className={LABEL}>{t('roadtrip.poi.addBetween')}</label>
|
||||
// A group named by the caption rather than a label pointing at the trigger: a
|
||||
// label would replace the trigger's name, which is the stretch chosen, and a
|
||||
// click on it would open the menu.
|
||||
<div role="group" aria-labelledby={legId}>
|
||||
<label id={legId} className={LABEL}>{t('roadtrip.poi.addBetween')}</label>
|
||||
<CustomSelect
|
||||
value={choice.legValue}
|
||||
onChange={value => onLeg(String(value))}
|
||||
|
||||
@@ -21,19 +21,32 @@ const DWELL_CHOICES = [5, 10, 20, 30, 45, 60]
|
||||
|
||||
const CHOSEN = 'border-transparent bg-accent font-semibold text-accent-text'
|
||||
const UNCHOSEN = 'border-edge text-content-secondary hover:border-content-faint hover:text-content'
|
||||
/** Unchosen on a grey panel: a white pill on a hairline, like every other pill there. */
|
||||
const UNCHOSEN_WHITE = 'border-transparent bg-surface-card text-content-secondary shadow-sm ring-1 ring-edge-faint hover:text-content'
|
||||
|
||||
/** What both rows take besides their value. */
|
||||
interface RowOptions {
|
||||
className?: string
|
||||
/** The id of the caption over the row, which then names it as a group. */
|
||||
labelledBy?: string
|
||||
/** Unchosen pills white, for a row that sits on a grey panel (the place form's). */
|
||||
white?: boolean
|
||||
}
|
||||
|
||||
const groupProps = (labelledBy?: string) => (labelledBy ? { role: 'group', 'aria-labelledby': labelledBy } : {})
|
||||
|
||||
/** The row itself. Overridable so a caller whose own label already spaces it can say so. */
|
||||
const ROW = 'mt-1.5 flex flex-wrap gap-1.5'
|
||||
|
||||
export function StopKindChips({ value, onPick, className = ROW }: {
|
||||
export function StopKindChips({ value, onPick, className = ROW, labelledBy, white = false }: RowOptions & {
|
||||
value: RoadtripStopType | null
|
||||
/** Called with the kind clicked, including the one already chosen. */
|
||||
onPick: (kind: RoadtripStopType, wasChosen: boolean) => void
|
||||
className?: string
|
||||
}): React.ReactElement {
|
||||
const { t } = useTranslation()
|
||||
const unchosen = white ? UNCHOSEN_WHITE : UNCHOSEN
|
||||
return (
|
||||
<div className={className}>
|
||||
<div className={className} {...groupProps(labelledBy)}>
|
||||
{STOP_KINDS.map(({ key, labelKey, Icon }) => {
|
||||
const on = value === key
|
||||
return (
|
||||
@@ -43,7 +56,7 @@ export function StopKindChips({ value, onPick, className = ROW }: {
|
||||
aria-pressed={on}
|
||||
onClick={() => onPick(key, on)}
|
||||
className={`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-caption transition-colors ${
|
||||
on ? CHOSEN : UNCHOSEN
|
||||
on ? CHOSEN : unchosen
|
||||
}`}
|
||||
>
|
||||
<Icon size={12} aria-hidden />
|
||||
@@ -55,13 +68,13 @@ export function StopKindChips({ value, onPick, className = ROW }: {
|
||||
)
|
||||
}
|
||||
|
||||
export function StopStayChips({ value, onPick, className = ROW }: {
|
||||
export function StopStayChips({ value, onPick, className = ROW, labelledBy, white = false }: RowOptions & {
|
||||
value: number
|
||||
onPick: (minutes: number) => void
|
||||
className?: string
|
||||
}): React.ReactElement {
|
||||
const unchosen = white ? UNCHOSEN_WHITE : UNCHOSEN
|
||||
return (
|
||||
<div className={className}>
|
||||
<div className={className} {...groupProps(labelledBy)}>
|
||||
{DWELL_CHOICES.map(minutes => (
|
||||
<button
|
||||
key={minutes}
|
||||
@@ -69,7 +82,7 @@ export function StopStayChips({ value, onPick, className = ROW }: {
|
||||
aria-pressed={value === minutes}
|
||||
onClick={() => onPick(minutes)}
|
||||
className={`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 text-caption tabular-nums transition-colors ${
|
||||
value === minutes ? CHOSEN : UNCHOSEN
|
||||
value === minutes ? CHOSEN : unchosen
|
||||
}`}
|
||||
>
|
||||
<Hourglass size={11} aria-hidden />
|
||||
|
||||
Reference in New Issue
Block a user