Desktop after the artboard, the panels too: the rail dark like the topbar (the open panel's item on a lighter band with an accent edge), side panels 400 px, the map's buttons as white cards of 40 px; Route laid out as drawn — Reverse/Clear in the head, each point with a grip to drag it elsewhere, its letter (the same on the marker), name and role, the leg to it as a dashed line between, + Search / Saved point / My position chips, the totals as a card (distance, time, climb, arrival; descent and steepest grade under it), vehicle and avoid as chips, Directions and Reach folded with their counts, Save to library and Elevation profile at the bottom; On the map: the Online/Offline choice and the legend are the first group of the Overlays panel, renamed On the map — no Base map item or panel of its own. TODO: copy the cursor's position, the scale back over the map
This commit is contained in:
1 parent
258d35a7a1
commit
d559f76b4a
6 files changed
+536
-142
No files matched your search
+399
-33
@@ -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;
|
||||
}
|
||||
+14
-40
@@ -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 = `<button type="button" class="sidebar-icon" title="Base map" aria-label="Base map">${LAYERS_ICON}</button>`;
|
||||
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();
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ export class OverlaysControl {
|
||||
mount(sidebar) {
|
||||
this._container = document.createElement("div");
|
||||
this._container.className = "sidebar-item";
|
||||
this._container.innerHTML = `<button type="button" class="sidebar-icon" title="Overlays" aria-label="Overlays">${OVERLAYS_ICON}</button>`;
|
||||
this._container.innerHTML = `<button type="button" class="sidebar-icon" title="On the map" aria-label="On the map">${OVERLAYS_ICON}</button>`;
|
||||
this._icon = this._container.querySelector(".sidebar-icon");
|
||||
this._icon.addEventListener("click", () => this._togglePanel());
|
||||
|
||||
|
||||
+68
-21
@@ -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]) => `<span><b>${value}</b><small>${key}</small></span>`).join("");
|
||||
if (route.elevation) {
|
||||
this._totals.insertAdjacentHTML("beforeend", `<span class="route-panel__totals-more">↓ ${Math.round(route.elevation.loss)} m · steepest ${route.elevation.maxGrade.toFixed(0)} %</span>`);
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in new issue
Block a user