Night mode (auto after sunset / on / off, one invert+dim filter for now), tracker drawn as a top-down vehicle rotated by its GNSS course with a heading-up tilted Navigate mode, side panels float over the map on phone width instead of squeezing it
CI / check (push) Successful in 36s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-11-23 15:03:58 +01:00
1 parent 0e5f79f8e4
commit 9148c9a411
5 files changed
+189 -17

No files matched your search

+28
View File
@@ -19,6 +19,7 @@ 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 { formatCoords, formatSunInfo, sunChartHtml } from "/js/sun.js";
import { getPosition } from "/vendor/suncalc/suncalc.js";
import { notifySidePanelOpen, onlyOneSidePanelOpen, setupSidePanelModes } from "/js/panels.js";
import { isLoggedIn } from "/js/auth.js";
import { DebugControl } from "/js/debug.js";
@@ -465,6 +466,33 @@ updateSun();
map.on("moveend", updateSun);
setInterval(updateSun, 60000);
// Night mode (html.night, style.css) so the screen doesn't glare in the
// car: "auto" follows the sun at the map center, or forced on/off — the
// topbar button cycles the three, remembered per device.
const NIGHT_MODES = { auto: ["◐", "Night mode: automatic (after sunset)"], on: ["☾", "Night mode: on"], off: ["☀", "Night mode: off"] };
const nightButton = document.querySelector(".topbar__night");
let nightMode = "auto";
try {
nightMode = localStorage.getItem("nightMode") || "auto";
} catch {}
const updateNight = () => {
const { lng, lat } = map.getCenter();
const dark = nightMode === "on" || (nightMode === "auto" && getPosition(new Date(), lat, lng).altitude < 0);
document.documentElement.classList.toggle("night", dark);
[nightButton.textContent, nightButton.title] = NIGHT_MODES[nightMode] || NIGHT_MODES.auto;
};
nightButton.addEventListener("click", () => {
const modes = Object.keys(NIGHT_MODES);
nightMode = modes[(modes.indexOf(nightMode) + 1) % modes.length];
try {
localStorage.setItem("nightMode", nightMode);
} catch {}
updateNight();
});
updateNight();
map.on("moveend", updateNight);
setInterval(updateNight, 60000);
const sidebar = document.getElementById("sidebar");
// Grouped into the TODO's planned 4-module menu (Explorer / Offline hub /