[feat](trx-frontend-http): lay the map filters out as a bar across the top
The filters were a 30rem column parked in the bottom-right corner, covering a third of the map they filter. Lay them out horizontally instead: one row per group -- label beside its control, thin rules between -- across the top of the map, spanning ~87% of its width at 1600px and wrapping to a second row as it narrows. It starts clear of Leaflet's zoom buttons and stops short of the corner controls, which stay outside it: the button that hides the filters cannot live inside the thing it hides. The bottom-left band legend keeps its place. The sentence explaining the two path toggles would have swallowed the bar, so it moves to their tooltips and is shown inline only in the stacked narrow-screen layout. Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -222,3 +222,62 @@ try {
|
||||
await retry.browser.close();
|
||||
await retryFixture.close();
|
||||
}
|
||||
|
||||
// The map's filter panel is a bar across the top of the map, not a window
|
||||
// sitting on it: it has to stay one or two rows tall, span most of the width,
|
||||
// and keep clear of the things that share the map's corners — Leaflet's zoom
|
||||
// buttons, the Fullscreen/Hide Filters controls, and the band legend. A panel
|
||||
// that grew a column would cover the map it filters.
|
||||
const mapFixture = await startWebFixture({ spectrum: true });
|
||||
const mapView = await startBrowser(chromium);
|
||||
try {
|
||||
for (const width of [1600, 1200]) {
|
||||
await mapView.page.setViewportSize({ width, height: 950 });
|
||||
await mapView.page.goto(`${mapFixture.origin}/map`, { waitUntil: "domcontentloaded" });
|
||||
await mapView.page.locator("#aprs-map .leaflet-pane").first().waitFor({ state: "attached" });
|
||||
await mapView.page.waitForTimeout(1200);
|
||||
|
||||
const bar = await mapView.page.evaluate(() => {
|
||||
const box = (element) => (element ? element.getBoundingClientRect() : null);
|
||||
const panel = document.querySelector(".map-overlay-panel");
|
||||
const stage = box(document.getElementById("map-stage"));
|
||||
const zoom = box(document.querySelector("#aprs-map .leaflet-control-zoom"));
|
||||
const corner = box(document.querySelector(".map-corner-controls"));
|
||||
const legend = box(document.getElementById("map-band-legend"));
|
||||
const panelBox = box(panel);
|
||||
const hits = (a, b) => !!a && !!b
|
||||
&& a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
|
||||
return {
|
||||
widthPct: Math.round((panelBox.width / stage.width) * 100),
|
||||
height: Math.round(panelBox.height),
|
||||
outsideStage: panelBox.right > stage.right + 1 || panelBox.bottom > stage.bottom + 1,
|
||||
hitsZoom: hits(panelBox, zoom),
|
||||
hitsCorner: hits(panelBox, corner),
|
||||
hitsLegend: hits(panelBox, legend),
|
||||
clipped: panel.scrollWidth > panel.clientWidth + 1 || panel.scrollHeight > panel.clientHeight + 1,
|
||||
};
|
||||
});
|
||||
assert.ok(bar.widthPct >= 70, `the filter bar covers ${bar.widthPct}% of the map at ${width}px`);
|
||||
assert.ok(bar.height <= 140, `the filter bar is ${bar.height}px tall at ${width}px, not a bar`);
|
||||
assert.equal(bar.outsideStage, false, `the filter bar runs off the map at ${width}px`);
|
||||
assert.equal(bar.hitsZoom, false, `the filter bar covers the zoom buttons at ${width}px`);
|
||||
assert.equal(bar.hitsCorner, false, `the filter bar covers the map controls at ${width}px`);
|
||||
assert.equal(bar.hitsLegend, false, `the filter bar covers the band legend at ${width}px`);
|
||||
assert.equal(bar.clipped, false, `the filter bar is clipping its own controls at ${width}px`);
|
||||
}
|
||||
|
||||
// Hiding it still works, and gives the whole map back.
|
||||
await mapView.page.locator("#map-overlay-toggle-btn").click();
|
||||
await mapView.page.waitForTimeout(400);
|
||||
const toggled = await mapView.page.evaluate(() => ({
|
||||
hidden: document.querySelector(".map-overlay-panel").classList.contains("is-hidden"),
|
||||
label: document.getElementById("map-overlay-toggle-btn").textContent.trim(),
|
||||
}));
|
||||
assert.equal(toggled.hidden, true, "the filter bar stayed up after Hide Filters");
|
||||
assert.equal(toggled.label, "Show Filters", `the toggle still reads "${toggled.label}"`);
|
||||
|
||||
assert.deepEqual(mapView.runtimeErrors, []);
|
||||
} finally {
|
||||
await mapView.browser.close();
|
||||
await mapFixture.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user