feat(regions): label the map pins and link them to the region list
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m17s
ci / test (pull_request) Successful in 12m34s
ci / build (pull_request) Canceled after 4m21s
ci / image (pull_request) Canceled after 0s

Pins carry the region's name, turn dark when the region is selected and
show a green dot while a checker of the region is live. Hovering a pin
highlights its row in the list and the other way round, and a region
ticked in the list pans into view. Scrolling the page no longer zooms
the map, and the attribution stays compact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-28 20:31:11 +01:00
1 parent 3562f8224e
commit 6c246b145f
6 files changed
+92 -31

No files matched your search

+44 -13
View File
@@ -119,23 +119,54 @@
}
}
/* Region maps: a dot per region, filled when it is selected and grey
when no checker of the region is live. */
.region-marker {
width: 14px;
height: 14px;
padding: 0;
border: 2px solid var(--color-ink);
/* Region maps: a labelled pin per region, filled when it is selected;
its dot is green while a checker of the region is live. */
.region-pin {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 3px 9px 3px 5px;
border: 1px solid var(--color-rule);
border-radius: 9999px;
background: var(--color-paper);
color: var(--color-ink);
font: 500 11px/1.3 var(--font-sans);
white-space: nowrap;
cursor: pointer;
box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
transition: background-color 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.region-marker.is-checked { background: var(--color-ink); }
.region-marker[data-live="0"] { border-color: var(--color-unknown); }
.region-marker.is-checked[data-live="0"] { background: var(--color-unknown); }
.region-marker.is-pick {
border-color: var(--color-down);
.region-pin-dot {
flex: none;
width: 8px;
height: 8px;
border-radius: 9999px;
background: var(--color-unknown);
box-shadow: 0 0 0 2px var(--color-paper);
}
.region-pin:not([data-live="0"]) .region-pin-dot { background: var(--color-up); }
.region-pin.is-checked {
border-color: var(--color-ink);
background: var(--color-ink);
color: var(--color-paper);
}
.region-pin.is-checked .region-pin-dot { box-shadow: 0 0 0 2px var(--color-ink); }
.maplibregl-marker.is-hover,
.maplibregl-marker:hover { z-index: 3; }
.is-hover > .region-pin,
.region-pin:hover {
transform: scale(1.1);
box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
}
.region-pin:focus-visible { outline: 2px solid var(--color-maintenance); outline-offset: 2px; }
.region-pick {
width: 14px;
height: 14px;
border: 2px solid var(--color-paper);
border-radius: 9999px;
background: var(--color-down);
cursor: default;
box-shadow: 0 1px 4px rgb(0 0 0 / 0.4);
}
.region-row { transition: background-color 0.15s; }
.region-row.is-hover { background: color-mix(in srgb, var(--color-ink) 7%, transparent); }
.region-map .maplibregl-ctrl-attrib { font-size: 10px; }
+36 -12
View File
@@ -647,7 +647,9 @@ for (const el of document.querySelectorAll("input[data-tz-default]")) {
box.hidden = false;
let map;
try {
map = new gl.Map({ container: box, style: mapStyle(server), center: [10.45, 51.17], zoom: 3 });
// Scrolling the page must not zoom the map; the buttons, a double
// click and pinching do.
map = new gl.Map({ container: box, style: mapStyle(server), center: [10.45, 51.17], zoom: 3, scrollZoom: false, attributionControl: { compact: true } });
} catch {
box.hidden = true;
return;
@@ -670,7 +672,8 @@ for (const el of document.querySelectorAll("input[data-tz-default]")) {
const points = items.map(lngLat);
if (points.length > 1) {
const bounds = points.slice(1).reduce((b, p) => b.extend(p), new gl.LngLatBounds(points[0], points[0]));
map.fitBounds(bounds, { padding: 40, maxZoom: 6, duration: 0 });
// Labels run to the right of their point.
map.fitBounds(bounds, { padding: { top: 40, bottom: 40, left: 40, right: 130 }, maxZoom: 6, duration: 0 });
} else if (points.length === 1) {
map.jumpTo({ center: points[0], zoom: 5 });
}
@@ -680,23 +683,44 @@ for (const el of document.querySelectorAll("input[data-tz-default]")) {
const selecting = box.dataset.regionMap === "select";
for (const item of items) {
const el = Object.assign(document.createElement("button"), { type: "button", className: "region-marker", title: item.dataset.name });
el.setAttribute("aria-label", item.dataset.name);
el.dataset.live = item.dataset.live;
new gl.Marker({ element: el }).setLngLat(lngLat(item)).addTo(map);
// The list row (a label or table row) and the marker light up together.
const row = item.closest("label, tr") ?? item;
row.classList.add("region-row");
const pin = Object.assign(document.createElement("button"), { type: "button", className: "region-pin", title: item.dataset.name });
pin.dataset.live = item.dataset.live;
pin.append(Object.assign(document.createElement("span"), { className: "region-pin-dot" }), Object.assign(document.createElement("span"), { textContent: item.dataset.name }));
const holder = document.createElement("div");
holder.append(pin);
const marker = new gl.Marker({ element: holder, anchor: "left", offset: [-8, 0] }).setLngLat(lngLat(item)).addTo(map);
const hover = (on) => {
holder.classList.toggle("is-hover", on);
row.classList.toggle("is-hover", on);
};
for (const el of [pin, row]) {
el.addEventListener("mouseenter", () => hover(true));
el.addEventListener("mouseleave", () => hover(false));
}
if (selecting) {
// The checkbox stays the source of truth; its change event keeps
// the form's own behaviour.
const paint = () => el.classList.toggle("is-checked", item.checked);
const paint = () => {
pin.classList.toggle("is-checked", item.checked);
row.classList.toggle("is-checked", item.checked);
pin.setAttribute("aria-pressed", String(item.checked));
};
paint();
item.addEventListener("change", paint);
el.addEventListener("click", (ev) => {
item.addEventListener("change", () => {
paint();
// A region ticked in the list comes into view on the map.
const bounds = map.getBounds?.();
if (item.checked && bounds && !bounds.contains(marker.getLngLat())) map.easeTo({ center: marker.getLngLat() });
});
pin.addEventListener("click", (ev) => {
ev.stopPropagation();
if (!item.matches(":disabled")) item.click();
});
} else {
el.classList.add("is-checked");
el.addEventListener("click", (ev) => {
pin.addEventListener("click", (ev) => {
ev.stopPropagation();
item.querySelector("[data-location-toggle]")?.click();
});
@@ -711,7 +735,7 @@ for (const el of document.querySelectorAll("input[data-tz-default]")) {
locationTarget.querySelector('[data-location-field="latitude"]').value = round(at.lat);
locationTarget.querySelector('[data-location-field="longitude"]').value = round(at.lng);
const point = [at.lng, at.lat];
pick ??= new gl.Marker({ element: Object.assign(document.createElement("div"), { className: "region-marker is-pick" }) })
pick ??= new gl.Marker({ element: Object.assign(document.createElement("div"), { className: "region-pick" }) })
.setLngLat(point)
.addTo(map);
pick.setLngLat(point);