Files
TREK/client/src/components/Collections/CollectionMapPanel.tsx
T
Maurice b65a1bb65c feat(collections): the map's padlock, and a picked place on the full map keeps the map
The collections map gets the trip map's padlock (#2010): locked, a click on a
place leaves the camera where it is, so places can be clicked through without
the map zooming in and out. One setting for both maps. On the full map a
picked place no longer brings the list back: its details dock on the map's
edge, or open as a sheet on a narrow screen.
2026-11-15 12:11:42 +01:00

95 lines
3.5 KiB
TypeScript

import React from 'react'
import { PanelLeftClose, PanelLeftOpen, Search } from 'lucide-react'
import type { CollectionPlace } from '@trek/shared'
import type { TranslationFn } from '../../types'
import CollectionMap from './CollectionMap'
import CollectionLabelFilter, { type LabelOption } from './CollectionLabelFilter'
interface CollectionMapPanelProps {
places: CollectionPlace[]
selectedPlaceId: number | null
onSelect: (id: number) => void
onDeselect: () => void
dark: boolean
/** Render the floating map controls (desktop). Mobile drives view from the toolbar. */
overlay: boolean
/** 'list' = split (map can be expanded); 'map' = full (list collapsed). */
view: 'list' | 'map'
onToggleView: () => void
search: string
onSearch: (v: string) => void
/**
* The label filter rides along in the map's top bar, where there is room for
* it. The filter row keeps it whenever no map is on screen, so it can never
* become unreachable.
*/
labelOptions?: LabelOption[]
labelFilter?: number[]
onLabelFilter?: (ids: number[]) => void
canManageLabels?: boolean
onManageLabels?: () => void
/** The padlock on the desktop map (#2010); the phone has no hover to look around with. */
mapLocked?: boolean
onToggleMapLocked?: () => void
t: TranslationFn
}
/**
* The map surface for the collections page — the map plus its floating controls:
* a top-left cluster (collapse/expand the list, toggle bulk-select) and a
* top-right search box. Used both in the desktop split and the full-map view.
*/
export default function CollectionMapPanel({
places, selectedPlaceId, onSelect, onDeselect, dark, overlay, view, onToggleView,
search, onSearch, labelOptions = [], labelFilter = [], onLabelFilter, canManageLabels = false,
onManageLabels, mapLocked = false, onToggleMapLocked, t,
}: CollectionMapPanelProps): React.ReactElement {
const showLabels = onLabelFilter != null && (labelOptions.length > 0 || canManageLabels)
return (
<div className="col-map-shell">
<CollectionMap
places={places}
selectedPlaceId={selectedPlaceId}
onOpenPlace={onSelect}
onDeselect={onDeselect}
dark={dark}
underBar={overlay}
locked={overlay && mapLocked}
onToggleLock={overlay ? onToggleMapLocked : undefined}
/>
{overlay && (
<div className="col-map-topbar">
<div className="col-map-group">
<button
type="button"
onClick={onToggleView}
className="col-map-btn"
aria-label={view === 'map' ? t('collections.showList') : t('collections.expandMap')}
title={view === 'map' ? t('collections.showList') : t('collections.expandMap')}
>
{view === 'map' ? <PanelLeftOpen size={17} /> : <PanelLeftClose size={17} />}
</button>
{showLabels && (
<CollectionLabelFilter
variant="map"
labelOptions={labelOptions}
labelFilter={labelFilter}
onLabelFilter={onLabelFilter!}
canManageLabels={canManageLabels}
onManageLabels={onManageLabels}
t={t}
/>
)}
</div>
<div className="col-map-group right">
<div className="col-map-search">
<Search size={15} />
<input value={search} onChange={e => onSearch(e.target.value)} placeholder={t('collections.search')} />
</div>
</div>
</div>
)}
</div>
)
}