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:
Maurice
2026-09-27 21:00:19 +02:00
parent acd0d6511e
commit 0dd07befa7
314 changed files with 17106 additions and 10400 deletions
@@ -1,88 +1,366 @@
import { Search, Plus, X, Upload, FileDown, ChevronDown, Check, MapPin, Star, CalendarPlus, CalendarDays } from 'lucide-react'
import { getCategoryIcon } from '../shared/categoryIcons'
import Tooltip from '../shared/Tooltip'
import CustomSelect from '../shared/CustomSelect'
import { useEffect, useRef, useState, type MouseEvent as ReactMouseEvent, type ReactNode } from 'react'
import { Search, Plus, X, Upload, FileDown, ListPlus, Check, Star, CalendarPlus, CalendarDays, ChevronDown, Tag } from 'lucide-react'
import { Tooltip } from '../shared/Tooltip'
import { ContextMenu, useContextMenu } from '../shared/ContextMenu'
import { NEUTRAL_TINT, fs } from '../shared/DialogShell'
import { useElementSize } from '../../hooks/useElementSize'
import type { SidebarState } from './usePlacesSidebar'
import { Eyebrow } from './bookings/bookingParts'
import { tintOf } from './planParts'
import { CategoryTile } from './PlacesBulkCategoryModal'
import type { PlacesFilter, SidebarState } from './usePlacesSidebar'
/**
* Below this the two labels stop fitting side by side and both buttons fall back
* to their icon. Measured on the button row itself rather than derived from the
* sidebar width: the labels are translated, so how much room they need differs
* per locale, and the row is what actually runs out of space. The rail is
* draggable down to 200px, which leaves the row 168.
* to their icon. Measured on the add row itself, the full width of the head band,
* rather than derived from the sidebar width: the labels are translated, so how
* much room they need differs per locale, and the row is what runs out of space.
* The rail is draggable down to 200px, which leaves the row 172.
*/
const COMPACT_BUTTONS_WIDTH = 232
/** The controls of the head band: one height, one radius, the card colour of the other trip bars. */
const CONTROL = 'h-8 rounded-[10px] shadow-sm'
/** A 32px icon control on the head band, named by its tooltip. `on` fills it in the accent (a mode that is switched on). */
function BandButton({ label, onClick, on = false, lit = false, ariaPressed, ariaExpanded, ariaHaspopup, children }: {
label: string
onClick: (e: ReactMouseEvent<HTMLButtonElement>) => void
on?: boolean
/** Brighter while its panel or menu is open, or while it is filtering. */
lit?: boolean
ariaPressed?: boolean
ariaExpanded?: boolean
ariaHaspopup?: 'dialog' | 'menu'
children: ReactNode
}) {
let tone = 'bg-surface-card text-content-secondary hover:text-content'
if (on) tone = 'bg-accent text-accent-text'
else if (lit) tone = 'bg-surface-card text-content'
return (
<Tooltip label={label}>
<button type="button" onClick={onClick} aria-label={label}
aria-pressed={ariaPressed} aria-expanded={ariaExpanded} aria-haspopup={ariaHaspopup}
className={`${CONTROL} relative grid w-8 flex-none place-items-center transition-colors ${tone}`}>
{children}
</button>
</Tooltip>
)
}
const RATING_FLOORS = ['all', 5, 4, 3, 2, 1] as const
export function PlacesDropOverlay({ t }: SidebarState) {
return (
<div style={{
position: 'absolute', inset: 0, zIndex: 10,
background: 'color-mix(in srgb, var(--accent) 12%, transparent)',
border: '2px dashed var(--accent)',
borderRadius: 4,
display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
gap: 10, pointerEvents: 'none',
}}>
<Upload size={28} strokeWidth={1.5} color="var(--accent)" />
<span className="text-accent" style={{ fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 600 }}>{t('places.sidebarDrop')}</span>
<div
className="pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-2.5 rounded-2xl border-2 border-dashed border-accent"
style={{ background: tintOf('var(--accent)', 12) }}
>
<Upload size={28} strokeWidth={1.5} className="text-accent" />
<span className="font-semibold text-accent" style={fs(13, 'body')}>{t('places.sidebarDrop')}</span>
</div>
)
}
/**
* The head of the places column, one tinted band like every panel head in the
* planner, in three rows: adding and importing first, as the column's main job;
* search with the category and rating filters and the select switch; what to
* show as tabs with their counts. While a day is open on the planned tab, a chip
* says so.
*/
export function PlacesHeader(S: SidebarState) {
const {
canEditPlaces, onAddPlace, onAddPlaceToSelectedDay, selectedDayId, t, setFileImportOpen, setListImportOpen, hasMultipleListImportProviders,
places, categories, categoryFilters, search, setSearch, plannedIds, plannedFilterIds, dayScoped, onClearSelectedDay, hasTracks,
filter, setFilter, setSelectedIds, selectMode, setSelectMode,
catDropOpen, setCatDropOpen, toggleCategoryFilter, setCategoryFilters,
ratingFilter, setRatingFilter,
starDropOpen, setStarDropOpen,
} = S
const dayOpen = selectedDayId != null
const { ref: buttonRowRef, width: buttonRowWidth } = useElementSize<HTMLDivElement>()
// Zero is the first paint, before the observer has measured anything — treat
// that as roomy so the labels do not flash away and back on every mount.
const compact = buttonRowWidth > 0 && buttonRowWidth < COMPACT_BUTTONS_WIDTH
const addLabel = t(dayOpen ? 'places.addPlaceShort' : 'places.addPlace')
const fileImportLabel = t('places.importFile')
const listImportLabel = t(hasMultipleListImportProviders ? 'places.importList' : 'places.importGoogleList')
const { canEditPlaces, t, selectMode, setSelectMode, setSelectedIds } = S
return (
<div className="border-b border-edge-faint" style={{ padding: '14px 16px 10px', flexShrink: 0 }}>
{canEditPlaces && <div ref={buttonRowRef} style={{ display: 'flex', gap: 6, marginBottom: 10 }}>
{/* The label shortens while the second button is out, so both fit side by
side in a default rail without either one truncating; a squeezed rail
drops it entirely and the aria-label carries the name instead. */}
<button type="button"
onClick={onAddPlace}
aria-label={compact ? addLabel : undefined}
title={compact ? addLabel : undefined}
className="bg-accent text-accent-text motion-reduce:transition-none"
style={{
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6,
// Both halves are driven by flex-basis rather than by grow, so the
// pair lands on an exact 50/50 and the handover animates in both
// directions. Half of the 6px gap comes off each side.
flexGrow: 0, flexShrink: 1, flexBasis: dayOpen ? 'calc(50% - 3px)' : '100%',
minWidth: 0, padding: '8px 12px', borderRadius: 12, border: 'none',
fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500,
cursor: 'pointer', fontFamily: 'inherit',
overflow: 'hidden', whiteSpace: 'nowrap',
transition: 'flex-basis 180ms ease',
}}
>
<Plus size={14} strokeWidth={2} />
{!compact && (
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{addLabel}
<div className="flex flex-none flex-col gap-2 border-b border-edge-faint px-3 py-2.5" style={{ background: NEUTRAL_TINT }}>
{canEditPlaces && <AddRow {...S} />}
<div className="relative flex items-center gap-1.5">
<SearchField {...S} />
{canEditPlaces && (
<BandButton
label={t('common.select')}
on={selectMode}
ariaPressed={selectMode}
onClick={() => { setSelectMode(v => !v); setSelectedIds(new Set()) }}
>
{selectMode ? <X size={15} strokeWidth={2.4} /> : <Check size={15} strokeWidth={2.4} />}
</BandButton>
)}
</div>
<div className="flex items-center gap-1.5">
<ShowDropdown {...S} />
<CategoryFilter {...S} />
<RatingFilter {...S} />
</div>
<ActiveFilterChips {...S} />
</div>
)
}
function SearchField({ t, search, setSearch, selectMode, setSelectedIds }: SidebarState) {
return (
<label className={`${CONTROL} flex min-w-0 flex-1 items-center gap-2 bg-surface-card pl-2.5 pr-1.5 text-content-faint focus-within:ring-2 focus-within:ring-[color:var(--text-primary)]`}>
<Search size={13} strokeWidth={2} className="flex-none" />
<input
type="text"
value={search}
onChange={e => { setSearch(e.target.value); if (selectMode) setSelectedIds(new Set()) }}
placeholder={t('common.search')}
aria-label={t('common.search')}
className="min-w-0 flex-1 border-0 bg-transparent text-content outline-none placeholder:text-content-faint"
style={fs(12.5, 'body')}
/>
{search && (
<Tooltip label={t('places.clearSearch')}>
<button type="button" onClick={() => setSearch('')} aria-label={t('places.clearSearch')}
className="grid h-5 w-5 flex-none place-items-center rounded-full text-content-faint hover:bg-surface-hover hover:text-content">
<X size={12} strokeWidth={2.2} />
</button>
</Tooltip>
)}
</label>
)
}
/** A category (or the no-category bucket) in the category list, ticked while it filters. */
function CategoryChoice({ on, onClick, tile, label }: { on: boolean; onClick: () => void; tile: ReactNode; label: string }) {
return (
<button type="button" onClick={onClick} aria-pressed={on}
className={`flex w-full items-center gap-2 rounded-[9px] px-1.5 py-1 text-left transition-colors ${on ? 'bg-surface-tertiary' : 'hover:bg-surface-hover'}`}
style={fs(12.5, 'body')}>
{tile}
<span className="min-w-0 flex-1 truncate text-content">{label}</span>
{on && <Check size={13} strokeWidth={2.4} className="flex-none text-content-muted" />}
</button>
)
}
/** The "show" choices; tracks only once a place has one. */
function filterTabs({ t, hasTracks }: Pick<SidebarState, 't' | 'hasTracks'>) {
const tabs: Array<{ id: PlacesFilter; label: string }> = [
{ id: 'all', label: t('places.all') },
{ id: 'unplanned', label: t('places.unplanned') },
{ id: 'planned', label: t('places.planned') },
]
if (hasTracks) tabs.push({ id: 'tracks', label: t('places.filterTracks') })
return tabs
}
/** What the list shows (every place, the unplanned, the planned, the tracks) as one dropdown with their counts. */
function ShowDropdown(S: SidebarState) {
const { t, filter, pickFilter, filterCounts } = S
const [open, setOpen] = useState(false)
const tabs = filterTabs(S)
const current = tabs.find(tab => tab.id === filter) ?? tabs[0]
return (
<FilterDropdown
wide
name={t('places.filterShow')}
label={current.label}
count={filterCounts[current.id]}
active={filter !== 'all'}
open={open}
setOpen={setOpen}
>
<div data-testid="places-filter" role="group" aria-label={t('places.filterShow')} className="flex flex-col gap-px">
{tabs.map(tab => {
const on = filter === tab.id
return (
<button type="button" key={tab.id} onClick={() => { pickFilter(tab.id); setOpen(false) }} aria-pressed={on}
className={`flex w-full items-center gap-2 rounded-[9px] px-2 py-1.5 text-left transition-colors ${on ? 'bg-surface-tertiary' : 'hover:bg-surface-hover'}`}
style={fs(12.5, 'body')}>
<span className="min-w-0 flex-1 truncate text-content">{tab.label}</span>
<span className="font-geist tabular-nums text-content-faint" style={fs(11)}>{filterCounts[tab.id]}</span>
<span className="grid w-3.5 flex-none place-items-center">{on && <Check size={13} strokeWidth={2.4} className="text-content-muted" />}</span>
</button>
)
})}
</div>
</FilterDropdown>
)
}
/**
* A filter as one icon on the tabs row, opening a small list under it; closes on a
* click outside or Escape. A badge marks it while it is narrowing the list, and the
* tooltip says to what.
*/
function FilterDropdown({ label, active, badge, icon, open, setOpen, name, children, wide = false, count }: {
/** What is in force: on the trigger when `wide`, else in the tooltip ("All categories", "4+"). */
label: string
active: boolean
badge?: string | number
icon?: ReactNode
/** Takes the row's free width and shows its label (and `count`) on the trigger. */
wide?: boolean
count?: number
open: boolean
setOpen: (v: boolean | ((v: boolean) => boolean)) => void
/** The trigger's accessible name: what it filters by. */
name: string
children: ReactNode
}) {
const wrapRef = useRef<HTMLDivElement>(null)
useEffect(() => {
if (!open) return
const onDown = (e: MouseEvent) => { if (!wrapRef.current?.contains(e.target as Node)) setOpen(false) }
// Captured and stopped, so the key takes back the list and nothing under it.
const onKey = (e: KeyboardEvent) => {
if (e.key !== 'Escape') return
e.stopPropagation()
setOpen(false)
wrapRef.current?.querySelector('button')?.focus()
}
document.addEventListener('mousedown', onDown)
document.addEventListener('keydown', onKey, true)
return () => {
document.removeEventListener('mousedown', onDown)
document.removeEventListener('keydown', onKey, true)
}
}, [open, setOpen])
return (
<div ref={wrapRef} className={`relative ${wide ? 'min-w-0 flex-1' : 'flex-none'}`}>
{wide ? (
<button type="button" onClick={() => setOpen(v => !v)} aria-expanded={open} aria-haspopup="listbox" aria-label={name}
className={`${CONTROL} flex w-full min-w-0 items-center gap-1.5 bg-surface-card px-2.5 font-semibold transition-colors ${active || open ? 'text-content' : 'text-content-secondary hover:text-content'}`}
style={fs(12, 'body')}>
<span className="min-w-0 truncate text-left">{label}</span>
{count != null && <span className="font-geist tabular-nums text-content-faint" style={fs(10.5)}>{count}</span>}
<ChevronDown size={13} strokeWidth={2.2} className={`ml-auto flex-none text-content-faint transition-transform ${open ? 'rotate-180' : ''}`} />
</button>
) : (
<Tooltip label={active ? `${name}: ${label}` : name} disabled={open}>
<button type="button" onClick={() => setOpen(v => !v)} aria-expanded={open} aria-haspopup="listbox" aria-label={name}
className={`${CONTROL} relative grid w-8 place-items-center bg-surface-card transition-colors ${active || open ? 'text-content' : 'text-content-secondary hover:text-content'}`}>
{icon}
{active && badge != null && (
<span className="absolute -right-1 -top-1 grid h-4 min-w-4 place-items-center rounded-full bg-accent px-1 font-geist font-bold tabular-nums text-accent-text" style={fs(9)}>
{badge}
</span>
)}
</button>
</Tooltip>
)}
{open && (
<div className={`trek-popover-enter absolute ${wide ? 'left-0' : 'right-0'} top-full z-50 mt-1.5 flex max-h-[min(60vh,360px)] flex-col overflow-y-auto rounded-[12px] border border-edge-secondary bg-surface-card p-1.5 shadow-popover`} style={{ width: 'max-content', minWidth: 180, maxWidth: 260 }}>
{children}
</div>
)}
</div>
)
}
/** Which categories to show, many at once; the label says what is in force. */
function CategoryFilter(S: SidebarState) {
const { t, places, categories, categoryFilters, setCategoryFilters, toggleCategoryFilter } = S
const [open, setOpen] = useState(false)
if (categories.length === 0) return null
let label = t('places.allCategories')
if (categoryFilters.size === 1) {
const only = categories.find(c => categoryFilters.has(String(c.id)))
if (categoryFilters.has('uncategorized')) label = t('places.noCategory')
else if (only) label = only.name
} else if (categoryFilters.size > 1) {
label = `${categoryFilters.size} ${t('places.categoriesSelected')}`
}
return (
<FilterDropdown name={t('categories.title')} label={label} active={categoryFilters.size > 0} badge={categoryFilters.size}
icon={<Tag size={14} strokeWidth={2} />} open={open} setOpen={setOpen}>
{categories.map(c => (
<CategoryChoice
key={c.id}
on={categoryFilters.has(String(c.id))}
onClick={() => toggleCategoryFilter(String(c.id))}
tile={<CategoryTile category={c} size={22} />}
label={c.name}
/>
))}
{places.some(p => p.category_id == null) && (
<CategoryChoice
on={categoryFilters.has('uncategorized')}
onClick={() => toggleCategoryFilter('uncategorized')}
tile={<CategoryTile size={22} />}
label={t('places.noCategory')}
/>
)}
{categoryFilters.size > 0 && (
<button type="button" onClick={() => setCategoryFilters(new Set())}
className="mt-1 flex w-full items-center gap-1.5 rounded-[9px] border-t border-edge-faint px-1.5 pb-1 pt-2 text-left font-semibold text-content-muted hover:text-content"
style={fs(12, 'body')}>
<X size={12} strokeWidth={2.4} />
{t('places.clearFilter')}
</button>
)}
</FilterDropdown>
)
}
/** A minimum of stars (#1435), the same floors as the collections bar. */
function RatingFilter(S: SidebarState) {
const { t, ratingFilter, setRatingFilter } = S
const [open, setOpen] = useState(false)
const star = <Star size={12} strokeWidth={2.2} fill="currentColor" className="flex-none text-warning" />
return (
<FilterDropdown
label={ratingFilter === 'all' ? t('common.all') : `${ratingFilter}+`}
name={t('places.filterByRating')}
active={ratingFilter !== 'all'}
badge={ratingFilter === 'all' ? undefined : `${ratingFilter}+`}
icon={<Star size={14} strokeWidth={2} className={ratingFilter === 'all' ? '' : 'fill-current text-warning'} />}
open={open}
setOpen={setOpen}
>
{RATING_FLOORS.map(opt => {
const on = ratingFilter === opt
return (
<button type="button" key={String(opt)} onClick={() => { setRatingFilter(opt); setOpen(false) }} aria-pressed={on}
className={`flex w-full items-center gap-2 rounded-[9px] px-2 py-1.5 text-left transition-colors ${on ? 'bg-surface-tertiary' : 'hover:bg-surface-hover'}`}
style={fs(12.5, 'body')}>
{opt === 'all' ? <span className="w-3" /> : star}
<span className="min-w-0 flex-1 text-content">{opt === 'all' ? t('common.all') : `${opt}+`}</span>
{on && <Check size={13} strokeWidth={2.4} className="flex-none text-content-muted" />}
</button>
)
})}
</FilterDropdown>
)
}
function AddRow(S: SidebarState) {
const { onAddPlace, onAddPlaceToSelectedDay, selectedDayId, t, setFileImportOpen, setListImportOpen, hasMultipleListImportProviders } = S
const dayOpen = selectedDayId != null
const split = dayOpen && !!onAddPlaceToSelectedDay
const { ref: rowRef, width: rowWidth } = useElementSize<HTMLDivElement>()
// Zero is the first paint, before the observer has measured anything — treat
// that as roomy so the labels do not flash away and back on every mount.
const compact = rowWidth > 0 && rowWidth < COMPACT_BUTTONS_WIDTH
const addLabel = t(dayOpen ? 'places.addPlaceShort' : 'places.addPlace')
const importMenu = useContextMenu()
const importItems = [
{ label: t('places.importFile'), icon: FileDown, onClick: () => setFileImportOpen(true) },
{ label: t(hasMultipleListImportProviders ? 'places.importList' : 'places.importGoogleList'), icon: ListPlus, onClick: () => setListImportOpen(true) },
]
return (
<div ref={rowRef} className="flex items-center gap-1.5">
{/* The label shortens while the second button is out, so both fit side by
side in a default rail without either one truncating; a squeezed rail
drops the labels entirely and the aria-labels carry the names instead. */}
<div className="flex min-w-0 flex-1 gap-1.5">
<Tooltip label={addLabel} disabled={!compact}>
<button type="button"
onClick={onAddPlace}
aria-label={compact ? addLabel : undefined}
className={`${CONTROL} flex min-w-0 items-center justify-center gap-1.5 overflow-hidden whitespace-nowrap bg-accent px-3 font-semibold text-accent-text transition-[flex-basis] duration-200 hover:opacity-90 motion-reduce:transition-none`}
// Both halves are driven by flex-basis rather than by grow, so the pair
// lands on an exact 50/50 and the handover animates in both directions.
style={{ ...fs(12.5, 'body'), flex: `0 1 ${split ? 'calc(50% - 3px)' : '100%'}` }}
>
<Plus size={14} strokeWidth={2.2} className="flex-none" />
{!compact && <span className="truncate">{addLabel}</span>}
</button>
</Tooltip>
{/* Kept mounted and collapsed rather than unmounted, so it has something
to animate out of: a button that only exists while a day is open
would appear and vanish on the spot. Hidden from the tab order and
from screen readers in the same breath, because a zero-width button
is still focusable otherwise. */}
to animate out of. Hidden from the tab order and from screen readers in
the same breath, because a zero-width button is still focusable otherwise. */}
{onAddPlaceToSelectedDay && (
<Tooltip label={t('places.addToSelectedDay')} disabled={!dayOpen}>
<button type="button"
@@ -91,347 +369,66 @@ export function PlacesHeader(S: SidebarState) {
data-testid="add-place-to-day"
aria-hidden={!dayOpen}
tabIndex={dayOpen ? 0 : -1}
className="bg-accent text-accent-text motion-reduce:transition-none"
style={{
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6,
flexGrow: 0, flexShrink: 1, flexBasis: dayOpen ? 'calc(50% - 3px)' : '0%',
minWidth: 0,
opacity: dayOpen ? 1 : 0,
padding: dayOpen ? '8px 12px' : 0,
borderRadius: 12, border: 'none',
fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500,
cursor: 'pointer', fontFamily: 'inherit', overflow: 'hidden', whiteSpace: 'nowrap',
pointerEvents: dayOpen ? 'auto' : 'none',
transition: 'flex-basis 180ms ease, opacity 140ms ease, padding 180ms ease',
}}
className={`flex h-8 min-w-0 items-center justify-center gap-1.5 overflow-hidden whitespace-nowrap rounded-[10px] bg-surface-card font-semibold text-content transition-[flex-basis,opacity,padding] duration-200 hover:text-content-secondary motion-reduce:transition-none ${dayOpen ? 'px-3 opacity-100 shadow-sm' : 'pointer-events-none px-0 opacity-0 shadow-none'}`}
style={{ ...fs(12.5, 'body'), flex: `0 1 ${dayOpen ? 'calc(50% - 3px)' : '0%'}` }}
>
<CalendarPlus size={14} strokeWidth={2} style={{ flexShrink: 0 }} />
{!compact && t('places.addToDayShort')}
<CalendarPlus size={14} strokeWidth={2} className="flex-none" />
{!compact && <span className="truncate">{t('places.addToDayShort')}</span>}
</button>
</Tooltip>
)}
</div>}
{canEditPlaces && <>
{/* Same squeeze rule as the row above, measured off the same rail: once the
add buttons lose their labels these two would not fit either. */}
<div style={{ display: 'flex', gap: 6, marginBottom: 10 }}>
<button type="button"
onClick={() => setFileImportOpen(true)}
aria-label={compact ? fileImportLabel : undefined}
title={compact ? fileImportLabel : undefined}
className="border border-dashed border-edge text-content-faint"
style={{
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 5,
flex: 1, minWidth: 0, padding: '5px 12px', borderRadius: 8,
background: 'none', fontSize: 'calc(11px * var(--fs-scale-caption, 1))', fontWeight: 500,
cursor: 'pointer', fontFamily: 'inherit',
overflow: 'hidden', whiteSpace: 'nowrap',
}}
>
<FileDown size={11} strokeWidth={2} /> {!compact && fileImportLabel}
</button>
<button type="button"
onClick={() => setListImportOpen(true)}
aria-label={compact ? listImportLabel : undefined}
title={compact ? listImportLabel : undefined}
className="border border-dashed border-edge text-content-faint"
style={{
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 5,
flex: 1, minWidth: 0, padding: '5px 12px', borderRadius: 8,
background: 'none', fontSize: 'calc(11px * var(--fs-scale-caption, 1))', fontWeight: 500,
cursor: 'pointer', fontFamily: 'inherit',
overflow: 'hidden', whiteSpace: 'nowrap',
}}
>
<MapPin size={11} strokeWidth={2} /> {!compact && listImportLabel}
</button>
</div>
<div className="bg-edge" style={{ height: 1, margin: '2px 0 10px' }} />
</>}
{/* Filter-Tabs */}
{(() => {
const baseFiltered = places.filter(p => {
if (categoryFilters.size > 0) {
if (p.category_id == null) {
if (!categoryFilters.has('uncategorized')) return false
} else if (!categoryFilters.has(String(p.category_id))) return false
}
if (search && !p.name.toLowerCase().includes(search.toLowerCase()) &&
!(p.address || '').toLowerCase().includes(search.toLowerCase())) return false
return true
})
const counts = {
all: baseFiltered.length,
unplanned: baseFiltered.filter(p => !plannedIds.has(p.id)).length,
// While a day is open this counts that day's plan, the same set the list and
// the map show. Counting the whole trip here is what made the tab read 55
// beside five pins, with nothing to say the two were answering different
// questions.
planned: baseFiltered.filter(p => plannedFilterIds.has(p.id)).length,
tracks: baseFiltered.filter(p => p.route_geometry).length,
}
const tabs = ([
{ id: 'all', label: t('places.all') },
{ id: 'unplanned', label: t('places.unplanned') },
{ id: 'planned', label: t('places.planned') },
hasTracks ? { id: 'tracks', label: t('places.filterTracks') } : null,
] as const).filter(Boolean) as Array<{ id: 'all' | 'unplanned' | 'planned' | 'tracks'; label: string }>
return (
// One select where four pills used to fight for the rail's width: with the
// tracks tab the row had grown past what a narrow panel can hold without
// clipping a word. The count rides on the trigger the way it rode on the
// active pill, and every option carries its own in the menu.
<div data-testid="places-filter" style={{ marginBottom: 8 }}>
<CustomSelect
size="sm"
value={filter}
onChange={v => { setFilter(v as 'all' | 'unplanned' | 'planned' | 'tracks'); setSelectedIds(new Set()) }}
options={tabs.map(f => ({ value: f.id, label: f.label, badge: String(counts[f.id]) }))}
/>
</div>
)
})()}
{/* Says out loud what the count above already narrowed to.
The map has followed the open day on this filter since #2024, and until now
nothing anywhere said so: the pool read 55, the map drew five, and the honest
conclusion was that the map was broken. It sits under the filter select
rather than on the map because a chip over the canvas is unreachable on a
phone, which is where this was reported from. */}
{dayScoped && (
<div
className="border border-edge-faint bg-surface-tertiary text-content-secondary"
style={{
display: 'flex', alignItems: 'center', gap: 6,
padding: '4px 6px 4px 9px', borderRadius: 8, marginBottom: 8,
fontSize: 'calc(11px * var(--fs-scale-caption, 1))',
}}
>
<CalendarDays size={11} strokeWidth={2} style={{ flexShrink: 0 }} />
<span style={{ minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{t('places.dayScoped')}
</span>
{onClearSelectedDay && (
<button type="button"
onClick={onClearSelectedDay}
aria-label={t('places.dayScopedClear')}
title={t('places.dayScopedClear')}
className="text-content-faint hover:text-content"
style={{
marginInlineStart: 'auto', display: 'flex', alignItems: 'center',
background: 'none', border: 'none', padding: 3, cursor: 'pointer', flexShrink: 0,
}}
>
<X size={12} strokeWidth={2.2} />
</button>
)}
</div>
)}
{/* Suchfeld */}
<div style={{ position: 'relative' }}>
<Search size={13} strokeWidth={1.8} color="var(--text-faint)" style={{ position: 'absolute', left: 10, top: '50%', transform: 'translateY(-50%)', pointerEvents: 'none' }} />
<input
type="text"
value={search}
onChange={e => { setSearch(e.target.value); if (selectMode) setSelectedIds(new Set()) }}
placeholder={t('places.search')}
className="bg-surface-card text-content"
style={{
width: '100%', padding: '7px 30px 7px 30px', borderRadius: 10,
// Borderless on the tertiary surface it sat almost flush with the
// panel; the outline is the one the category dropdown below already
// uses, so the two read as the same kind of control.
border: '1px solid var(--border-primary)',
fontSize: 'calc(12px * var(--fs-scale-body, 1))',
outline: 'none', fontFamily: 'inherit', boxSizing: 'border-box',
}}
/>
{search && (
<button type="button" onClick={() => setSearch('')} style={{ position: 'absolute', right: 8, top: '50%', transform: 'translateY(-50%)', background: 'none', border: 'none', cursor: 'pointer', padding: 0, display: 'flex' }}>
<X size={12} strokeWidth={2} color="var(--text-faint)" />
</button>
)}
</div>
{/* Category multi-select plus the star filter. Rendered even without any
category, because the rating filter does not depend on one and a fresh
trip is exactly where someone collects places to rate. */}
{(() => {
const label = categoryFilters.size === 0
? t('places.allCategories')
: categoryFilters.size === 1
? (categoryFilters.has('uncategorized') ? t('places.noCategory') : categories.find(c => categoryFilters.has(String(c.id)))?.name || t('places.allCategories'))
: `${categoryFilters.size} ${t('places.categoriesSelected')}`
return (
<div style={{ marginTop: 6, position: 'relative', display: 'flex', gap: 6, alignItems: 'stretch' }}>
{categories.length > 0 && <button type="button" onClick={() => setCatDropOpen(v => !v)} className="bg-surface-card text-content" style={{
flex: 1, minWidth: 0, display: 'flex', alignItems: 'center', justifyContent: 'space-between',
padding: '6px 10px', borderRadius: 8, border: '1px solid var(--border-primary)',
fontSize: 'calc(12px * var(--fs-scale-body, 1))',
cursor: 'pointer', fontFamily: 'inherit',
}}>
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{label}</span>
<ChevronDown size={12} className="text-content-faint" style={{ flexShrink: 0, transform: catDropOpen ? 'rotate(180deg)' : 'none', transition: 'transform 0.15s' }} />
</button>}
{/* Minimum-stars filter (#1435), same floors as the collections bar. */}
<Tooltip label={t('places.filterByRating')} placement="bottom">
<button type="button"
onClick={() => { setStarDropOpen(v => !v); setCatDropOpen(false) }}
aria-label={t('places.filterByRating')}
aria-expanded={starDropOpen}
className={ratingFilter !== 'all' ? 'text-accent' : 'text-content-faint'}
style={{
height: 30, flexShrink: 0, borderRadius: 8, gap: 3,
padding: ratingFilter === 'all' ? 0 : '0 7px',
width: ratingFilter === 'all' ? 30 : undefined,
border: `1px solid ${ratingFilter !== 'all' ? 'var(--accent)' : 'var(--border-primary)'}`,
background: ratingFilter !== 'all' ? 'color-mix(in srgb, var(--accent) 14%, transparent)' : 'var(--bg-card)',
cursor: 'pointer', fontFamily: 'inherit',
fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 600,
display: 'flex', alignItems: 'center', justifyContent: 'center',
transition: 'background 0.18s, color 0.18s, border-color 0.18s',
}}
>
<Star size={13} strokeWidth={2.2} fill={ratingFilter !== 'all' ? 'currentColor' : 'none'} />
{ratingFilter !== 'all' && <span>{ratingFilter}+</span>}
</button>
</Tooltip>
{starDropOpen && (
<div className="bg-surface-card" style={{
position: 'absolute', top: '100%', right: 0, zIndex: 50, marginTop: 4, minWidth: 116,
border: '1px solid var(--border-primary)', borderRadius: 10,
boxShadow: '0 4px 16px rgba(0,0,0,0.12)', padding: 4,
}}>
{(['all', 5, 4, 3, 2, 1] as const).map(opt => {
const active = ratingFilter === opt
return (
<button type="button"
key={String(opt)}
onClick={() => { setRatingFilter(opt as number | 'all'); setStarDropOpen(false) }}
className={`text-content ${active ? 'bg-surface-hover' : 'bg-transparent'}`}
style={{
display: 'flex', alignItems: 'center', gap: 7, width: '100%',
padding: '6px 10px', borderRadius: 6, border: 'none', cursor: 'pointer',
fontFamily: 'inherit', fontSize: 'calc(12px * var(--fs-scale-body, 1))',
textAlign: 'left',
}}
>
{opt === 'all'
? <span style={{ flex: 1 }}>{t('common.all')}</span>
: (
<>
<Star size={12} strokeWidth={2.2} color="#facc15" fill="#facc15" />
<span style={{ flex: 1 }}>{opt}+</span>
</>
)}
{active && <Check size={11} strokeWidth={3} className="text-content-faint" />}
</button>
)
})}
</div>
)}
{canEditPlaces && (
<Tooltip label={t('common.select')} placement="bottom">
<button type="button"
onClick={() => { setSelectMode(v => !v); setSelectedIds(new Set()) }}
aria-label={t('common.select')}
aria-pressed={selectMode}
className={selectMode ? 'text-accent' : 'text-content-faint'}
style={{
position: 'relative', width: 30, flexShrink: 0, borderRadius: 8,
border: `1px solid ${selectMode ? 'var(--accent)' : 'var(--border-primary)'}`,
background: selectMode ? 'color-mix(in srgb, var(--accent) 14%, transparent)' : 'var(--bg-card)',
cursor: 'pointer', fontFamily: 'inherit', padding: 0,
transition: 'background 0.18s, color 0.18s, border-color 0.18s',
overflow: 'hidden',
}}
>
<span style={{
position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center',
transition: 'opacity 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1)',
opacity: selectMode ? 0 : 1,
transform: selectMode ? 'rotate(-90deg) scale(0.6)' : 'rotate(0) scale(1)',
}}>
<Check size={13} strokeWidth={2.4} />
</span>
<span style={{
position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center',
transition: 'opacity 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1)',
opacity: selectMode ? 1 : 0,
transform: selectMode ? 'rotate(0) scale(1)' : 'rotate(90deg) scale(0.6)',
}}>
<X size={13} strokeWidth={2.4} />
</span>
</button>
</Tooltip>
)}
{catDropOpen && categories.length > 0 && (
<div className="bg-surface-card" style={{
position: 'absolute', top: '100%', left: 0, right: 0, zIndex: 50, marginTop: 4,
border: '1px solid var(--border-primary)', borderRadius: 10,
boxShadow: '0 4px 16px rgba(0,0,0,0.12)', padding: 4, maxHeight: 200, overflowY: 'auto',
}}>
{categories.map(c => {
const active = categoryFilters.has(String(c.id))
const CatIcon = getCategoryIcon(c.icon)
return (
<button type="button" key={c.id} onClick={() => toggleCategoryFilter(String(c.id))} className={`text-content ${active ? 'bg-surface-hover' : 'bg-transparent'}`} style={{
display: 'flex', alignItems: 'center', gap: 8, width: '100%',
padding: '6px 10px', borderRadius: 6, border: 'none', cursor: 'pointer',
fontFamily: 'inherit', fontSize: 'calc(12px * var(--fs-scale-body, 1))',
textAlign: 'left',
}}>
<div style={{
width: 16, height: 16, borderRadius: 4, flexShrink: 0,
border: active ? 'none' : '1.5px solid var(--border-primary)',
background: active ? (c.color || 'var(--accent)') : 'transparent',
display: 'flex', alignItems: 'center', justifyContent: 'center',
}}>
{active && <Check size={10} strokeWidth={3} color="white" />}
</div>
<CatIcon size={12} strokeWidth={2} color={c.color || 'var(--text-muted)'} />
<span style={{ flex: 1 }}>{c.name}</span>
</button>
)
})}
{places.some(p => p.category_id == null) && (() => {
const active = categoryFilters.has('uncategorized')
return (
<button type="button" onClick={() => toggleCategoryFilter('uncategorized')} className={`text-content-muted ${active ? 'bg-surface-hover' : 'bg-transparent'}`} style={{
display: 'flex', alignItems: 'center', gap: 8, width: '100%',
padding: '6px 10px', borderRadius: 6, border: 'none', cursor: 'pointer',
fontFamily: 'inherit', fontSize: 'calc(12px * var(--fs-scale-body, 1))',
textAlign: 'left', borderTop: '1px solid var(--border-faint)', marginTop: 2,
}}>
<div className={active ? 'bg-[var(--text-faint)]' : 'bg-transparent'} style={{
width: 16, height: 16, borderRadius: 4, flexShrink: 0,
border: active ? 'none' : '1.5px solid var(--border-primary)',
display: 'flex', alignItems: 'center', justifyContent: 'center',
}}>
{active && <Check size={10} strokeWidth={3} color="white" />}
</div>
<MapPin size={12} strokeWidth={2} color="var(--text-faint)" />
<span style={{ flex: 1 }}>{t('places.noCategory')}</span>
</button>
)
})()}
{categoryFilters.size > 0 && (
<button type="button" onClick={() => setCategoryFilters(new Set())} className="bg-transparent text-content-faint" style={{
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 4,
width: '100%', padding: '6px 10px', borderRadius: 6, border: 'none', cursor: 'pointer',
fontFamily: 'inherit', fontSize: 'calc(11px * var(--fs-scale-caption, 1))',
marginTop: 2, borderTop: '1px solid var(--border-faint)',
}}>
<X size={10} /> {t('places.clearFilter')}
</button>
)}
</div>
)}
</div>
)
})()}
<BandButton
label={t('mobileTrip.importPlaces')}
lit={!!importMenu.menu}
ariaHaspopup="menu"
ariaExpanded={!!importMenu.menu}
onClick={e => { if (importMenu.menu) importMenu.close(); else importMenu.open(e, importItems, true) }}
>
<FileDown size={15} strokeWidth={2} />
</BandButton>
<ContextMenu menu={importMenu.menu} onClose={importMenu.close} />
</div>
)
}
/** A filter in force, said out loud, with the X that lifts it. */
function FilterChip({ label, clearLabel, onClear, icon, tone = 'neutral' }: {
label: string
/** The X's name; its tooltip, too, unless the X says more than the tooltip. */
clearLabel: string
onClear?: () => void
icon?: ReactNode
tone?: 'neutral' | 'info'
}) {
const look = tone === 'info' ? 'bg-info-soft text-info' : 'border border-edge-faint bg-surface-card text-content-secondary'
return (
<span className={`inline-flex min-w-0 max-w-full items-center gap-1 rounded-full py-[3px] font-semibold ${onClear ? 'pl-2 pr-[3px]' : 'px-2'} ${look}`} style={fs(11)}>
{icon}
<span className="min-w-0 truncate">{label}</span>
{onClear && (
<Tooltip label={clearLabel}>
<button type="button" onClick={onClear} aria-label={clearLabel}
className="grid h-[18px] w-[18px] flex-none place-items-center rounded-full opacity-70 transition-opacity hover:bg-surface-hover hover:opacity-100">
<X size={11} strokeWidth={2.4} />
</button>
</Tooltip>
)}
</span>
)
}
function ActiveFilterChips(S: SidebarState) {
const { t, dayScoped, onClearSelectedDay } = S
// Says out loud what the count below already narrowed to. The map has followed
// the open day on this filter since #2024, and until this said so the pool read 55
// beside five pins and the honest conclusion was that the map was broken. The X
// closes the day rather than changing the filter.
if (!dayScoped) return null
return (
<div className="flex flex-wrap gap-1.5">
<FilterChip tone="info" label={t('places.dayScoped')} clearLabel={t('places.dayScopedClear')} onClear={onClearSelectedDay}
icon={<CalendarDays size={11} strokeWidth={2.2} className="flex-none" />} />
</div>
)
}