mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
feat(places): notes, visits, tours, history, tags and location in the place sheet, saved lists on the trip map
Both the desktop sheet and the phone sheet of All places show the place's location as a badge, its notes per list, its visits from trips (hidden without any), linked tours and bookings, its change history and the reader's own tags with a tag filter. A trip map can show the places of linked lists and add one to the trip. All places reloads after a list is added or removed.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Utensils, Coffee, Wine, BedDouble, Camera, Landmark, Trees, Ticket, Fuel, Zap, ParkingSquare, Tent, Binoculars, Mountain, Warehouse, Droplet, Toilet, Sandwich, Anchor, Sailboat, Wrench, Store, BatteryCharging, Croissant, ShoppingBasket, type LucideIcon } from 'lucide-react'
|
||||
import { listIcon } from '../Collections/listIcons'
|
||||
import type { TourPoiCategory } from '@trek/shared'
|
||||
import { parsePluginPoiCategoryKey, type PluginPoiDetail } from '@trek/shared'
|
||||
// The road-trip kinds take their colour from the one place that defines it, so the
|
||||
@@ -127,6 +128,14 @@ export interface Poi {
|
||||
color?: string
|
||||
}
|
||||
|
||||
/** The category of a saved place a linked list lays over the trip map (PLC-16). */
|
||||
export const SAVED_PLACE_POI_CATEGORY = 'saved-place'
|
||||
|
||||
/** A list's colour when it is a `#rrggbb` value, the theme's accent otherwise. */
|
||||
function savedPlaceColor(color: string | undefined): string {
|
||||
return color && /^#[0-9a-fA-F]{6}$/.test(color) ? color : 'var(--accent)'
|
||||
}
|
||||
|
||||
/** What a POI pin and its hover card are drawn with. */
|
||||
export interface PoiAppearance {
|
||||
color: string
|
||||
@@ -143,6 +152,8 @@ export interface PoiAppearance {
|
||||
* category and is drawn like one.
|
||||
*/
|
||||
export function poiAppearance(poi: Pick<Poi, 'category' | 'icon' | 'color'>): PoiAppearance {
|
||||
// A saved place of a list linked to the trip (PLC-16): the list's own symbol in its colour.
|
||||
if (poi.category === SAVED_PLACE_POI_CATEGORY) return { color: savedPlaceColor(poi.color), Icon: listIcon(poi.icon) }
|
||||
const core = CATEGORY_BY_KEY.get(poi.category)
|
||||
if (core) return { color: core.color, Icon: core.Icon }
|
||||
if (parsePluginPoiCategoryKey(poi.category)) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createElement } from 'react'
|
||||
import { PLUGIN_POI_DETAILS_MAX, isPluginPoiIcon, parsePluginPoiCategoryKey, type PluginPoiDetail } from '@trek/shared'
|
||||
import { renderIconMarkup } from '../../utils/iconMarkup'
|
||||
import { poiAppearance, type Poi } from './poiCategories'
|
||||
import { poiAppearance, SAVED_PLACE_POI_CATEGORY, type Poi } from './poiCategories'
|
||||
import { pluginPoiColor } from './pluginPoiIcons'
|
||||
|
||||
/**
|
||||
@@ -32,6 +32,8 @@ export function poiPinParts(poi: PoiLook): { color: string; svg: string } {
|
||||
* icon: a pin cached before the update is never handed out after it.
|
||||
*/
|
||||
export function poiPinCacheKey(poi: PoiLook): string {
|
||||
// A saved place is drawn in its list's colour and symbol, so lists apart are pins apart.
|
||||
if (poi.category === SAVED_PLACE_POI_CATEGORY) return `${poi.category}|${poi.color ?? ''}|${poi.icon ?? ''}`
|
||||
if (!parsePluginPoiCategoryKey(poi.category)) return poi.category
|
||||
const icon = isPluginPoiIcon(poi.icon) ? poi.icon : ''
|
||||
return `${poi.category}|${pluginPoiColor(poi.color)}|${icon}`
|
||||
|
||||
Reference in New Issue
Block a user