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
+252 -214

No files matched your search

+148 -54
View File
@@ -6,6 +6,8 @@
blue: nothing brighter than the map). <html data-palette="dusk|night">
switches; Day is the default. Meanings never change between them. */
:root {
--rail: 72px; /* the labelled side rail */
--statusbar: 24px;
/* planning UI (NPS) */
--ui-bg: #ffffff;
--ui-bg-2: #f0f0f0; /* hover, subtle fills */
@@ -161,7 +163,7 @@ html, body {
gap: 14px;
}
.topbar__coords,
.statusbar__coords,
.topbar__sun {
display: flex;
align-items: center;
@@ -193,12 +195,13 @@ html, body {
height: 100%;
}
.topbar__coords {
.statusbar__coords {
cursor: pointer;
color: inherit;
}
.topbar__coords:hover {
color: #fff;
.statusbar__coords:hover {
color: var(--ui-fg);
}
.topbar__sun[hidden] {
@@ -438,7 +441,7 @@ html, body {
}
.sidebar {
flex: 0 0 52px;
flex: 0 0 var(--rail);
position: relative;
display: flex;
flex-direction: column;
@@ -450,7 +453,7 @@ html, body {
/* 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
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 {
@@ -503,7 +506,7 @@ html, body {
.sidebar-flyout {
position: absolute;
top: 0;
left: 44px;
left: calc(var(--rail) - 6px);
z-index: 20;
min-width: max-content;
background: var(--ui-bg);
@@ -647,10 +650,10 @@ html, body {
.basemap-panel {
position: fixed;
top: 44px; /* below the topbar, its title in view */
left: 52px;
left: var(--rail);
width: 300px;
max-width: 90vw;
bottom: 0;
bottom: var(--statusbar);
display: flex;
flex-direction: column;
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 {
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
@@ -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 {
left: 52px;
left: var(--rail);
}
/* body: outranks .gpx-panel's own rule further down */
@@ -796,7 +799,7 @@ button.basemap-panel__link[hidden] { display: none; }
position: fixed;
top: 44px;
right: 0;
bottom: 0;
bottom: var(--statusbar);
width: 300px;
max-width: 90vw;
background: var(--ui-bg);
@@ -1074,10 +1077,10 @@ button.basemap-panel__link[hidden] { display: none; }
.gpx-panel {
position: fixed;
top: 44px; /* below the topbar, its title in view */
left: 52px;
left: var(--rail);
width: 300px;
max-width: 90vw;
bottom: 0;
bottom: var(--statusbar);
display: flex;
flex-direction: column;
background: var(--ui-bg);
@@ -1524,8 +1527,8 @@ button.basemap-panel__link[hidden] { display: none; }
.measure-panel {
position: absolute;
top: 0;
left: 100%;
margin-left: 8px;
right: 100%;
margin-right: 8px;
z-index: 20;
min-width: max-content;
background: var(--ui-bg);
@@ -1632,28 +1635,50 @@ button.basemap-panel__link[hidden] { display: none; }
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 {
position: relative;
}
.search-ctrl__button svg {
display: block;
margin: 0 auto;
width: 18px;
height: 18px;
.search-panel__form {
display: flex;
align-items: center;
gap: 8px;
height: 32px;
padding: 0 10px;
border-radius: 8px;
background: rgb(255 255 255 / 0.12);
color: #ddd;
}
.search-ctrl__button.active {
background: var(--accent-bg);
.search-ctrl__icon svg {
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 {
position: absolute;
top: 0;
left: 100%;
margin-left: 8px;
z-index: 20;
width: 240px;
top: 100%;
left: 0;
right: 0;
margin-top: 6px;
z-index: 30;
min-width: 300px;
background: var(--ui-bg);
border: 1px solid var(--ui-line);
border-radius: 6px;
@@ -1673,17 +1698,22 @@ button.basemap-panel__link[hidden] { display: none; }
}
.search-panel__input {
width: 100%;
box-sizing: border-box;
border: 1px solid var(--ui-line);
border-radius: 4px;
padding: 5px 7px;
font: inherit;
flex: 1;
min-width: 0;
border: none;
background: none;
color: #fff;
font: 14px inherit;
outline: none;
}
.search-panel__input::placeholder {
color: #aaa;
}
.search-panel__results {
list-style: none;
margin: 6px 0 0;
margin: 0;
padding: 0;
flex: 1 1 auto;
min-height: 0;
@@ -1709,7 +1739,7 @@ button.basemap-panel__link[hidden] { display: none; }
display: flex;
flex-wrap: wrap;
gap: 2px 10px;
margin-top: 6px;
margin-bottom: 6px;
font-size: 12px;
color: var(--ui-fg);
}
@@ -1761,8 +1791,8 @@ button.basemap-panel__link[hidden] { display: none; }
.notes-panel {
position: absolute;
top: 0;
left: 100%;
margin-left: 8px;
right: 100%;
margin-right: 8px;
z-index: 20;
width: 200px;
background: var(--ui-bg);
@@ -2034,18 +2064,6 @@ button.basemap-panel__link[hidden] { display: none; }
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 {
width: 29px;
height: 29px;
@@ -2427,9 +2445,9 @@ button.basemap-panel__link[hidden] { display: none; }
.profile-panel {
position: fixed;
left: 52px;
left: var(--rail);
right: 0;
bottom: 0;
bottom: var(--statusbar);
max-height: 45vh;
display: flex;
flex-direction: column;
@@ -2775,6 +2793,13 @@ button.basemap-panel__link[hidden] { display: none; }
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 {
margin: 0 0 8px;
padding: 0;
@@ -2878,10 +2903,19 @@ button.basemap-panel__link[hidden] { display: none; }
display: none;
}
.route-panel__directions {
.route-panel__directions,
.route-panel__fold {
margin-bottom: 8px;
}
.route-panel__fold summary {
cursor: pointer;
}
.route-panel__fold .route-panel__reach {
margin-top: 6px;
}
.route-panel__directions ol {
margin: 6px 0 0;
padding-left: 20px;
@@ -3539,7 +3573,9 @@ html.driving .basemap-panel,
html.driving .gpx-panel,
html.driving .trail-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 {
position: absolute;
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-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);
}
// 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) {
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
// 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
@@ -341,13 +270,7 @@ const map = new MaplibreMap({
hash: "map",
});
// A compact top-left stack — Home, zoom, zoom-level readout, measure,
// 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
// Home's bounds (rather than homePosition/zoom) so Home resets to an overview of
// 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
// above), "current view" and "the default view" are no longer the same
@@ -358,21 +281,17 @@ const SLOVAKIA_BOUNDS = [
[16.83, 47.73],
[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();
map.addControl(searchControl, "top-left");
map.addControl(new HomeButton({ bounds: SLOVAKIA_BOUNDS }), "top-left");
searchControl.mount(map, document.querySelector(".topbar__search"));
// The compass shows the bearing; a click turns the map back north.
map.addControl(new NavigationControl({ visualizePitch: false }), "top-left");
map.addControl(new RotationLockControl(), "top-left");
map.addControl(new ZoomLevelControl(), "top-left");
map.addControl(new NavigationControl({ visualizePitch: false }), "top-right");
map.addControl(new RotationLockControl(), "top-right");
const pitchToggle = new PitchToggleControl();
map.addControl(pitchToggle, "top-left");
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");
map.addControl(pitchToggle, "top-right");
// Constructed here (rather than down where it's mounted, alongside the
// other sidebar controls) so LocateControl can hold the same instance —
// 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
// the "GNSS" sidebar icon actually turns it on — not just whenever a
// receiver happens to have a fix. See locate.js.
map.addControl(new LocateControl(gnssControl), "top-left");
map.addControl(new ScaleControl({ unit: "metric" }), "bottom-left");
map.addControl(new LocateControl(gnssControl), "top-right");
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
// 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");
});
const coordsLabel = document.querySelector(".topbar__coords");
const coordsLabel = document.querySelector(".statusbar__coords");
const updateCoords = () => {
const { lng, lat } = map.getCenter();
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");
// Grouped into the TODO's planned 4-module menu (Explorer / Offline hub /
// Navigation / Camper & HW) ahead of that split actually happening —
// Camper & HW has no sidebar item yet (leveling/solar/telemetry are all
// still unbuilt), so it's left out rather than shown empty.
// 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.
const layerToggle = new LayerToggleControl(applyStyle);
const profilePanel = new TrackProfilePanel(map);
profilePanel.mount();
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Explorer"></div>`);
const gpxPanel = new GpxPanelControl(map, profilePanel);
gpxPanel.mount(sidebar);
layerToggle.mount(sidebar);
layerToggle.setActive("online");
const overlaysControl = new OverlaysControl(map);
overlaysControl.mount(sidebar);
const gpxPanel = new GpxPanelControl(map, profilePanel);
gpxPanel.mount(sidebar);
offerSharedFiles(gpxPanel);
searchControl.setLayerOpeners({
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.
if (isLoggedIn()) new PluginsControl(map).mount(sidebar);
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Offline hub"></div>`);
layerToggle.mount(sidebar);
layerToggle.setActive("online");
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label"></div>`);
const routePanel = new RoutePanelControl(map, gnssControl, profilePanel);
routePanel.mount(sidebar);
setupDriving(map, nightButton, routePanel);
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);
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" };
sidebar.querySelectorAll(".sidebar-icon").forEach((icon) => (icon.dataset.label = RAIL_LABELS[icon.title] ?? icon.title));
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) {
layerToggle.setActive(name);
map.setStyle(nightMap.base(name === "offline" ? offlineStyle() : onlineStyle()));
+25 -26
View File
@@ -37,7 +37,7 @@ function formatKm(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
// currently switched off switches it on (see setLayerOpeners).
export class SearchControl {
@@ -53,16 +53,20 @@ export class SearchControl {
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._container = document.createElement("div");
this._container.className = "maplibregl-ctrl maplibregl-ctrl-group search-ctrl";
this._container.className = "search-ctrl";
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">
<span class="search-ctrl__icon" aria-hidden="true">${SEARCH_ICON}</span>
<input type="search" class="search-panel__input" placeholder="Search places, the library, or lat, lng" aria-label="Search">
<kbd class="search-ctrl__key" title="Press / to search">/</kbd>
</form>
<div class="search-panel" hidden>
<form class="search-panel__form">
<input type="text" class="search-panel__input" placeholder="Search, or lat, lng">
</form>
<div class="search-panel__sources">
${SOURCES.map(
(source) => `
@@ -73,12 +77,11 @@ export class SearchControl {
<ul class="search-panel__results"></ul>
</div>
`;
this._button = this._container.querySelector(".search-ctrl__button");
this._panel = this._container.querySelector(".search-panel");
this._input = this._container.querySelector(".search-panel__input");
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) => {
event.preventDefault();
this._search();
@@ -90,23 +93,20 @@ export class SearchControl {
if (this._input.value.trim()) this._search();
});
});
document.addEventListener("click", (event) => {
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();
}
});
return this._container;
}
onRemove() {
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();
slot.appendChild(this._container);
}
async _search() {
@@ -260,6 +260,5 @@ export class SearchControl {
this._marker = new Marker({ element: el }).setLngLat(center).addTo(this._map);
}
this._panel.hidden = true;
this._button.classList.remove("active");
}
}