Desktop redesign after the Design canvas' Desktop artboard: search is one field in the topbar (places, the library, coordinates; / focuses it, sources and results drop down under it), the side rail is labelled (Map, Overlays, Library, Import | Route, Offline | GNSS, Live, Status at the bottom), the map's buttons in one column on the right (zoom and compass, north lock, 3D, my position, measure, note, home; measure/note panels open to the left), a status bar under the map (center coordinates to copy, the point under the mouse, zoom, scale, revision) instead of the zoom-level control, the scale on the map and the coordinates in the topbar; the base map button on the map dropped (the rail has it). Route panel reordered: points with their legs, adding one, the totals as a card, vehicle and avoid, directions and reach folded, reverse/clear/save last. Drive unchanged: the search, the status bar and the right column hide there
CI / check (push) Successful in 23s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-03 01:28:49 +01:00
1 parent 60d7c825fc
commit 0a5548cd8f
4 files changed
+251 -213

No files matched your search

+148 -54
View File
@@ -6,6 +6,8 @@
blue: nothing brighter than the map). <html data-palette="dusk|night"> blue: nothing brighter than the map). <html data-palette="dusk|night">
switches; Day is the default. Meanings never change between them. */ switches; Day is the default. Meanings never change between them. */
:root { :root {
--rail: 72px; /* the labelled side rail */
--statusbar: 24px;
/* planning UI (NPS) */ /* planning UI (NPS) */
--ui-bg: #ffffff; --ui-bg: #ffffff;
--ui-bg-2: #f0f0f0; /* hover, subtle fills */ --ui-bg-2: #f0f0f0; /* hover, subtle fills */
@@ -161,7 +163,7 @@ html, body {
gap: 14px; gap: 14px;
} }
.topbar__coords, .statusbar__coords,
.topbar__sun { .topbar__sun {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -193,12 +195,13 @@ html, body {
height: 100%; height: 100%;
} }
.topbar__coords { .statusbar__coords {
cursor: pointer; cursor: pointer;
color: inherit;
} }
.topbar__coords:hover { .statusbar__coords:hover {
color: #fff; color: var(--ui-fg);
} }
.topbar__sun[hidden] { .topbar__sun[hidden] {
@@ -438,7 +441,7 @@ html, body {
} }
.sidebar { .sidebar {
flex: 0 0 52px; flex: 0 0 var(--rail);
position: relative; position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -450,7 +453,7 @@ html, body {
/* No overflow-y:auto here: setting only one axis to a clipping value /* No overflow-y:auto here: setting only one axis to a clipping value
forces the browser to compute the other axis as "auto" too (CSS forces the browser to compute the other axis as "auto" too (CSS
Overflow spec), which would clip the flyouts — they intentionally Overflow spec), which would clip the flyouts — they intentionally
poke out past the sidebar's own width via left:44px. */ poke out past the sidebar's own width. */
} }
.sidebar-item { .sidebar-item {
@@ -503,7 +506,7 @@ html, body {
.sidebar-flyout { .sidebar-flyout {
position: absolute; position: absolute;
top: 0; top: 0;
left: 44px; left: calc(var(--rail) - 6px);
z-index: 20; z-index: 20;
min-width: max-content; min-width: max-content;
background: var(--ui-bg); background: var(--ui-bg);
@@ -647,10 +650,10 @@ html, body {
.basemap-panel { .basemap-panel {
position: fixed; position: fixed;
top: 44px; /* below the topbar, its title in view */ top: 44px; /* below the topbar, its title in view */
left: 52px; left: var(--rail);
width: 300px; width: 300px;
max-width: 90vw; max-width: 90vw;
bottom: 0; bottom: var(--statusbar);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background: var(--ui-bg); background: var(--ui-bg);
@@ -670,7 +673,7 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) #ma
} }
body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .profile-panel { body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .profile-panel {
left: calc(52px + min(300px, 90vw)); left: calc(var(--rail) + min(300px, 90vw));
} }
/* Phone portrait: a pinned 300px panel left the map a sliver, so there it /* Phone portrait: a pinned 300px panel left the map a sliver, so there it
@@ -681,7 +684,7 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr
} }
body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .profile-panel { body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .profile-panel {
left: 52px; left: var(--rail);
} }
/* body: outranks .gpx-panel's own rule further down */ /* body: outranks .gpx-panel's own rule further down */
@@ -796,7 +799,7 @@ button.basemap-panel__link[hidden] { display: none; }
position: fixed; position: fixed;
top: 44px; top: 44px;
right: 0; right: 0;
bottom: 0; bottom: var(--statusbar);
width: 300px; width: 300px;
max-width: 90vw; max-width: 90vw;
background: var(--ui-bg); background: var(--ui-bg);
@@ -1074,10 +1077,10 @@ button.basemap-panel__link[hidden] { display: none; }
.gpx-panel { .gpx-panel {
position: fixed; position: fixed;
top: 44px; /* below the topbar, its title in view */ top: 44px; /* below the topbar, its title in view */
left: 52px; left: var(--rail);
width: 300px; width: 300px;
max-width: 90vw; max-width: 90vw;
bottom: 0; bottom: var(--statusbar);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background: var(--ui-bg); background: var(--ui-bg);
@@ -1524,8 +1527,8 @@ button.basemap-panel__link[hidden] { display: none; }
.measure-panel { .measure-panel {
position: absolute; position: absolute;
top: 0; top: 0;
left: 100%; right: 100%;
margin-left: 8px; margin-right: 8px;
z-index: 20; z-index: 20;
min-width: max-content; min-width: max-content;
background: var(--ui-bg); background: var(--ui-bg);
@@ -1632,28 +1635,50 @@ button.basemap-panel__link[hidden] { display: none; }
color: var(--ui-fg); color: var(--ui-fg);
} }
/* The search field in the topbar, its sources and results dropping down
under it (search.js). */
.topbar__search {
flex: 0 1 460px;
min-width: 0;
}
.search-ctrl { .search-ctrl {
position: relative; position: relative;
} }
.search-ctrl__button svg { .search-panel__form {
display: block; display: flex;
margin: 0 auto; align-items: center;
width: 18px; gap: 8px;
height: 18px; height: 32px;
padding: 0 10px;
border-radius: 8px;
background: rgb(255 255 255 / 0.12);
color: #ddd;
} }
.search-ctrl__button.active { .search-ctrl__icon svg {
background: var(--accent-bg); display: block;
width: 16px;
height: 16px;
}
.search-ctrl__key {
font: 12px inherit;
padding: 0 6px;
border: 1px solid rgb(255 255 255 / 0.25);
border-radius: 4px;
color: #bbb;
} }
.search-panel { .search-panel {
position: absolute; position: absolute;
top: 0; top: 100%;
left: 100%; left: 0;
margin-left: 8px; right: 0;
z-index: 20; margin-top: 6px;
width: 240px; z-index: 30;
min-width: 300px;
background: var(--ui-bg); background: var(--ui-bg);
border: 1px solid var(--ui-line); border: 1px solid var(--ui-line);
border-radius: 6px; border-radius: 6px;
@@ -1673,17 +1698,22 @@ button.basemap-panel__link[hidden] { display: none; }
} }
.search-panel__input { .search-panel__input {
width: 100%; flex: 1;
box-sizing: border-box; min-width: 0;
border: 1px solid var(--ui-line); border: none;
border-radius: 4px; background: none;
padding: 5px 7px; color: #fff;
font: inherit; font: 14px inherit;
outline: none;
}
.search-panel__input::placeholder {
color: #aaa;
} }
.search-panel__results { .search-panel__results {
list-style: none; list-style: none;
margin: 6px 0 0; margin: 0;
padding: 0; padding: 0;
flex: 1 1 auto; flex: 1 1 auto;
min-height: 0; min-height: 0;
@@ -1709,7 +1739,7 @@ button.basemap-panel__link[hidden] { display: none; }
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 2px 10px; gap: 2px 10px;
margin-top: 6px; margin-bottom: 6px;
font-size: 12px; font-size: 12px;
color: var(--ui-fg); color: var(--ui-fg);
} }
@@ -1761,8 +1791,8 @@ button.basemap-panel__link[hidden] { display: none; }
.notes-panel { .notes-panel {
position: absolute; position: absolute;
top: 0; top: 0;
left: 100%; right: 100%;
margin-left: 8px; margin-right: 8px;
z-index: 20; z-index: 20;
width: 200px; width: 200px;
background: var(--ui-bg); background: var(--ui-bg);
@@ -2034,18 +2064,6 @@ button.basemap-panel__link[hidden] { display: none; }
color: #fff; color: #fff;
} }
.zoom-level-ctrl__value {
width: 29px;
height: 29px;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
font-weight: 600;
color: var(--ui-fg);
user-select: none;
}
.pitch-toggle-ctrl__button { .pitch-toggle-ctrl__button {
width: 29px; width: 29px;
height: 29px; height: 29px;
@@ -2427,9 +2445,9 @@ button.basemap-panel__link[hidden] { display: none; }
.profile-panel { .profile-panel {
position: fixed; position: fixed;
left: 52px; left: var(--rail);
right: 0; right: 0;
bottom: 0; bottom: var(--statusbar);
max-height: 45vh; max-height: 45vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -2775,6 +2793,13 @@ button.basemap-panel__link[hidden] { display: none; }
font-weight: 600; font-weight: 600;
} }
/* the totals as a card (empty: no route yet, no card) */
.route-panel__summary:not(:empty) {
padding: 8px 10px;
border-radius: 8px;
background: var(--ui-bg-2);
}
.route-panel__points { .route-panel__points {
margin: 0 0 8px; margin: 0 0 8px;
padding: 0; padding: 0;
@@ -2878,10 +2903,19 @@ button.basemap-panel__link[hidden] { display: none; }
display: none; display: none;
} }
.route-panel__directions { .route-panel__directions,
.route-panel__fold {
margin-bottom: 8px; margin-bottom: 8px;
} }
.route-panel__fold summary {
cursor: pointer;
}
.route-panel__fold .route-panel__reach {
margin-top: 6px;
}
.route-panel__directions ol { .route-panel__directions ol {
margin: 6px 0 0; margin: 6px 0 0;
padding-left: 20px; padding-left: 20px;
@@ -3539,7 +3573,9 @@ html.driving .basemap-panel,
html.driving .gpx-panel, html.driving .gpx-panel,
html.driving .trail-panel, html.driving .trail-panel,
html.driving .profile-panel, html.driving .profile-panel,
html.driving #map .maplibregl-ctrl-top-left { display: none; } html.driving #map .maplibregl-ctrl-top-right > :not(.maplibregl-ctrl-overview-map),
html.driving .topbar__search,
html.driving .statusbar { display: none; }
.drive-bar { .drive-bar {
position: absolute; position: absolute;
left: 12px; left: 12px;
@@ -3705,3 +3741,61 @@ html.follow-3d .maplibregl-ctrl-overview-map { display: none; }
} }
.drive-trip__log button.drive-trip__log--on { background: var(--route-driven); color: #fff; } .drive-trip__log button.drive-trip__log--on { background: var(--route-driven); color: #fff; }
.drive-trip__log-state { flex: 1; color: var(--route-driven); font-weight: 600; font-size: 15px; } .drive-trip__log-state { flex: 1; color: var(--route-driven); font-weight: 600; font-size: 15px; }
/* The side rail, labelled (map.js sets data-label), and the status bar
under the map — the Design canvas' Desktop. */
.sidebar-icon {
width: calc(var(--rail) - 8px);
height: 52px;
flex-direction: column;
gap: 3px;
}
.sidebar-icon::after {
content: attr(data-label);
font-size: 10px;
font-weight: 600;
line-height: 1;
}
.statusbar {
flex: 0 0 var(--statusbar);
display: flex;
align-items: center;
gap: 18px;
padding: 0 12px;
border-top: 1px solid var(--ui-line);
background: var(--ui-bg-2);
color: var(--ui-muted);
font-size: 12px;
font-variant-numeric: tabular-nums;
white-space: nowrap;
overflow: hidden;
}
.statusbar__scale .maplibregl-ctrl-scale {
margin: 0;
font-size: 11px;
}
.statusbar__rev {
margin-left: auto;
}
/* Phone: the rail's icons alone, the status bar's basics. */
@media (max-width: 640px) {
:root {
--rail: 52px;
}
.sidebar-icon {
height: 36px;
}
.sidebar-icon::after,
.statusbar__cursor,
.statusbar__rev,
.search-ctrl__key {
display: none;
}
}
+42 -111
View File
@@ -142,12 +142,6 @@ class LayerToggleControl {
if (open) notifySidePanelOpen(this._panel); if (open) notifySidePanelOpen(this._panel);
} }
// Public wrapper so a second entry point (MapLayersButton, a map corner
// control) can open/close the same panel without reaching into a
// "private" method by convention only.
toggle() {
this._togglePanel();
}
setActive(name) { setActive(name) {
this._panel.querySelectorAll(".basemap-panel__option").forEach((button) => { this._panel.querySelectorAll(".basemap-panel__option").forEach((button) => {
@@ -164,71 +158,6 @@ class LayerToggleControl {
} }
} }
// A small map-corner button (grouped with Home/zoom, see below) that's a
// second entry point to the same panel LayerToggleControl already manages
// in the page's own sidebar — matching the National Park Service's own
// map control layout, which keeps zoom/home/base-map together on the map
// rather than split between the map and a separate side rail.
class MapLayersButton {
constructor(layerToggle) {
this._layerToggle = layerToggle;
}
onAdd() {
this._container = document.createElement("div");
this._container.className = "maplibregl-ctrl maplibregl-ctrl-group";
const button = document.createElement("button");
button.type = "button";
button.title = "Base map";
button.setAttribute("aria-label", "Base map");
button.innerHTML = LAYERS_ICON;
button.addEventListener("click", () => this._layerToggle.toggle());
this._container.appendChild(button);
return this._container;
}
onRemove() {
this._container.remove();
}
getDefaultPosition() {
return "top-left";
}
}
// A passive zoom-level readout, sitting in the same stack as the buttons
// around it — the National Park Service's own control layout has one (the
// small numbered square next to their zoom buttons). Not a button: no
// click behavior, just a live display, so it's a plain div rather than a
// <button> (no hover/focus affordance implying it does something).
class ZoomLevelControl {
onAdd(map) {
this._map = map;
this._container = document.createElement("div");
this._container.className = "maplibregl-ctrl maplibregl-ctrl-group zoom-level-ctrl";
this._label = document.createElement("div");
this._label.className = "zoom-level-ctrl__value";
this._container.appendChild(this._label);
this._update = () => {
this._label.textContent = Math.round(map.getZoom());
};
this._update();
map.on("zoom", this._update);
return this._container;
}
onRemove() {
this._map.off("zoom", this._update);
this._container.remove();
}
getDefaultPosition() {
return "top-left";
}
}
// Tilts the camera between a flat top-down view and a fixed 3D-perspective // Tilts the camera between a flat top-down view and a fixed 3D-perspective
// pitch — bearing stays untouched, so this is purely "look at it from an // pitch — bearing stays untouched, so this is purely "look at it from an
// angle", not a rotate/compass control. Tilted, the ground is raised into // angle", not a rotate/compass control. Tilted, the ground is raised into
@@ -341,13 +270,7 @@ const map = new MaplibreMap({
hash: "map", hash: "map",
}); });
// A compact top-left stack — Home, zoom, zoom-level readout, measure, // Home's bounds (rather than homePosition/zoom) so Home resets to an overview of
// locate-me, base map — matching the National Park Service's own map
// control layout,
// all grouped together rather than split across corners. Added in this
// order since MapLibre stacks same-position controls in add order.
//
// bounds (rather than homePosition/zoom) so Home resets to an overview of
// the whole country, not back to CENTER/ZOOM's initial Bratislava view — // the whole country, not back to CENTER/ZOOM's initial Bratislava view —
// now that the URL hash can restore any view on load (see the Hash option // now that the URL hash can restore any view on load (see the Hash option
// above), "current view" and "the default view" are no longer the same // above), "current view" and "the default view" are no longer the same
@@ -358,21 +281,17 @@ const SLOVAKIA_BOUNDS = [
[16.83, 47.73], [16.83, 47.73],
[22.57, 49.61], [22.57, 49.61],
]; ];
// The Design canvas' Desktop: search in the topbar, the map's own buttons
// in one column on the right — zoom and compass, the view (north lock, 3D,
// my position), the tools (measure, note, home); the zoom level, the scale
// and the coordinates in the status bar under the map.
const searchControl = new SearchControl(); const searchControl = new SearchControl();
map.addControl(searchControl, "top-left"); searchControl.mount(map, document.querySelector(".topbar__search"));
map.addControl(new HomeButton({ bounds: SLOVAKIA_BOUNDS }), "top-left");
// The compass shows the bearing; a click turns the map back north. // The compass shows the bearing; a click turns the map back north.
map.addControl(new NavigationControl({ visualizePitch: false }), "top-left"); map.addControl(new NavigationControl({ visualizePitch: false }), "top-right");
map.addControl(new RotationLockControl(), "top-left"); map.addControl(new RotationLockControl(), "top-right");
map.addControl(new ZoomLevelControl(), "top-left");
const pitchToggle = new PitchToggleControl(); const pitchToggle = new PitchToggleControl();
map.addControl(pitchToggle, "top-left"); map.addControl(pitchToggle, "top-right");
map.addControl(new MeasureControl(), "top-left");
// Writing a note needs a login (POST /api/library/notes) — no point adding a
// button that can only ever end in a 401 for a logged-out viewer, same
// "hide the write-only affordance" story as GpxPanelControl's own
// upload/new-folder buttons.
if (isLoggedIn()) map.addControl(new NotesControl(), "top-left");
// Constructed here (rather than down where it's mounted, alongside the // Constructed here (rather than down where it's mounted, alongside the
// other sidebar controls) so LocateControl can hold the same instance — // other sidebar controls) so LocateControl can hold the same instance —
// its constructor only touches `map`, mount() (which needs the sidebar // its constructor only touches `map`, mount() (which needs the sidebar
@@ -384,8 +303,25 @@ const gnssControl = new GnssControl(map);
// device's separate, often less accurate location service, but only once // device's separate, often less accurate location service, but only once
// the "GNSS" sidebar icon actually turns it on — not just whenever a // the "GNSS" sidebar icon actually turns it on — not just whenever a
// receiver happens to have a fix. See locate.js. // receiver happens to have a fix. See locate.js.
map.addControl(new LocateControl(gnssControl), "top-left"); map.addControl(new LocateControl(gnssControl), "top-right");
map.addControl(new ScaleControl({ unit: "metric" }), "bottom-left"); map.addControl(new MeasureControl(), "top-right");
// Writing a note needs a login (POST /api/library/notes) — no point adding a
// button that can only ever end in a 401 for a logged-out viewer, same
// "hide the write-only affordance" story as GpxPanelControl's own
// upload/new-folder buttons.
if (isLoggedIn()) map.addControl(new NotesControl(), "top-right");
map.addControl(new HomeButton({ bounds: SLOVAKIA_BOUNDS }), "top-right");
// The status bar: the map's center (click to copy), the point under the
// mouse, the zoom level, the scale.
const cursorLabel = document.querySelector(".statusbar__cursor");
map.on("mousemove", ({ lngLat }) => (cursorLabel.textContent = `Cursor ${formatCoords(lngLat.lat, lngLat.lng)}`));
map.getCanvasContainer().addEventListener("mouseleave", () => (cursorLabel.textContent = ""));
const zoomLabel = document.querySelector(".statusbar__zoom");
const updateZoom = () => (zoomLabel.textContent = `Zoom ${map.getZoom().toFixed(1)}`);
updateZoom();
map.on("zoom", updateZoom);
document.querySelector(".statusbar__scale").appendChild(new ScaleControl({ unit: "metric" }).onAdd(map));
// A small inset map showing where the current view sits in context — NPS's // A small inset map showing where the current view sits in context — NPS's
// own overview plugin (docs/nps-resources.adoc's "overview" entry, still on // own overview plugin (docs/nps-resources.adoc's "overview" entry, still on
@@ -402,7 +338,7 @@ map.once("style.load", () => {
map.addControl(new OverviewMapControl({}), "top-right"); map.addControl(new OverviewMapControl({}), "top-right");
}); });
const coordsLabel = document.querySelector(".topbar__coords"); const coordsLabel = document.querySelector(".statusbar__coords");
const updateCoords = () => { const updateCoords = () => {
const { lng, lat } = map.getCenter(); const { lng, lat } = map.getCenter();
coordsLabel.innerHTML = `<span class="topbar__icon">${WAYPOINT_ICON}</span><span>${formatCoords(lat, lng)}</span>`; coordsLabel.innerHTML = `<span class="topbar__icon">${WAYPOINT_ICON}</span><span>${formatCoords(lat, lng)}</span>`;
@@ -535,19 +471,20 @@ setInterval(updateNight, 60000);
const sidebar = document.getElementById("sidebar"); const sidebar = document.getElementById("sidebar");
// Grouped into the TODO's planned 4-module menu (Explorer / Offline hub / // The rail of the Design canvas' Desktop, labelled: what's on the map (the
// Navigation / Camper & HW) ahead of that split actually happening — // map, overlays), the library and imports; the route; offline data; live
// Camper & HW has no sidebar item yet (leveling/solar/telemetry are all // (GNSS, LiveTrack); Status pinned at the bottom. Folding Map, Overlays and
// still unbuilt), so it's left out rather than shown empty. // Live into one "On the map" panel is the canvas' next step, not done yet.
const layerToggle = new LayerToggleControl(applyStyle); const layerToggle = new LayerToggleControl(applyStyle);
const profilePanel = new TrackProfilePanel(map); const profilePanel = new TrackProfilePanel(map);
profilePanel.mount(); profilePanel.mount();
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Explorer"></div>`); layerToggle.mount(sidebar);
const gpxPanel = new GpxPanelControl(map, profilePanel); layerToggle.setActive("online");
gpxPanel.mount(sidebar);
const overlaysControl = new OverlaysControl(map); const overlaysControl = new OverlaysControl(map);
overlaysControl.mount(sidebar); overlaysControl.mount(sidebar);
const gpxPanel = new GpxPanelControl(map, profilePanel);
gpxPanel.mount(sidebar);
offerSharedFiles(gpxPanel); offerSharedFiles(gpxPanel);
searchControl.setLayerOpeners({ searchControl.setLayerOpeners({
layers: (path, result) => gpxPanel.showFeature(path, result.bbox.slice(0, 2)), layers: (path, result) => gpxPanel.showFeature(path, result.bbox.slice(0, 2)),
@@ -558,29 +495,23 @@ pitchToggle.setOverlaysControl(overlaysControl);
// "hide the write-only affordance" story as NotesControl above. // "hide the write-only affordance" story as NotesControl above.
if (isLoggedIn()) new PluginsControl(map).mount(sidebar); if (isLoggedIn()) new PluginsControl(map).mount(sidebar);
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Offline hub"></div>`); sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label"></div>`);
layerToggle.mount(sidebar);
layerToggle.setActive("online");
const routePanel = new RoutePanelControl(map, gnssControl, profilePanel); const routePanel = new RoutePanelControl(map, gnssControl, profilePanel);
routePanel.mount(sidebar); routePanel.mount(sidebar);
setupDriving(map, nightButton, routePanel); setupDriving(map, nightButton, routePanel);
new OfflineDataControl().mount(sidebar); new OfflineDataControl().mount(sidebar);
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Navigation"></div>`); sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label"></div>`);
gnssControl.mount(sidebar); gnssControl.mount(sidebar);
new LiveTrackPanelControl(map).mount(sidebar); new LiveTrackPanelControl(map).mount(sidebar);
if (isLoggedIn()) new DebugControl().mount(sidebar); if (isLoggedIn()) new DebugControl().mount(sidebar);
if (isLoggedIn()) setupUpdate(document.querySelector(".topbar__update"), document.querySelector(".debug-panel__update-check")); 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" };
sidebar.querySelectorAll(".sidebar-icon").forEach((icon) => (icon.dataset.label = RAIL_LABELS[icon.title] ?? icon.title));
setupSidePanelModes(); setupSidePanelModes();
// The sidebar already has a "Base map" icon (opens the same panel) —
// this is a second entry point for it, grouped with Home/zoom on the map
// itself rather than off in the page's own side rail, matching NPS's
// layout. layerToggle only needs to exist (not be mounted yet) for this.
const mapLayersButton = new MapLayersButton(layerToggle);
map.addControl(mapLayersButton, "top-left");
function applyStyle(name) { function applyStyle(name) {
layerToggle.setActive(name); layerToggle.setActive(name);
map.setStyle(nightMap.base(name === "offline" ? offlineStyle() : onlineStyle())); map.setStyle(nightMap.base(name === "offline" ? offlineStyle() : onlineStyle()));
+24 -25
View File
@@ -37,7 +37,7 @@ function formatKm(km) {
return km < 10 ? `${km.toFixed(1)} km` : `${Math.round(km)} km`; return km < 10 ? `${km.toFixed(1)} km` : `${Math.round(km)} km`;
} }
// A place-name/coordinate search box, matching NPS's own Park Tiles viewer. // A place-name/coordinate search box in the topbar.
// Every result says where it was found; picking one from a layer that's // Every result says where it was found; picking one from a layer that's
// currently switched off switches it on (see setLayerOpeners). // currently switched off switches it on (see setLayerOpeners).
export class SearchControl { export class SearchControl {
@@ -53,16 +53,20 @@ export class SearchControl {
this._openers = openers; this._openers = openers;
} }
onAdd(map) { // In the topbar (the Design canvas' Desktop): the field always there,
// the sources and results drop down under it while it's in use; "/"
// anywhere focuses it.
mount(map, slot) {
this._map = map; this._map = map;
this._container = document.createElement("div"); this._container = document.createElement("div");
this._container.className = "maplibregl-ctrl maplibregl-ctrl-group search-ctrl"; this._container.className = "search-ctrl";
this._container.innerHTML = ` this._container.innerHTML = `
<button type="button" class="search-ctrl__button" title="Search" aria-label="Search">${SEARCH_ICON}</button> <form class="search-panel__form" role="search">
<div class="search-panel" hidden> <span class="search-ctrl__icon" aria-hidden="true">${SEARCH_ICON}</span>
<form class="search-panel__form"> <input type="search" class="search-panel__input" placeholder="Search places, the library, or lat, lng" aria-label="Search">
<input type="text" class="search-panel__input" placeholder="Search, or lat, lng"> <kbd class="search-ctrl__key" title="Press / to search">/</kbd>
</form> </form>
<div class="search-panel" hidden>
<div class="search-panel__sources"> <div class="search-panel__sources">
${SOURCES.map( ${SOURCES.map(
(source) => ` (source) => `
@@ -73,12 +77,11 @@ export class SearchControl {
<ul class="search-panel__results"></ul> <ul class="search-panel__results"></ul>
</div> </div>
`; `;
this._button = this._container.querySelector(".search-ctrl__button");
this._panel = this._container.querySelector(".search-panel"); this._panel = this._container.querySelector(".search-panel");
this._input = this._container.querySelector(".search-panel__input"); this._input = this._container.querySelector(".search-panel__input");
this._resultsEl = this._container.querySelector(".search-panel__results"); this._resultsEl = this._container.querySelector(".search-panel__results");
this._button.addEventListener("click", () => this._toggle()); this._input.addEventListener("focus", () => (this._panel.hidden = false));
this._container.querySelector(".search-panel__form").addEventListener("submit", (event) => { this._container.querySelector(".search-panel__form").addEventListener("submit", (event) => {
event.preventDefault(); event.preventDefault();
this._search(); this._search();
@@ -90,23 +93,20 @@ export class SearchControl {
if (this._input.value.trim()) this._search(); if (this._input.value.trim()) this._search();
}); });
}); });
document.addEventListener("click", (event) => {
return this._container; if (!this._container.contains(event.target)) this._panel.hidden = true;
});
document.addEventListener("keydown", (event) => {
if (event.key === "Escape" && this._container.contains(document.activeElement)) {
this._panel.hidden = true;
this._input.blur();
} else if (event.key === "/" && !event.target.closest("input, textarea, select, [contenteditable]")) {
event.preventDefault();
this._input.focus();
} }
});
onRemove() { slot.appendChild(this._container);
this._container.remove();
}
getDefaultPosition() {
return "top-left";
}
_toggle() {
const opening = this._panel.hidden;
this._panel.hidden = !opening;
this._button.classList.toggle("active", opening);
if (opening) this._input.focus();
} }
async _search() { async _search() {
@@ -260,6 +260,5 @@ export class SearchControl {
this._marker = new Marker({ element: el }).setLngLat(center).addTo(this._map); this._marker = new Marker({ element: el }).setLngLat(center).addTo(this._map);
} }
this._panel.hidden = true; this._panel.hidden = true;
this._button.classList.remove("active");
} }
} }
+37 -23
View File
@@ -1,8 +1,8 @@
<div id="app"> <div id="app">
<header class="topbar"> <header class="topbar">
<span class="topbar__brand" title="rev <%= revision %>">MapTool</span> <span class="topbar__brand" title="rev <%= revision %>">MapTool</span>
<div class="topbar__search"></div>
<span class="topbar__center"> <span class="topbar__center">
<span class="topbar__coords"></span>
<span class="topbar__sun" title="Sun &amp; moon" hidden></span> <span class="topbar__sun" title="Sun &amp; moon" hidden></span>
</span> </span>
<div class="sun-chart" hidden></div> <div class="sun-chart" hidden></div>
@@ -23,6 +23,14 @@
<nav id="sidebar" class="sidebar"></nav> <nav id="sidebar" class="sidebar"></nav>
<div id="map"></div> <div id="map"></div>
</div> </div>
<footer class="statusbar">
<span class="statusbar__coords"></span>
<span class="statusbar__cursor"></span>
<span class="statusbar__zoom"></span>
<span class="statusbar__scale"></span>
<span class="statusbar__rev">rev <%= revision %></span>
</footer>
</div> </div>
<div id="profile-panel" class="profile-panel" hidden> <div id="profile-panel" class="profile-panel" hidden>
@@ -132,7 +140,9 @@
</div> </div>
<!-- Filled by RoutePanelControl (public/js/route.js). --> <!-- Filled by RoutePanelControl (public/js/route.js). -->
<div class="route-panel__body"> <div class="route-panel__body">
<p class="route-panel__hint">Click the map to add points (or "Add to route" on a search result or a library point); drag a marker to move it.</p> <!-- The order of the Design canvas' Desktop artboard: the points
with their legs, adding one, the totals, the vehicle and what to avoid,
then the long parts folded; editing the whole route at the bottom. -->
<p class="route-panel__editing" hidden></p> <p class="route-panel__editing" hidden></p>
<ol class="route-panel__points"></ol> <ol class="route-panel__points"></ol>
<!-- Icons are added by RoutePanelControl (public/js/icons.js). --> <!-- Icons are added by RoutePanelControl (public/js/icons.js). -->
@@ -144,30 +154,10 @@
<input type="search" placeholder="Search saved points" aria-label="Search saved points"> <input type="search" placeholder="Search saved points" aria-label="Search saved points">
<ul></ul> <ul></ul>
</div> </div>
<div class="route-panel__buttons"> <p class="route-panel__hint">Add a point: below, "+" on a search result or a library point, or click the map; drag a marker to move it.</p>
<button type="button" data-action="reverse">Reverse</button>
<button type="button" data-action="clear">Clear</button>
<button type="button" data-action="save" hidden>Save to library</button>
</div>
<p class="route-panel__summary"></p> <p class="route-panel__summary"></p>
<ul class="route-panel__countries" hidden></ul> <ul class="route-panel__countries" hidden></ul>
<button type="button" class="route-panel__profile" hidden>Elevation profile</button> <button type="button" class="route-panel__profile" hidden>Elevation profile</button>
<details class="route-panel__directions" hidden>
<summary>Directions</summary>
<ol></ol>
</details>
<div class="route-panel__reach">
<span>Reach in</span>
<select>
<option value="30">30 min</option>
<option value="60" selected>1 h</option>
<option value="120">2 h</option>
<option value="30,60,120">30 min · 1 h · 2 h</option>
</select>
<button type="button" data-action="reach">Show</button>
<button type="button" data-action="reach-clear" hidden>Hide</button>
</div>
<p class="route-panel__reach-status" hidden></p>
<div class="route-panel__vehicle-row"> <div class="route-panel__vehicle-row">
<label>Vehicle <select class="route-panel__vehicle-select"></select></label> <label>Vehicle <select class="route-panel__vehicle-select"></select></label>
<button type="button" data-action="vehicle-edit" hidden>Edit</button> <button type="button" data-action="vehicle-edit" hidden>Edit</button>
@@ -222,6 +212,30 @@
<button type="button" data-action="vehicle-add">+ New vehicle</button> <button type="button" data-action="vehicle-add">+ New vehicle</button>
<button type="button" data-action="vehicle-delete">Delete</button> <button type="button" data-action="vehicle-delete">Delete</button>
</fieldset> </fieldset>
<details class="route-panel__directions" hidden>
<summary>Directions</summary>
<ol></ol>
</details>
<details class="route-panel__fold">
<summary>Reach</summary>
<div class="route-panel__reach">
<span>Reach in</span>
<select>
<option value="30">30 min</option>
<option value="60" selected>1 h</option>
<option value="120">2 h</option>
<option value="30,60,120">30 min · 1 h · 2 h</option>
</select>
<button type="button" data-action="reach">Show</button>
<button type="button" data-action="reach-clear" hidden>Hide</button>
</div>
<p class="route-panel__reach-status" hidden></p>
</details>
<div class="route-panel__buttons">
<button type="button" data-action="reverse">Reverse</button>
<button type="button" data-action="clear">Clear</button>
<button type="button" data-action="save" hidden>Save to library</button>
</div>
</div> </div>
</div> </div>