Material Design Icons replace the hand-drawn UI icons (only the used ones vendored, Renovate-tracked); route panel: saved-point picker, buttons on two rows with icons
CI / check (push) Successful in 19s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-11-15 11:17:40 +01:00
1 parent a6d63e242b
commit 4c704045c5
10 files changed
+251 -206

No files matched your search

+63 -202
View File
@@ -1,136 +1,70 @@
// Small hand-authored monoline SVG icons for the sidebar, so the app
// doesn't need to vendor an icon font/library for four glyphs.
// The app's icons as inline SVG strings (fill currentColor, so CSS
// colors them and gpx.js can recolor a copy for map markers).
// Material Design Icons (Apache-2.0, public/vendor/mdi/) for the UI;
// the National Park Service pictograms further down (CC0) for points.
// bin/vendor-sync.mjs vendors only the mdi* names used in public/js/.
import {
mdiBacteriaOutline,
mdiBugOutline,
mdiClockOutline,
mdiCloudDownloadOutline,
mdiContentSaveOutline,
mdiCrosshairsGps,
mdiDeleteSweepOutline,
mdiFolderPlusOutline,
mdiLayersOutline,
mdiLayersPlus,
mdiMagnify,
mdiMapMarkerOutline,
mdiMapMarkerPath,
mdiMapMarkerPlusOutline,
mdiMapMarkerRadiusOutline,
mdiMapMarkerStarOutline,
mdiPuzzleOutline,
mdiRadar,
mdiRoutes,
mdiRuler,
mdiSunAngleOutline,
mdiSwapVertical,
mdiTrayArrowDown,
mdiTrayArrowUp,
mdiWeatherSunsetDown,
mdiWeatherSunsetUp,
mdiWikipedia,
} from "/vendor/mdi/mdi.mjs";
export const LAYERS_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" stroke-linecap="round">
<path d="M12 3 2 9l10 6 10-6-10-6z"/>
<path d="M2 14l10 6 10-6"/>
</svg>`;
// Two overlapping circles — distinct from LAYERS_ICON's stacked-planes
// look (that one picks a *base* map; this one is for the sidebar flyout
// toggling live overlay layers, e.g. Wikipedia, on top of whichever base
// map is showing) while still reading as "layers combining."
export const OVERLAYS_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" stroke-linecap="round">
<circle cx="9" cy="12" r="6"/>
<circle cx="15" cy="12" r="6"/>
</svg>`;
export const NOTE_PIN_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 21s7-7.58 7-12a7 7 0 0 0-14 0c0 4.42 7 12 7 12z"/>
<path d="M12 6.5v5M9.5 9h5"/>
</svg>`;
export const GPX_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<circle cx="5" cy="6" r="2"/>
<circle cx="19" cy="18" r="2"/>
<path d="M6.5 7.5C10 11 8 13 12 13s2 5 6.5 5"/>
</svg>`;
export const GNSS_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round">
<circle cx="12" cy="12" r="5.5"/>
<circle cx="12" cy="12" r="1.4" fill="currentColor" stroke="none"/>
<path d="M12 2v3M12 19v3M2 12h3M19 12h3"/>
</svg>`;
export const RULER_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" stroke-linecap="round">
<path d="M4 15 15 4l5 5-11 11-5-5z"/>
<path d="M9 10l1.5 1.5M12 7l1.5 1.5M15 4l1.5 1.5M6 13l1.5 1.5"/>
</svg>`;
// Toolbar readout glyphs (public/js/sun.js's text, assembled with these by
// map.js) — same monoline style as the sidebar icons above, no NPS source
// for either (that set has no sunrise/sunset pictogram).
export const SUNRISE_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 18h18"/>
<path d="M6 18a6 6 0 0 1 12 0"/>
<path d="M12 13V5"/>
<path d="M9 8l3-3 3 3"/>
</svg>`;
export const SUNSET_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 18h18"/>
<path d="M6 18a6 6 0 0 1 12 0"/>
<path d="M12 5v8"/>
<path d="M9 10l3 3 3-3"/>
</svg>`;
export const SEARCH_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="7"/>
<path d="M20 20l-4.35-4.35"/>
</svg>`;
export const NEW_FOLDER_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"/>
<path d="M12 11v5M9.5 13.5h5"/>
</svg>`;
export const UPLOAD_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 15V4M8 8l4-4 4 4"/>
<path d="M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3"/>
</svg>`;
// The inverse of UPLOAD_ICON (arrow into the tray, not out of it) — used
// for the import plugins panel (plugins.js), which pulls data in from
// somewhere else rather than sending a file out.
export const PLUGIN_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 4v11M8 11l4 4 4-4"/>
<path d="M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3"/>
</svg>`;
// Shown next to each file in the GPX tree, indicating whether it has
// waypoints, a track, or both.
export const WAYPOINT_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 21s7-7.58 7-12a7 7 0 0 0-14 0c0 4.42 7 12 7 12z"/>
<circle cx="12" cy="9" r="2.2"/>
</svg>`;
const mdi = (path) => `<svg viewBox="0 0 24 24"><path fill="currentColor" d="${path}"/></svg>`;
export const LAYERS_ICON = mdi(mdiLayersOutline);
export const OVERLAYS_ICON = mdi(mdiLayersPlus);
export const NOTE_PIN_ICON = mdi(mdiMapMarkerPlusOutline);
export const GPX_ICON = mdi(mdiMapMarkerPath);
export const GNSS_ICON = mdi(mdiCrosshairsGps);
export const RULER_ICON = mdi(mdiRuler);
export const SUNRISE_ICON = mdi(mdiWeatherSunsetUp);
export const SUNSET_ICON = mdi(mdiWeatherSunsetDown);
export const SEARCH_ICON = mdi(mdiMagnify);
export const NEW_FOLDER_ICON = mdi(mdiFolderPlusOutline);
export const UPLOAD_ICON = mdi(mdiTrayArrowUp);
export const PLUGIN_ICON = mdi(mdiPuzzleOutline);
export const WAYPOINT_ICON = mdi(mdiMapMarkerOutline);
export const PENDING_ICON = mdi(mdiClockOutline);
export const DOWNLOAD_ICON = mdi(mdiTrayArrowDown);
export const ROUTE_ICON = mdi(mdiRoutes);
export const RADAR_CLOUD_ICON = mdi(mdiRadar);
export const TERRAIN_SHADOW_ICON = mdi(mdiSunAngleOutline);
export const CONTOUR_ICON = mdi(mdiBacteriaOutline);
export const OFFLINE_DATA_ICON = mdi(mdiCloudDownloadOutline);
export const DEBUG_ICON = mdi(mdiBugOutline);
export const WIKI_ICON = mdi(mdiWikipedia);
export const LIVETRACK_ICON = mdi(mdiMapMarkerRadiusOutline);
export const POSITION_ICON = mdi(mdiCrosshairsGps);
export const SAVED_POINT_ICON = mdi(mdiMapMarkerStarOutline);
export const REVERSE_ICON = mdi(mdiSwapVertical);
export const CLEAR_ICON = mdi(mdiDeleteSweepOutline);
export const SAVE_ICON = mdi(mdiContentSaveOutline);
export const TRACK_ICON = GPX_ICON;
// Shown next to a file whose GeoJSON conversion is NOT yet cached on disk
// (GpxStore#geojson) — the uncommon case, since GpxStore#save converts
// eagerly at upload time; this only happens for a .gpx/.fit dropped
// straight into data/gpx/ on the filesystem, bypassing the app, and not
// yet opened. Everything uploaded normally is cached almost immediately,
// so badging the common case would just be noise — this badges the
// exception instead.
export const PENDING_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="8"/>
<path d="M12 8v4l3 2"/>
</svg>`;
// A small download button next to each tree file's delete button — the
// name link (see gpx.js's _renderFile) does the same thing, but isn't
// obviously clickable at a glance, so this is the discoverable version.
export const DOWNLOAD_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 4v11M8 11l4 4 4-4"/>
<path d="M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3"/>
</svg>`;
// Same shape as TRACK_ICON, dashed — a route is planned rather than
// recorded, the same visual convention most map apps use for the
// distinction.
export const ROUTE_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<circle cx="5" cy="6" r="2"/>
<circle cx="19" cy="18" r="2"/>
<path d="M6.5 7.5C10 11 8 13 12 13s2 5 6.5 5" stroke-dasharray="2 2.2"/>
</svg>`;
// A rounded-square badge — used as the map marker for individual waypoints,
// tinted by category color via icon-color (see gpx.js). Not a plain dot,
// which blended in with a base map style's own small circular POI icons,
@@ -172,39 +106,6 @@ export const MAP_MARKER_ICON = `
export const WILDERNESS_ICON = `
<svg viewBox="0 0 22 22" fill="currentColor"><polygon points="18,18 13,15 17,15 13,11 16,11 12,7 15,7 12,4 14,4 11,0 8,4 10,4 7,7 10,7 6,11 9,11 5,15 9,15 4,18 10,18 10,22 12,22 12,18 "/></svg>`;
// Hand-drawn, not NPS-sourced — that set has no weather/precipitation
// pictogram to reuse for the Overlays panel's Radar item, unlike Wikipedia
// (WIKI_ICON) and Terrain shading (WILDERNESS_ICON) above.
export const RADAR_CLOUD_ICON = `
<svg viewBox="0 0 22 22" fill="currentColor">
<path d="M17,10.1c-0.4-3-2.9-5.3-6-5.3c-2.5,0-4.7,1.5-5.6,3.8C3.4,8.9,1,11.1,1,13.9C1,16.7,3.3,19,6.1,19h10.3
c2.5,0,4.6-2,4.6-4.5C21,12.2,19.3,10.4,17,10.1z"/>
<rect x="6" y="20" width="1.6" height="2"/>
<rect x="10.2" y="20" width="1.6" height="2"/>
<rect x="14.4" y="20" width="1.6" height="2"/>
</svg>`;
// Hand-drawn, not NPS-sourced — same story as RADAR_CLOUD_ICON above, no
// terrain-shadow/sun-behind-a-ridge pictogram in that set either. Used as
// the Overlays panel's Terrain shadow glyph (shadow.js via overlays.js).
export const TERRAIN_SHADOW_ICON = `
<svg viewBox="0 0 22 22" fill="currentColor">
<circle cx="16" cy="6" r="3"/>
<polygon points="0,19 6,9 9,13 13,6 22,19"/>
</svg>`;
// Hand-drawn, not NPS-sourced — no contour-line pictogram in that set
// either. Concentric rings via fill-rule evenodd, same solid-glyph
// convention as WILDERNESS_ICON/RADAR_CLOUD_ICON/TERRAIN_SHADOW_ICON above —
// used as the Overlays panel's Contour lines glyph (contour.js).
export const CONTOUR_ICON = `
<svg viewBox="0 0 22 22" fill="currentColor" fill-rule="evenodd">
<path d="M21,11 A10,10 0 1,0 1,11 A10,10 0 1,0 21,11 Z
M18.5,11 A7.5,7.5 0 1,0 3.5,11 A7.5,7.5 0 1,0 18.5,11 Z
M16,11 A5,5 0 1,0 6,11 A5,5 0 1,0 16,11 Z
M13.5,11 A2.5,2.5 0 1,0 8.5,11 A2.5,2.5 0 1,0 13.5,11 Z"/>
</svg>`;
// src/bicycle-trail-22.svg — pulled out to its own constant since it's also
// used unrasterized, inline, as PARK4NIGHT_TAGS.vtt below.
const BICYCLE_TRAIL_ICON = `
@@ -420,43 +321,3 @@ Object.assign(POI_ICONS, {
shop_convenience: STORE_ICON,
});
// Hand-drawn, not NPS-sourced — no "download offline map data" pictogram
// in that set either. A tray with a downward arrow into it, same solid
// 22x22 currentColor convention as CONTOUR_ICON/TERRAIN_SHADOW_ICON above
// — used for the "Offline data" sidebar icon (offline_data.js).
export const OFFLINE_DATA_ICON = `
<svg viewBox="0 0 22 22" fill="currentColor">
<path d="M10,0h2v10.5l3-3l1.4,1.4L11,14.3L5.6,8.9L7,7.5l3,3V0z"/>
<path d="M2,15h18v2H2z M2,18h18v2H2z"/>
</svg>`;
// src/bookstore-22.svg (NPS symbol library, same source/license as
// POI_ICONS above) — used as the fixed marker glyph for the "Wikipedia"
// map layer (gpx.js), not part of POI_ICONS itself: that set is keyed by
// OSM/p4n2gpx category and doubles as the note icon-picker's option list
// (notes.js), neither of which applies here — every point on this layer
// gets the same one glyph, there's no per-feature category to key it by.
// A bug — the status/debug panel (debug.js).
export const DEBUG_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
<rect x="7" y="7" width="10" height="13" rx="5"/>
<path d="M9 7a3 3 0 0 1 6 0M12 11v9M3 13h4M17 13h4M4 7l3 2M20 7l-3 2M4 19l3-2M20 19l-3-2"/>
</svg>`;
export const WIKI_ICON = `
<svg viewBox="0 0 22 22" fill="currentColor">
<path d="M16.6,20.7c-0.6,0-0.9-0.4-0.9-0.9c0-0.5,0.3-0.9,0.9-0.9c0.3,0,0.5-0.2,0.5-0.5
S16.9,18,16.6,18c-1.1,0-1.9,0.8-1.9,1.9c0,1,0.7,1.9,1.9,1.9c0.3,0,0.5-0.2,0.5-0.5S16.9,20.7,16.6,20.7L16.6,20.7z"/>
<path d="M5,18c0,0,0,0,0,0c0,3.1,0.5,4,2.7,4l8.9,0c0.3,0,0.5-0.2,0.5-0.5
c0-0.3-0.2-0.5-0.5-0.5H8c-1.5,0-2-0.5-2-3c0,0,0,0,0-0.1c0-0.3-0.2-0.5-0.5-0.5S5,17.7,5,18L5,18z"/>
<path d="M5,8c0-0.6,5-5,5-5h5h1c0.6,0,1,0.4,1,1v14c0,0.6-0.4,1-1,1H6c-0.6,0-1-0.4-1-1
V8z M9,4L6,18c0,0,10,0,10,0c0,0,0-14,0-14C16,4,9,4,9,4z"/>
<path d="M5,6.8c0-0.5,0.4-1.3,0.8-1.6l6.4-4.7C12.7,0.2,13,0.4,13,1v10
c0,0.6-0.3,1.7-0.7,2.1l-6.5,5.3C5.4,18.8,5,18.6,5,18V6.8z"/>
</svg>`;
export const LIVETRACK_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 21s7-7.58 7-12a7 7 0 0 0-14 0c0 4.42 7 12 7 12z"/>
<path d="M8.5 9a3.5 3.5 0 0 1 7 0" stroke-dasharray="1.5 2.2"/>
</svg>`;
+48 -1
View File
@@ -1,5 +1,5 @@
import { Marker } from "/vendor/maplibre-gl/maplibre-gl.mjs";
import { ROUTE_ICON } from "/js/icons.js";
import { ROUTE_ICON, POSITION_ICON, SAVED_POINT_ICON, REVERSE_ICON, CLEAR_ICON, SAVE_ICON } from "/js/icons.js";
import { notifySidePanelOpen, onlyOneSidePanelOpen, notifyGpxStoreChanged, onRoutePoint, onRouteEdit } from "/js/panels.js";
import { isLoggedIn } from "/js/auth.js";
import { wirePreview } from "/js/preview.js";
@@ -76,6 +76,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 };
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");
this._saveButton.addEventListener("click", () => this._save());
this._profileButton = this._panel.querySelector(".route-panel__profile");
@@ -402,6 +405,50 @@ export class RoutePanelControl {
return features.find((f) => f.geometry.type === "LineString")?.properties.id;
}
// "Saved point": a search over the library's points (GET /api/search,
// the "layers" source, nearest the map center first); a pick adds it.
_setupSavedPoints() {
const box = this._panel.querySelector(".route-panel__saved");
const input = box.querySelector("input");
const list = box.querySelector("ul");
let timer = null;
let request = 0;
this._panel.querySelector('[data-action="saved-point"]').addEventListener("click", () => {
box.hidden = !box.hidden;
if (!box.hidden) input.focus();
});
input.addEventListener("input", () => {
clearTimeout(timer);
timer = setTimeout(async () => {
const mine = ++request;
const center = this._map.getCenter();
const url = new URL("/api/search", window.location.origin);
url.search = new URLSearchParams({ q: input.value, sources: "layers", lat: center.lat, lng: center.lng });
let results = [];
try {
if (input.value.trim()) results = (await (await fetch(url)).json()).results;
} catch {}
if (mine !== request) return;
const points = results.filter(({ bbox }) => bbox && bbox[0] === bbox[2] && bbox[1] === bbox[3]);
list.replaceChildren(
...points.map(({ name, bbox, source_label: folder }) => {
const item = document.createElement("li");
const button = Object.assign(document.createElement("button"), { type: "button", textContent: name, title: folder });
button.addEventListener("click", () => {
this._addPoint(bbox.slice(0, 2), name);
box.hidden = true;
input.value = "";
list.replaceChildren();
});
item.appendChild(button);
return item;
}),
);
if (!points.length && input.value.trim()) list.replaceChildren(Object.assign(document.createElement("li"), { textContent: "No saved points found." }));
}, 250);
});
}
// Where the route needs a vignette or pays tolls, country by country.
_showCountries(countries) {
const rows = (countries || []).flatMap(({ code, motorway_km: motorway, toll_km: toll }) => {