Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
style(geomap): take the zoom readout off the controls
Elian Doran3e9570bd4ef8
diff --git a/apps/client/src/stylesheets/theme-next/forms.css b/apps/client/src/stylesheets/theme-next/forms.cssindex 91021abc1e..4cee121b77 100644--- a/apps/client/src/stylesheets/theme-next/forms.css+++ b/apps/client/src/stylesheets/theme-next/forms.css@@ -307,13 +307,6 @@ button.tn-low-profile:hover {pointer-events: none;}- /* A readout standing among the buttons — a zoom level, a scale — disabled only to stand- inert on the group's surface. It is not a refused action, and does not wear the refused- look. */- &.tn-overlay-readout:disabled {- opacity: 1;- }-}}diff --git a/apps/client/src/widgets/collections/geomap/MapToolbar.spec.tsx b/apps/client/src/widgets/collections/geomap/MapToolbar.spec.tsxindex b1ed894975..c22eeae729 100644--- a/apps/client/src/widgets/collections/geomap/MapToolbar.spec.tsx+++ b/apps/client/src/widgets/collections/geomap/MapToolbar.spec.tsx@@ -2,8 +2,8 @@* The controls over a geo map, which used to be MapLibre's own — white boxes on a map that may well* be dark, dressed in neither Trilium's buttons nor its colors. What is checked here is what they* did for us: the two steps, a step that would carry the map past either end of the range it is- * allowed being refused rather than merely doing nothing, the readout between the steps saying how- * close in the map is, and the screen being given and taken back.+ * allowed being refused rather than merely doing nothing, and the screen being given and taken+ * back.*/import type { Map as MapLibreGLMap } from "maplibre-gl";import { render } from "preact";@@ -18,9 +18,8 @@ import MapToolbar from "./MapToolbar";* screen at the end. */const TILT = 0;const ZOOM_OUT = 1;-const ZOOM_LEVEL = 2;-const ZOOM_IN = 3;-const FULLSCREEN = 4;+const ZOOM_IN = 2;+const FULLSCREEN = 3;/** A map that zooms and tilts, says so, and stands somewhere — all these controls ask of one. */function fakeMap({ zoom = 5, minZoom = 2, maxZoom = 22, pitch = 0 } = {}) {@@ -108,7 +107,6 @@ describe("geo map MapToolbar", () => {expect(buttons(container).map((button) => button.className)).toEqual([expect.stringContaining("geo-map-tilt-button"),expect.stringContaining("bx-minus-circle"),- expect.stringContaining("tn-overlay-text-button"),expect.stringContaining("bx-plus-circle"),expect.stringContaining("bx-fullscreen")]);@@ -159,19 +157,6 @@ describe("geo map MapToolbar", () => {expect(map.zoomOut).toHaveBeenCalled();});- it("says how close in the map is, in whole levels, following the wheel as much as the buttons", () => {- const map = fakeMap({ zoom: 5 });- const container = renderToolbar(map);- expect(buttons(container)[ZOOM_LEVEL].textContent).toBe("5");-- // As the wheel or a pinch would — landing between levels, which the readout does not split.- act(() => map.zoomTo(13.6));-- expect(buttons(container)[ZOOM_LEVEL].textContent).toBe("14");- // The readout is told, not asked: unlike the image viewer's, pressing it resets nothing.- expect(buttons(container)[ZOOM_LEVEL].disabled).toBe(true);- });-it("disables the step that would carry the map past the range it is allowed", () => {const atTheTop = renderToolbar(fakeMap({ zoom: 22 }));expect(buttons(atTheTop)[ZOOM_IN].disabled).toBe(true);diff --git a/apps/client/src/widgets/collections/geomap/MapToolbar.tsx b/apps/client/src/widgets/collections/geomap/MapToolbar.tsxindex 5e9ade4875..a9143b5e81 100644--- a/apps/client/src/widgets/collections/geomap/MapToolbar.tsx+++ b/apps/client/src/widgets/collections/geomap/MapToolbar.tsx@@ -15,9 +15,9 @@ import { ParentMap } from "./map";* `FullscreenControl`), dressed in neither Trilium's buttons nor Trilium's colors — a white box with* hairline-separated squares in it, on a map that may well be dark. What they do is done here* instead, on the control group the image viewer's zoom buttons stand on (`tn-overlay-control-group`,- * see {@link ImageViewer}): a step out, a step in, and between them a readout saying how close in- * the map is. The readout only says it — a map has no fitted view to be reset to the way an image- * has, and the whole world is a place worth going back to only rarely.+ * see {@link ImageViewer}). No readout between the steps, though: a map's zoom level is a number+ * out of the cartographer's toolbox, not the reader's, and a map has no fitted view a readout+ * could offer back the way an image has.** At the group's leading end stands the tilt, after Google Maps's own button: 3D leans the view* over, 2D lays it flat again. Which of the two it offers is read off the view itself rather than@@ -87,18 +87,6 @@ export default function MapToolbar() {disabled={current <= map.getMinZoom()}onClick={() => map.zoomOut()}/>- {/* The readout is told, not asked: the image viewer's presses this to go back to the- fitted view, but a map has no such view to offer — so it only says where between the- ends the zoom stands, whole levels being all anyone does anything with. Disabled- rather than a plain span so it stays a child the group's styling knows; the refused- look is taken off it by `tn-overlay-readout` (see theme-next/forms.css). */}- <button- type="button"- className="tn-overlay-text-button tn-overlay-readout geo-map-zoom-level"- disabled- >- {Math.round(current)}- </button><buttonref={zoomInRef}type="button"@@ -123,13 +111,12 @@ export default function MapToolbar() {/*** How close in the map is drawn, followed as it changes — by these buttons, by the wheel, or by the- * view being restored. Read for the readout between the steps, and for whether there is any room- * left to zoom, which is what leaves a button that would do nothing disabled instead of idle:- * MapLibre clamps a step past either end silently.+ * view being restored. What it is read for is whether there is any room left to zoom, which is what+ * leaves a button that would do nothing disabled instead of idle: MapLibre clamps a step past+ * either end silently.*- * `zoom` rather than `zoomend`, so that the readout counts through the animated step rather than- * jumping at its end, and a button reaching the end of the range is disabled as the map arrives- * there rather than a moment later.+ * `zoom` rather than `zoomend`, so that a button reaching the end of the range is disabled as the+ * map arrives there rather than a moment later — the two steps are animated.*/function useMapZoom(map: MapLibreGLMap | null) {const [ zoom, setZoom ] = useState<number | null>(null);