From d559f76b4a8eedaac9eeaa3d931827ddd0104a48 Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Thu, 3 Dec 2026 09:20:27 +0100 Subject: [PATCH] =?UTF-8?q?Desktop=20after=20the=20artboard,=20the=20panel?= =?UTF-8?q?s=20too:=20the=20rail=20dark=20like=20the=20topbar=20(the=20ope?= =?UTF-8?q?n=20panel's=20item=20on=20a=20lighter=20band=20with=20an=20acce?= =?UTF-8?q?nt=20edge),=20side=20panels=20400=20px,=20the=20map's=20buttons?= =?UTF-8?q?=20as=20white=20cards=20of=2040=20px;=20Route=20laid=20out=20as?= =?UTF-8?q?=20drawn=20=E2=80=94=20Reverse/Clear=20in=20the=20head,=20each?= =?UTF-8?q?=20point=20with=20a=20grip=20to=20drag=20it=20elsewhere,=20its?= =?UTF-8?q?=20letter=20(the=20same=20on=20the=20marker),=20name=20and=20ro?= =?UTF-8?q?le,=20the=20leg=20to=20it=20as=20a=20dashed=20line=20between,?= =?UTF-8?q?=20+=20Search=20/=20Saved=20point=20/=20My=20position=20chips,?= =?UTF-8?q?=20the=20totals=20as=20a=20card=20(distance,=20time,=20climb,?= =?UTF-8?q?=20arrival;=20descent=20and=20steepest=20grade=20under=20it),?= =?UTF-8?q?=20vehicle=20and=20avoid=20as=20chips,=20Directions=20and=20Rea?= =?UTF-8?q?ch=20folded=20with=20their=20counts,=20Save=20to=20library=20an?= =?UTF-8?q?d=20Elevation=20profile=20at=20the=20bottom;=20On=20the=20map:?= =?UTF-8?q?=20the=20Online/Offline=20choice=20and=20the=20legend=20are=20t?= =?UTF-8?q?he=20first=20group=20of=20the=20Overlays=20panel,=20renamed=20O?= =?UTF-8?q?n=20the=20map=20=E2=80=94=20no=20Base=20map=20item=20or=20panel?= =?UTF-8?q?=20of=20its=20own.=20TODO:=20copy=20the=20cursor's=20position,?= =?UTF-8?q?=20the=20scale=20back=20over=20the=20map?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.adoc | 4 + public/css/style.css | 432 ++++++++++++++++++++++++++++++++++++++---- public/js/map.js | 54 ++---- public/js/overlays.js | 2 +- public/js/route.js | 89 +++++++-- views/index.erb | 97 +++++----- 6 files changed, 536 insertions(+), 142 deletions(-) diff --git a/TODO.adoc b/TODO.adoc index 671babc..4408498 100644 --- a/TODO.adoc +++ b/TODO.adoc @@ -140,6 +140,10 @@ plan from — the server does the heavy lifting. The UI is built for a mouse tod text fields. Who: the navigator (co-driver) runs the whole UI and the trip's points on the 16" display; the driver only looks at a finished map on Android Auto, touching the 16" only now and then — so it's simple for a moving car, not driver-distraction rules +* [ ] Desktop (the Design canvas' Desktop, 2026-12-03): copy the position under the cursor + to the clipboard (a key or the right-click menu) — today only the map's center copies, + from the status bar, so the way around it is to put the center on the point first +* [ ] Desktop: the scale back over the map, not in the status bar * [x] Night mode — topbar button cycles auto (sun below the horizon at the map center) / on / off. The map has its own night palette (`NightMap` in `public/js/map_themes.js`, switched live with setPaintProperty): dark blue-gray ground, roads a step lighter, muted ochre motorways, light-gray labels on dark halos; raster overlays dimmed, our own track/point colors kept ** [x] The rest of the UI is still one invert+dim filter — CSS color tokens and a real dark set instead * [x] Tracker as a top-down vehicle (car / motorbike / bicycle from its icon) rotated by the GNSS course, kept while standing still; "Navigate" (tracker card or Overlays status) follows it heading-up, tilted 60°, vehicle in the lower third — panning by hand ends it diff --git a/public/css/style.css b/public/css/style.css index 5f90600..71c3658 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -8,6 +8,7 @@ :root { --rail: 72px; /* the labelled side rail */ --statusbar: 24px; + --panel: 400px; /* a side panel's width */ /* planning UI (NPS) */ --ui-bg: #ffffff; --ui-bg-2: #f0f0f0; /* hover, subtle fills */ @@ -651,7 +652,7 @@ html, body { position: fixed; top: 44px; /* below the topbar, its title in view */ left: var(--rail); - width: 300px; + width: var(--panel); max-width: 90vw; bottom: var(--statusbar); display: flex; @@ -669,11 +670,11 @@ html, body { /* Pinned side panel: the map (and the profile panel under it) moves over instead of being covered. Switching panels swaps the one in that spot. */ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) #map { - margin-left: min(300px, 90vw); + margin-left: min(var(--panel), 90vw); } body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .profile-panel { - left: calc(var(--rail) + min(300px, 90vw)); + left: calc(var(--rail) + min(var(--panel), 90vw)); } /* Phone portrait: a pinned 300px panel left the map a sliver, so there it @@ -1078,7 +1079,7 @@ button.basemap-panel__link[hidden] { display: none; } position: fixed; top: 44px; /* below the topbar, its title in view */ left: var(--rail); - width: 300px; + width: var(--panel); max-width: 90vw; bottom: var(--statusbar); display: flex; @@ -1664,7 +1665,8 @@ button.basemap-panel__link[hidden] { display: none; } } .search-ctrl__key { - font: 12px inherit; + font-family: inherit; + font-size: 12px; padding: 0 6px; border: 1px solid rgb(255 255 255 / 0.25); border-radius: 4px; @@ -1703,7 +1705,8 @@ button.basemap-panel__link[hidden] { display: none; } border: none; background: none; color: #fff; - font: 14px inherit; + font-family: inherit; + font-size: 14px; outline: none; } @@ -2837,33 +2840,9 @@ button.basemap-panel__link[hidden] { display: none; } opacity: 1; } -.route-panel__buttons { - display: flex; - gap: 6px; - margin-bottom: 8px; -} -.route-panel__buttons button { - border: 1px solid var(--ui-line); - border-radius: 4px; - background: var(--ui-bg); - padding: 4px 8px; - font: inherit; - font-size: 12px; - cursor: pointer; -} -.route-panel__buttons button { - display: inline-flex; - align-items: center; - gap: 4px; -} -.route-panel__buttons svg { - width: 16px; - height: 16px; - flex: none; -} .route-panel__saved { margin-bottom: 8px; @@ -2899,9 +2878,6 @@ button.basemap-panel__link[hidden] { display: none; } background: #eef3fb; } -.route-panel__buttons button[hidden] { - display: none; -} .route-panel__directions, .route-panel__fold { @@ -3799,3 +3775,393 @@ html.follow-3d .maplibregl-ctrl-overview-map { display: none; } display: none; } } + +/* ---- The Design canvas' Desktop artboard ------------------------------ */ + +/* The rail: dark like the topbar, the open panel's item marked by a light + band and an accent edge. */ +.sidebar { + background: var(--band); + border-right: none; + gap: 2px; + padding: 6px 0; +} + +.sidebar-item { + align-self: stretch; +} + +.sidebar .sidebar-icon { + width: 100%; + height: 58px; + border-radius: 0; + border-left: 3px solid transparent; + color: #bdbab0; +} + +.sidebar .sidebar-icon:hover { + background: #2c2c28; + color: #fff; +} + +.sidebar .sidebar-icon.active { + background: #2c2c28; + color: #fff; + border-left-color: var(--accent); +} + +.sidebar-group-label { + margin: 4px 12px; + background: #3a3a35; +} + +/* The map's buttons: white cards of 40 px buttons, a group per card. */ +.maplibregl-ctrl-top-right { + top: 12px; + right: 12px; + display: flex; + flex-direction: column; + align-items: flex-end; + gap: 10px; +} + +.maplibregl-ctrl-top-right .maplibregl-ctrl { + margin: 0; +} + +.maplibregl-ctrl-top-right .maplibregl-ctrl-group { + border-radius: 8px; + box-shadow: 0 1px 6px rgb(0 0 0 / 0.25); + overflow: hidden; +} + +.maplibregl-ctrl-top-right .maplibregl-ctrl-group button { + width: 40px; + height: 40px; +} + +.maplibregl-ctrl-top-right .maplibregl-ctrl-group button svg { + width: 20px; + height: 20px; +} + +/* Panel heads as on the artboard: a bigger title. */ +:is(.gpx-panel__header, .basemap-panel__header) > strong { + font-size: 17px; +} + +/* Route (route.js) */ +.route-panel { + font-size: 14px; +} + +.route-panel__body { + flex: 1; + min-height: 0; + padding: 8px 16px; +} + +.route-panel__head-actions { + display: flex; + gap: 6px; + margin-left: auto; +} + +.route-panel .route-panel__head-actions button { + min-height: 30px; + height: 30px; + display: flex; + align-items: center; + gap: 4px; + padding: 0 10px; + border: 1px solid var(--ui-line); + border-radius: 6px; + background: none; + color: var(--ui-fg); + font-family: inherit; + font-size: 13px; + cursor: pointer; +} + +.route-panel__head-actions svg { + width: 14px; + height: 14px; +} + +.route-panel__points { + margin: 0; +} + +.route-panel .route-panel__stop { + display: flex; + align-items: center; + gap: 10px; + min-height: 44px; + padding: 0; +} + +.route-panel__dragging { + opacity: 0.4; +} + +.route-panel__grip { + color: var(--ui-muted); + cursor: grab; + letter-spacing: -2px; +} + +.route-panel__badge { + width: 24px; + height: 24px; + flex: none; + border-radius: 50%; + background: var(--accent); + color: #fff; + font-size: 12px; + font-weight: 700; + display: flex; + align-items: center; + justify-content: center; +} + +.route-panel__badge--end { + background: #a21caf; +} + +.route-panel__point { + min-width: 0; + display: flex; + flex-direction: column; +} + +.route-panel__name { + font-size: 15px; + font-weight: 600; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.route-panel__role { + font-size: 12px; + color: var(--ui-muted); +} + +.route-panel .route-panel__leg { + display: block; + margin-left: 46px; + padding: 2px 0 2px 12px; + border-left: 2px dashed var(--ui-line); + color: var(--ui-muted); + font-size: 12px; +} + +.route-panel__add { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 6px; + padding: 8px 0 12px 36px; +} + +.route-panel .route-panel__chip { + min-height: 32px; + height: 32px; + display: inline-flex; + align-items: center; + gap: 6px; + padding: 0 12px; + border: 1px solid var(--ui-line); + border-radius: 16px; + background: none; + color: var(--ui-fg); + font-family: inherit; + font-size: 13px; + cursor: pointer; +} + +.route-panel .route-panel__chip--add { + border: 1px dashed var(--accent); + color: var(--accent); + font-weight: 600; +} + +.route-panel .route-panel__hint { + margin: 0; + font-size: 12px; +} + +/* a ticked avoid chip, the vehicle in use */ +.route-panel .route-panel__chip:has(input:checked), +.route-panel select.route-panel__chip { + border-color: var(--accent); + background: var(--accent-bg); + font-weight: 600; +} + +.route-panel__chip input { + display: none; +} + +.route-panel__totals { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 4px; + margin-bottom: 4px; + padding: 12px; + border-radius: 10px; + background: var(--ui-bg-2); + text-align: center; +} + +.route-panel__totals[hidden] { + display: none; +} + +.route-panel__totals > span { + display: flex; + flex-direction: column; +} + +.route-panel__totals b { + font-size: 18px; + font-variant-numeric: tabular-nums; +} + +.route-panel__totals small { + font-size: 11px; + color: var(--ui-muted); + text-transform: uppercase; + letter-spacing: 0.05em; +} + +.route-panel .route-panel__totals-more { + grid-column: 1 / 5; + margin-top: 4px; + font-size: 12px; + color: var(--ui-muted); +} + +.route-panel__summary:empty { + display: none; +} + +.route-panel .route-panel__summary { + padding: 0; + background: none; + font-weight: 400; + color: var(--ui-muted); +} + +.route-panel__row { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 6px; + margin: 10px 0 0; +} + +.route-panel__label { + width: 56px; + font-size: 12px; + color: var(--ui-muted); +} + +.route-panel .route-panel__fold { + margin: 12px -16px 0; + border-top: 1px solid var(--ui-line); +} + +.route-panel .route-panel__fold + .route-panel__fold { + margin-top: 0; +} + +.route-panel .route-panel__fold > summary { + display: flex; + align-items: center; + padding: 0 16px; + font-weight: 600; + list-style: none; +} + +.route-panel__fold > summary::-webkit-details-marker { + display: none; +} + +.route-panel__fold-meta { + margin-left: auto; + font-size: 12px; + font-weight: 400; + color: var(--ui-muted); +} + +.route-panel__fold-meta::after { + content: " ›"; +} + +.route-panel__fold[open] .route-panel__fold-meta::after { + content: " ⌄"; +} + +.route-panel__fold > :not(summary) { + margin: 0 16px 12px; +} + +.route-panel__footer { + display: flex; + gap: 8px; + padding: 12px 16px; + border-top: 1px solid var(--ui-line); +} + +.route-panel__footer:not(:has(button:not([hidden]))) { + display: none; +} + +.route-panel .route-panel__footer button { + flex: 1; + height: 40px; + border-radius: 8px; + font-family: inherit; + font-size: 14px; + font-weight: 600; + cursor: pointer; +} + +.route-panel .route-panel__primary { + border: none; + background: var(--accent); + color: #fff; +} + +.route-panel .route-panel__secondary { + border: 1px solid var(--ui-line); + background: none; + color: var(--ui-fg); +} + +.route-panel__footer button[hidden] { + display: none; +} + +/* a route's markers in the panel's colours */ +.route-marker { + background: var(--accent); +} + +/* "On the map" on two lines in the rail */ +.sidebar-icon::after { + max-width: 100%; + white-space: normal; + text-align: center; +} + +/* On the map's Map group sits above the overlays' own scrolling list */ +.onthemap-map { + flex: none; +} + +.onthemap-map .overlays-panel__group { + margin: 0; + border-top: none; +} diff --git a/public/js/map.js b/public/js/map.js index f4d9360..c04dcda 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -17,10 +17,10 @@ import { LocateControl } from "/js/locate.js"; import { SearchControl } from "/js/search.js"; import { OfflineDataControl } from "/js/offline_data.js"; import { RoutePanelControl } from "/js/route.js"; -import { LAYERS_ICON, WAYPOINT_ICON, SUNRISE_ICON, SUNSET_ICON, PENDING_ICON, LOCK_ICON, UNLOCK_ICON } from "/js/icons.js"; +import { WAYPOINT_ICON, SUNRISE_ICON, SUNSET_ICON, PENDING_ICON, LOCK_ICON, UNLOCK_ICON } from "/js/icons.js"; import { formatCoords, formatSunInfo, sunChartHtml } from "/js/sun.js"; import { getPosition } from "/vendor/suncalc/suncalc.js"; -import { notifySidePanelOpen, onlyOneSidePanelOpen, setupSidePanelModes } from "/js/panels.js"; +import { setupSidePanelModes } from "/js/panels.js"; import { isLoggedIn } from "/js/auth.js"; import { DebugControl } from "/js/debug.js"; import { setupUpdate } from "/js/update.js"; @@ -104,45 +104,20 @@ function offlineStyle() { return style; } -// A sidebar icon that opens a full-height side panel (like the GPX one) -// with the Online/Offline choice — modelled after OsmAnd's "Configure map" -// panel, rather than a small dropdown flyout. +// The Online/Offline choice: the first group of the On the map panel +// (the Overlays one, overlays.js), no rail item or panel of its own. class LayerToggleControl { constructor(onSelect) { this._onSelect = onSelect; + this._panel = document.querySelector(".onthemap-map"); } - mount(sidebar) { - this._container = document.createElement("div"); - this._container.className = "sidebar-item"; - this._container.innerHTML = ``; - this._icon = this._container.querySelector(".sidebar-icon"); - this._icon.addEventListener("click", () => this._togglePanel()); - - this._panel = document.getElementById("basemap-panel"); - this._panel - .querySelector(".basemap-panel__close") - .addEventListener("click", () => this._togglePanel(false)); + mount() { this._panel.querySelectorAll(".basemap-panel__option").forEach((button) => { - button.addEventListener("click", () => { - this._onSelect(button.dataset.style); - this._togglePanel(false); - }); + button.addEventListener("click", () => this._onSelect(button.dataset.style)); }); - - onlyOneSidePanelOpen(this._panel, () => this._icon.classList.remove("active")); - - sidebar.appendChild(this._container); } - _togglePanel(force) { - const open = force === undefined ? this._panel.hidden : force; - this._panel.hidden = !open; - this._icon.classList.toggle("active", open); - if (open) notifySidePanelOpen(this._panel); - } - - setActive(name) { this._panel.querySelectorAll(".basemap-panel__option").forEach((button) => { button.classList.toggle("active", button.dataset.style === name); @@ -151,8 +126,8 @@ class LayerToggleControl { // Called once it's known there's no offline map to switch to (see the // /api/offline-tiles check below) — an Online/Offline switch doesn't make - // sense to show at all when Offline was never going to work. The panel - // itself stays for its legend link. + // sense to show at all when Offline was never going to work. The legend + // link stays. hideSources() { this._panel.querySelector(".basemap-panel__sources").hidden = true; } @@ -471,15 +446,14 @@ setInterval(updateNight, 60000); const sidebar = document.getElementById("sidebar"); -// The rail of the Design canvas' Desktop, labelled: what's on the map (the -// map, overlays), the library and imports; the route; offline data; live -// (GNSS, LiveTrack); Status pinned at the bottom. Folding Map, Overlays and -// Live into one "On the map" panel is the canvas' next step, not done yet. +// The rail of the Design canvas' Desktop, labelled: On the map (the map, +// overlays), the library and imports; the route; offline data; live +// (GNSS, LiveTrack); Status pinned at the bottom. const layerToggle = new LayerToggleControl(applyStyle); const profilePanel = new TrackProfilePanel(map); profilePanel.mount(); -layerToggle.mount(sidebar); +layerToggle.mount(); layerToggle.setActive("online"); const overlaysControl = new OverlaysControl(map); overlaysControl.mount(sidebar); @@ -508,7 +482,7 @@ new LiveTrackPanelControl(map).mount(sidebar); if (isLoggedIn()) new DebugControl().mount(sidebar); if (isLoggedIn()) setupUpdate(document.querySelector(".topbar__update"), document.querySelector(".debug-panel__update-check")); // A short name under each icon (CSS ::after), the title stays the tooltip. -const RAIL_LABELS = { "Base map": "Map", "Tracks & Points": "Library", "Import plugins": "Import", "Offline data": "Offline", LiveTrack: "Live", "Status / debug": "Status" }; +const RAIL_LABELS = { "Tracks & Points": "Library", "Import plugins": "Import", "Offline data": "Offline", LiveTrack: "Live", "Status / debug": "Status" }; sidebar.querySelectorAll(".sidebar-icon").forEach((icon) => (icon.dataset.label = RAIL_LABELS[icon.title] ?? icon.title)); setupSidePanelModes(); diff --git a/public/js/overlays.js b/public/js/overlays.js index 72c6dc8..1d70a35 100644 --- a/public/js/overlays.js +++ b/public/js/overlays.js @@ -224,7 +224,7 @@ export class OverlaysControl { mount(sidebar) { this._container = document.createElement("div"); this._container.className = "sidebar-item"; - this._container.innerHTML = ``; + this._container.innerHTML = ``; this._icon = this._container.querySelector(".sidebar-icon"); this._icon.addEventListener("click", () => this._togglePanel()); diff --git a/public/js/route.js b/public/js/route.js index ed0e744..fd38fbc 100644 --- a/public/js/route.js +++ b/public/js/route.js @@ -1,5 +1,5 @@ import { Marker } from "/vendor/maplibre-gl/maplibre-gl.mjs"; -import { ROUTE_ICON, POSITION_ICON, SAVED_POINT_ICON, REVERSE_ICON, CLEAR_ICON, SAVE_ICON } from "/js/icons.js"; +import { ROUTE_ICON, REVERSE_ICON, CLEAR_ICON } from "/js/icons.js"; import { notifySidePanelOpen, onlyOneSidePanelOpen, notifyGpxStoreChanged, onRoutePoint, onRouteEdit, notifyRouteChanged, onReroute, onRouteProgress } from "/js/panels.js"; import { isLoggedIn } from "/js/auth.js"; import { wirePreview } from "/js/preview.js"; @@ -103,7 +103,9 @@ export class RoutePanelControl { }); this._panel.querySelector('[data-action="clear"]').addEventListener("click", () => this._clear()); this._panel.querySelector('[data-action="position"]').addEventListener("click", () => this._addPosition()); - const icons = { position: POSITION_ICON, "saved-point": SAVED_POINT_ICON, reverse: REVERSE_ICON, clear: CLEAR_ICON, save: SAVE_ICON }; + this._panel.querySelector('[data-action="search"]').addEventListener("click", () => document.querySelector(".search-panel__input")?.focus()); + this._totals = this._panel.querySelector(".route-panel__totals"); + const icons = { reverse: REVERSE_ICON, clear: CLEAR_ICON }; for (const [action, icon] of Object.entries(icons)) this._panel.querySelector(`[data-action="${action}"]`).insertAdjacentHTML("afterbegin", icon); this._setupSavedPoints(); this._editingNote = this._panel.querySelector(".route-panel__editing"); @@ -357,25 +359,52 @@ export class RoutePanelControl { this._fetchRoute(); } + // The Desktop artboard's list: a grip to drag the point to another place, + // its letter (the same on its marker), name and role, then the leg to the + // next one as a dashed line between them. _renderPoints() { this._list.innerHTML = ""; + const last = this._points.length - 1; this._points.forEach((point, index) => { - const label = index === 0 ? "Start" : index === this._points.length - 1 ? "End" : `Via ${index}`; - point.marker.getElement().textContent = index === 0 ? "S" : index === this._points.length - 1 ? "E" : String(index); + const letter = String.fromCharCode(65 + (index % 26)); + const role = index === 0 ? "Start" : index === last ? "End" : `Via ${index}`; + point.marker.getElement().textContent = letter; + const leg = this._leg(index); + if (leg) { + this._list.appendChild(Object.assign(document.createElement("li"), { + className: "route-panel__leg", + textContent: `${leg.km.toFixed(1)} km${leg.s != null ? ` · ${formatDuration(leg.s)}` : ""}`, + })); + } const li = document.createElement("li"); + li.className = "route-panel__stop"; li.classList.toggle("route-panel__passed", !!point.passed || this._behind(index)); + const grip = Object.assign(document.createElement("span"), { className: "route-panel__grip", textContent: "⋮⋮", title: "Drag to reorder" }); + li.draggable = true; + li.addEventListener("dragstart", (event) => { + this._dragging = point; + event.dataTransfer.effectAllowed = "move"; + li.classList.add("route-panel__dragging"); + }); + li.addEventListener("dragend", () => li.classList.remove("route-panel__dragging")); + li.addEventListener("dragover", (event) => event.preventDefault()); + li.addEventListener("drop", (event) => { + event.preventDefault(); + const from = this._points.indexOf(this._dragging); + this._dragging = null; + if (from < 0 || from === index) return; + this._points.splice(index, 0, ...this._points.splice(from, 1)); + this._changed(); + }); + const badge = Object.assign(document.createElement("span"), { className: "route-panel__badge", textContent: letter }); + badge.classList.toggle("route-panel__badge--end", index === last && last > 0); const text = document.createElement("span"); text.className = "route-panel__point"; - text.textContent = `${label} · ${point.name || `${point.lngLat[1].toFixed(5)}, ${point.lngLat[0].toFixed(5)}`}`; - const leg = this._leg(index); - if (leg) text.append(Object.assign(document.createElement("small"), { className: "route-panel__leg", textContent: `+${leg.km.toFixed(1)} km${leg.s != null ? ` · ${formatDuration(leg.s)}` : ""}` })); - li.append( - text, - this._navButton(point, label), - this._pointButton("↑", "Move up", index > 0, () => this._move(point, -1)), - this._pointButton("↓", "Move down", index < this._points.length - 1, () => this._move(point, 1)), - this._pointButton("×", "Remove", true, () => this._removePoint(point)), + text.append( + Object.assign(document.createElement("span"), { className: "route-panel__name", textContent: point.name || `${point.lngLat[1].toFixed(5)}, ${point.lngLat[0].toFixed(5)}` }), + Object.assign(document.createElement("small"), { className: "route-panel__role", textContent: role }), ); + li.append(grip, badge, text, this._navButton(point, role), this._pointButton("×", "Remove", true, () => this._removePoint(point))); // Hover/hold previews the point; a click on its name commits. wirePreview(this._map, text, () => ({ lngLat: point.lngLat })); text.addEventListener("click", () => this._map.easeTo({ center: point.lngLat, zoom: Math.max(this._map.getZoom(), 14) })); @@ -387,6 +416,25 @@ export class RoutePanelControl { this._saveButton.textContent = this._editing ? "Save changes" : "Save to library"; } + // The totals card: distance, time, climb (once the terrain's sampled), + // arrival if leaving now. + _renderTotals(route) { + this._totals.hidden = !route; + if (!route) return; + const { distance_km: km, time_s: seconds } = route.properties; + const arrive = new Date(Date.now() + seconds * 1000).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); + const cells = [ + [`${km.toFixed(km < 10 ? 1 : 0)} km`, "distance"], + [formatDuration(seconds), "time"], + [route.elevation ? `${Math.round(route.elevation.gain)} m` : "…", "climb"], + [arrive, "arrive"], + ]; + this._totals.innerHTML = cells.map(([value, key]) => `${value}${key}`).join(""); + if (route.elevation) { + this._totals.insertAdjacentHTML("beforeend", `↓ ${Math.round(route.elevation.loss)} m · steepest ${route.elevation.maxGrade.toFixed(0)} %`); + } + } + // Toggles whether the point is saved into the route as a navigation // point (a course point on a Garmin); an unnamed one asks for a name. _navButton(point, label) { @@ -457,13 +505,12 @@ export class RoutePanelControl { this._directions.hidden = !route; this._profileButton.hidden = true; this._showCountries(route?.properties.countries); - if (!route) { - this._summary.textContent = message; - return; - } + this._renderTotals(route); + this._summary.textContent = message; + if (!route) return; - const { distance_km: km, time_s: seconds, maneuvers } = route.properties; - this._summary.textContent = `${km.toFixed(1)} km · ${formatDuration(seconds)}`; + const { maneuvers } = route.properties; + this._directions.querySelector(".route-panel__fold-meta").textContent = `${maneuvers.length} steps`; const list = this._directions.querySelector("ol"); list.innerHTML = ""; maneuvers.forEach(({ text, km: length }) => { @@ -481,7 +528,7 @@ export class RoutePanelControl { if (this._route !== route || !profile) return; route.elevation = profile; - this._summary.textContent += ` · ↑ ${Math.round(profile.gain)} m ↓ ${Math.round(profile.loss)} m · max ${profile.maxGrade.toFixed(0)} %`; + this._renderTotals(route); this._profileButton.hidden = false; } @@ -638,7 +685,7 @@ export class RoutePanelControl { notifyGpxStoreChanged(path); this._editing = { key: path, id: editing?.id ?? (await this._savedId(path)), name: name.trim() }; this._renderPoints(); - this._summary.textContent += " · saved"; + this._summary.textContent = "Saved to the library"; } // The route's points marked 📍 as points inside the route item (marked diff --git a/views/index.erb b/views/index.erb index 3ffe6d6..acb83aa 100644 --- a/views/index.erb +++ b/views/index.erb @@ -47,26 +47,6 @@
- -
>
Tracks & Points @@ -86,9 +66,27 @@ - +
-
    - -
    - - +
    + + + + or click the map
    -

    Add a point: below, "+" on a search result or a library point, or click the map; drag a marker to move it.

    +

    - -
    - - +
    + Vehicle + +
    -
    - Avoid - - +
    + Avoid + +
    -