diff --git a/public/css/style.css b/public/css/style.css index 6255ed4..18dbd02 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -975,9 +975,43 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr } .gpx-tree summary { + display: flex; + align-items: center; cursor: pointer; font-weight: 600; border-radius: 3px; + list-style: none; +} + +.gpx-tree summary::-webkit-details-marker { + display: none; +} + +/* The open/close arrow for folders and tracks with points: a real hit area + (the browser's own marker, or a 12px glyph, was a fingertip miss). */ +.gpx-tree summary::before { + content: "▸"; + flex: none; + display: flex; + align-items: center; + justify-content: center; + width: 24px; + height: 28px; + color: #888; + font-size: 13px; + transition: transform 0.15s; +} + +.gpx-tree details[open] > summary::before { + transform: rotate(90deg); +} + +@media (pointer: coarse) { + .gpx-tree summary::before { + width: 36px; + height: 40px; + font-size: 16px; + } } .gpx-tree__folder-row { @@ -985,7 +1019,8 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr align-items: center; justify-content: space-between; gap: 4px; - width: calc(100% - 18px); + flex: 1; + min-width: 0; } .gpx-tree__folder-row > :first-child { @@ -997,34 +1032,13 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr outline: 1px dashed #4a90d9; } -/* A track/route holding points: its row is the summary, a small - triangle (not the browser's marker, gone with display:flex) opens the - point list. */ +/* A track/route holding points: its row is the summary, the shared + .gpx-tree summary::before arrow opens the point list. */ .gpx-tree__track > summary { - display: flex; - align-items: center; font-weight: normal; - list-style: none; margin-left: -12px; } -.gpx-tree__track > summary::-webkit-details-marker { - display: none; -} - -.gpx-tree__track > summary::before { - content: "▸"; - width: 12px; - flex: none; - color: #888; - font-size: 10px; - transition: transform 0.15s; -} - -.gpx-tree__track[open] > summary::before { - transform: rotate(90deg); -} - .gpx-tree__track > summary > .gpx-tree__file { flex: 1; min-width: 0; @@ -1697,6 +1711,73 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr background: var(--accent-bg); } +/* Point color swatches (PointStyleFields, notes.js); the first is "default". */ +.notes-panel__colors { + display: flex; + flex-wrap: wrap; + gap: 4px; + margin: 4px 0; +} + +.notes-panel__color { + width: 24px; + height: 24px; + padding: 0; + border: 2px solid #fff; + border-radius: 50%; + background: var(--swatch, repeating-linear-gradient(45deg, #fff 0 3px, #ccc 3px 6px)); + box-shadow: 0 0 0 1px #bbb; + cursor: pointer; +} + +.notes-panel__color.active { + box-shadow: 0 0 0 2px var(--accent); +} + +/* B / I above a note's text (formatToolbar, notes.js). */ +.notes-panel__format { + display: flex; + gap: 4px; + margin: 4px 0 2px; +} + +.notes-panel__format button { + min-width: 32px; + height: 28px; + border: 1px solid #ccc; + border-radius: 4px; + background: #fff; + font: inherit; + cursor: pointer; +} + +.notes-panel__format button:hover { + background: #f0f0f0; +} + +/* Moving a note: the marker takes the accent color, the hint + Save/Cancel + ride in a popup above it. */ +.note-move-marker { + background: var(--accent); +} + +.gpx-popup__move-bar p { + margin: 0 0 6px; + font-size: 13px; +} + +@media (pointer: coarse) { + .notes-panel__color { + width: 32px; + height: 32px; + } + + .notes-panel__format button { + min-width: 44px; + height: 36px; + } +} + /* The pending-note marker shown on the map while the save form is open — updates live to whatever icon is picked (see notes.js's onIconChange). A plain round badge (not a drop-pin shape) since MapLibre anchors a custom @@ -2644,6 +2725,15 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr cursor: grab; } +/* An invisible 48px grab area around the 26px dot: a finger missed the dot + itself and panned the map instead (the marker is already absolutely + positioned by MapLibre, so this needs no position of its own). */ +.route-marker::after { + content: ""; + position: absolute; + inset: -11px; +} + .route-panel__remove:disabled { visibility: hidden; } diff --git a/public/js/gpx.js b/public/js/gpx.js index 36ea094..3d8924e 100644 --- a/public/js/gpx.js +++ b/public/js/gpx.js @@ -1,4 +1,5 @@ -import { Popup, LngLatBounds } from "/vendor/maplibre-gl/maplibre-gl.mjs"; +import { Popup, LngLatBounds, Marker } from "/vendor/maplibre-gl/maplibre-gl.mjs"; +import { PointStyleFields, formatToolbar } from "/js/notes.js"; import { GPX_ICON, NEW_FOLDER_ICON, @@ -874,7 +875,7 @@ export class GpxPanelControl { const editable = feature.properties.category === "Note" && !!feature.properties.id && isLoggedIn(); const popup = new Popup({ closeButton: true, maxWidth: "260px" }) .setLngLat(lngLat) - .setHTML(popupHtml(feature.properties, { editable })) + .setHTML(popupHtml(feature.properties, { editable, movable: feature.geometry.type === "Point" })) .addTo(this._map); if (editable) this._wireNoteActions(popup, path, feature); if (feature.geometry.type === "Point") { @@ -946,6 +947,7 @@ export class GpxPanelControl { content.innerHTML = `
Drag the point or tap its new spot
`; + const barPopup = new Popup({ closeButton: false, closeOnClick: false, offset: 22, maxWidth: "240px" }).setDOMContent(bar); + marker.setPopup(barPopup).togglePopup(); + const onMapClick = (event) => { + marker.setLngLat(event.lngLat); + if (!barPopup.isOpen()) marker.togglePopup(); + }; + this._map.on("click", onMapClick); + const end = () => { + this._map.off("click", onMapClick); + marker.remove(); + this._cancelMove = null; + }; + this._cancelMove = end; + bar.querySelector(".gpx-popup__edit-cancel").addEventListener("click", end); + bar.querySelector(".gpx-popup__edit-save").addEventListener("click", async () => { + const { lng, lat } = marker.getLngLat(); + if (await this._saveNote(path, { ...feature, geometry: { ...feature.geometry, coordinates: [lng, lat] } })) end(); + }); + } + + // PUTs the edited note and reloads its file's layers; false on failure. + async _saveNote(path, updated) { + try { + const body = new URLSearchParams({ path, id: updated.properties.id, feature: JSON.stringify(updated) }); + const response = await fetch("/api/library/notes", { method: "PUT", body }); + if (!response.ok) throw new Error(`save failed: ${response.status}`); + notifyGpxStoreChanged(); + await this._reloadFile(path); + return true; + } catch (err) { + window.alert("Could not save the note — check your connection and try again."); + return false; + } } async _reloadFile(path) { @@ -1459,7 +1505,7 @@ function nodeKeys(node) { // for — see _registerPointInteractivity) adds Edit/Delete buttons; the // click handling for them lives in _wireNoteActions, not here, since this // only builds markup, it has no map/store access of its own. -function popupHtml({ name, description, time, category, photos, icon }, { editable = false } = {}) { +function popupHtml({ name, description, time, category, photos, icon }, { editable = false, movable = false } = {}) { const parts = []; if (name) { const glyph = icon && POI_ICONS[icon] ? `` : ""; @@ -1482,7 +1528,7 @@ function popupHtml({ name, description, time, category, photos, icon }, { editab } if (editable) { parts.push( - ``, + `