mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
feat(places): Places replaces Collections, with All places, place sheets and a calmer list
- Collections is Places now: /places opens "All places", every place of the trips and lists with where it comes from, the same filter row (where from, status, category, order), map bar (search, lock, list toggle) and place sheet as a list; /places/saved and /places/:id are the lists, and the old /collections links still land there. On the phone the same, with its own sheet. A place sheet shows each trip (planned day or trip dates, stay, booking, notes) and each list (status, labels, rating, notes) as one row that opens it. - The rail: a calm "New list" with its plus tile, All places and All saved as views, a "My lists" heading, every name on one edge. Lists can carry one of 24 symbols, shown in their colour in the rail and the editor. - A saved place's row keeps to two lines: its category as an icon before the name, its average vote as a star on the picture. Map pins wear the same star. - The place forms put the category in front of the name as a tile that opens the category list, instead of a row of chips. - All saved gets a subtitle; the import dialog opens centred. - Fixes: a pasted coordinate pair splits from either field of the place form; "more" in All places frees itself when a filter changes mid-load; place names on the trip map and the rating badge follow the reading direction.
This commit is contained in:
@@ -7,13 +7,13 @@ import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, D
|
||||
import { AddRowButton, EditorField, INPUT, Segmented, TEXTAREA } from '../shared/dialogParts'
|
||||
import NoteFormatToolbar from '../shared/NoteFormatToolbar'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { getCategoryIcon } from '../shared/categoryIcons'
|
||||
import { normalizeLinkUrl, STATUS_META, STATUS_ORDER } from '../../pages/collections/collectionsModel'
|
||||
import type { Category, TranslationFn } from '../../types'
|
||||
import type { CollectionStatus } from '@trek/shared'
|
||||
import { str } from './addPlaceModel'
|
||||
import { useAddPlaceToCollection } from './useAddPlaceToCollection'
|
||||
import { PlaceFormLocation } from '../Planner/PlaceFormLocation'
|
||||
import CategoryTileMenu from './CategoryTileMenu'
|
||||
|
||||
/**
|
||||
* The search row, pinned to the top of the scrolling body. The dialog stays open
|
||||
@@ -22,10 +22,6 @@ import { PlaceFormLocation } from '../Planner/PlaceFormLocation'
|
||||
* margins let its background cover the body's padding while it is stuck.
|
||||
*/
|
||||
const STICKY_SEARCH = 'sticky top-0 z-20 -mx-6 -mt-5 bg-surface-card px-6 pb-4 pt-5'
|
||||
/** A chip of the category row; the picked one wears the category's own colour. */
|
||||
const CHIP = 'inline-flex items-center gap-1.5 rounded-full border px-3 py-1 font-semibold'
|
||||
const CHIP_OFF = 'border-edge-faint bg-surface-card text-content-muted hover:text-content'
|
||||
const CHIP_NONE_ON = 'border-content bg-surface-card text-content'
|
||||
const ROW_ACTION = 'grid h-8 w-8 flex-none place-items-center rounded-[9px] text-content-faint hover:bg-surface-secondary'
|
||||
|
||||
interface AddPlaceToCollectionModalProps {
|
||||
@@ -65,7 +61,10 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
|
||||
|
||||
const header = (
|
||||
<DialogHeader
|
||||
tile={<DialogTile><MapPinned size={20} strokeWidth={1.9} className="text-content-muted" /></DialogTile>}
|
||||
// The category is the tile in front of the name: one tap picks it, no chip row below.
|
||||
tile={categories.length > 0
|
||||
? <CategoryTileMenu categories={categories} value={categoryId} onChange={setCategoryId} t={t} />
|
||||
: <DialogTile><MapPinned size={20} strokeWidth={1.9} className="text-content-muted" /></DialogTile>}
|
||||
tint={NEUTRAL_TINT}
|
||||
labelId={labelId}
|
||||
onClose={onClose}
|
||||
@@ -178,39 +177,6 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
|
||||
/>
|
||||
</EditorField>
|
||||
|
||||
{categories.length > 0 && (
|
||||
<EditorField label={t('collections.category')}>
|
||||
<div role="group" aria-label={t('collections.category')} className="flex flex-wrap gap-1.5">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setCategoryId(null)}
|
||||
aria-pressed={categoryId == null}
|
||||
className={`${CHIP} ${categoryId == null ? CHIP_NONE_ON : CHIP_OFF}`}
|
||||
style={fs(12, 'body')}
|
||||
>
|
||||
{t('collections.noCategory')}
|
||||
</button>
|
||||
{categories.map(cat => {
|
||||
const Icon = getCategoryIcon(cat.icon ?? undefined)
|
||||
const on = categoryId === cat.id
|
||||
const col = cat.color || '#6366f1' // theme-lint-disable: the category's own colour, and the default one without a colour is drawn in
|
||||
return (
|
||||
<button
|
||||
key={cat.id}
|
||||
type="button"
|
||||
onClick={() => setCategoryId(cat.id)}
|
||||
aria-pressed={on}
|
||||
className={`${CHIP} ${CHIP_OFF}`}
|
||||
style={{ ...fs(12, 'body'), ...(on ? { color: col, background: `color-mix(in oklch, ${col} 15%, transparent)`, borderColor: `color-mix(in oklch, ${col} 40%, transparent)` } : {}) }}
|
||||
>
|
||||
<Icon size={13} /> {cat.name}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</EditorField>
|
||||
)}
|
||||
|
||||
<DialogSection
|
||||
label={<label htmlFor={`${fieldId}-description`}>{t('collections.description')}</label>}
|
||||
action={<NoteFormatToolbar textareaRef={descRef} onChange={setDescription} compact customTooltips />}
|
||||
|
||||
Reference in New Issue
Block a user