mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
Add the track colour picker to the place inspector
New shared component rather than a ninth copy of the swatch grid that is already inline in eight places. Selection is drawn with var(--accent) so it follows whatever accent the user runs. The custom-colour cell listens for the native change event instead of React's onChange: for a colour input React maps onChange to input, which fires on every drag inside the OS picker — dozens of writes, each one a 409 candidate against the base-version header. The auto cell previews the colour you would get back, not the one currently set, which is a different value as soon as anything is picked. The row sits next to the track stats block, not inside it: that block returns null on unparsable geometry and the colour control has no business disappearing with it. The elevation chart and the distance pin follow the track colour too, otherwise the panel and the map read as two unrelated objects. In the places list the track icon becomes a stroke in the colour the line is drawn in. The map has no legend of its own, so that stroke is the only thing tying a line back to a row. Undo after deleting a track now restores its geometry and colour instead of bringing back a bare point.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import React from 'react'
|
||||
import { Plus, Check, Route, Star } from 'lucide-react'
|
||||
import { Plus, Check, Star } from 'lucide-react'
|
||||
import PlaceAvatar from '../shared/PlaceAvatar'
|
||||
import { getCategoryIcon } from '../shared/categoryIcons'
|
||||
import { resolveTrackColor } from '../Map/trackColors'
|
||||
import type { Place, Category } from '../../types'
|
||||
|
||||
interface MemoPlaceRowProps {
|
||||
@@ -81,7 +82,15 @@ export const MemoPlaceRow = React.memo(function MemoPlaceRow({
|
||||
<PlaceAvatar place={place} category={cat} size={34} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 5, overflow: 'hidden' }}>
|
||||
{hasGeometry && <span title="Track / Route" style={{ display: 'inline-flex', flexShrink: 0 }}><Route size={11} strokeWidth={2} color="var(--text-faint)" /></span>}
|
||||
{/* A stroke of the colour the track is drawn in — the map has no legend
|
||||
of its own, so this is what tells you which line is this row (#776).
|
||||
A line rather than another 11px icon, so it doesn't read as a second
|
||||
category glyph next to the one below. */}
|
||||
{hasGeometry && (
|
||||
<span title={t('places.trackIndicator')} style={{ display: 'inline-flex', flexShrink: 0 }}>
|
||||
<span style={{ display: 'block', width: 14, height: 3, borderRadius: 999, background: resolveTrackColor(place) }} />
|
||||
</span>
|
||||
)}
|
||||
{cat && (() => {
|
||||
const CatIcon = getCategoryIcon(cat.icon)
|
||||
return <span title={cat.name} style={{ display: 'inline-flex', flexShrink: 0 }}><CatIcon size={11} strokeWidth={2} color={cat.color || '#6366f1'} /></span>
|
||||
|
||||
Reference in New Issue
Block a user