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): let the marker's pane stand as an island, the height of the map
Elian Doran20ae5970b75d
diff --git a/apps/client/src/widgets/collections/geomap/DetailPane.css b/apps/client/src/widgets/collections/geomap/DetailPane.cssindex 147347c228..13a94f7881 100644--- a/apps/client/src/widgets/collections/geomap/DetailPane.css+++ b/apps/client/src/widgets/collections/geomap/DetailPane.css@@ -1,10 +1,11 @@/*- * The pane stands against the trailing edge of the map, the full height of it.+ * The pane stands in the trailing corner of the map, held off its edges by as much as everything+ * else over the map is.*- * Flush rather than inset, and square rather than rounded: a card floating in the corner is what the- * mind map's panel is (see NodePanel.css), and it is the right shape there, where what it holds is a- * handful of controls for whatever is selected. This one holds a note, stands as tall as the map and- * is meant to be read from, so it reads as a wall of the map rather than as a sheet laid over it.+ * An island rather than a wall against the edge: every other thing standing over this map is one —+ * the bar of buttons, the scale and the attribution beside it, and the mind map's panel opposite+ * them all — and the map here is a widget inside a note rather than a screen of its own, so a pane+ * flush to its edge reads as cropping the map instead of standing over it.** The width has to agree with `PANE_WIDTH` in DetailPane.tsx, which is what the map is told to hold* a selected marker clear of.@@ -14,32 +15,31 @@}.geo-map-container .geo-detail-pane {- --overlay-panel-radius: 0;+ /*+ * The room kept at the foot of the map for the bar of buttons, which stands in this very corner+ * — its own room and as much again over it, so that the two are parted by the same air that+ * holds the bar off the edge. The mind map's panel reckons its own foot the same way.+ *+ * Standing clear of the bar rather than moving it aside: the bar belongs to the map and keeps+ * its corner whatever is opened over it, and a pane that ends above it needs no second file to+ * agree about how wide it is.+ */+ --detail-pane-foot: calc(var(--geo-map-inset) + var(--geo-map-toolbar-height) + var(--geo-map-inset));position: absolute;- top: 0;- bottom: 0;- inset-inline-end: 0;+ /* The height of the map, less what is kept at either end: a pane that stood only as tall as+ what it holds would be a different pane for every marker, growing and shrinking under the+ pointer as the reader moved from one to the next. What it holds scrolls within it instead+ (see OverlayPanel.css). */+ top: var(--geo-map-inset);+ bottom: var(--detail-pane-foot);+ inset-inline-end: var(--geo-map-inset);width: var(--geo-detail-pane-width);/* An embedded map may be narrower than the pane would like to be. */- max-width: 100%;+ max-width: calc(100% - 2 * var(--geo-map-inset));/* Above the canvas and clear of MapLibre's own control corners, which sit at 2 — the samereckoning the bar of buttons makes (see MapToolbar.css). */z-index: 3;- /* Only the inner edge is an edge at all; the other three are the map's own. */- border-block: none;- border-inline-end: none;-}--/*- * What the bar of buttons in the corner steps aside by, which is the whole of the pane while one is- * open and nothing at all otherwise (see MapToolbar.css, which reads it).- *- * Written against the pane being there rather than set as the pane opens, so that the map's own- * furniture answers to what is on it without the pane having to reach outside itself to say so.- */-.geo-map-container:has(.geo-detail-pane) {- --geo-pane-width: var(--geo-detail-pane-width);}/*diff --git a/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx b/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsxindex 45631bbc1b..9d77c16969 100644--- a/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx+++ b/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx@@ -119,7 +119,9 @@ describe("DetailPane", () => {map.setUnderPointer([ markerFeature(note, [ 2, 1 ]) ]);await act(async () => map.click());- expect(map.eased).toEqual([ { center: [ 2, 1 ], offset: [ -190, 0 ] } ]);+ // Half of what the pane reaches into the map: its own width, plus the air it is held off+ // the edge by.+ expect(map.eased).toEqual([ { center: [ 2, 1 ], offset: [ -200, 0 ] } ]);});/** An embedded map may be narrower than the pane wants to be, and then there is nowhere to move to. */diff --git a/apps/client/src/widgets/collections/geomap/DetailPane.tsx b/apps/client/src/widgets/collections/geomap/DetailPane.tsxindex a52d36a6f4..fc2925e69a 100644--- a/apps/client/src/widgets/collections/geomap/DetailPane.tsx+++ b/apps/client/src/widgets/collections/geomap/DetailPane.tsx@@ -97,6 +97,15 @@ export default function DetailPane({ notes, placing }: {*/const PANE_WIDTH = 380;+/** How far the pane is held off the edge it stands against, matching `--geo-map-inset` (index.css). */+const PANE_INSET = 20;++/**+ * How far into the map the pane reaches from that edge. The gap counts as covered: it is the pane's+ * own air, and a marker sitting in it reads as tucked behind the pane rather than beside it.+ */+const PANE_REACH = PANE_WIDTH + PANE_INSET;+/*** How far off its own centre the map has to hold a marker for the pane not to cover it.*@@ -109,12 +118,12 @@ const PANE_WIDTH = 380;function paneOffset(map: MapLibreGLMap): [number, number] {// A pane with the whole map under it — an embedded one narrower than the pane — leaves nowhere// to hold the marker clear of, so it is left where it is.- if (map.getContainer().clientWidth <= PANE_WIDTH) {+ if (map.getContainer().clientWidth <= PANE_REACH) {return [ 0, 0 ];}// The pane stands at the trailing edge, which is the left one where the app reads right to left.- const shift = PANE_WIDTH / 2;+ const shift = PANE_REACH / 2;return [ glob.isRtl ? shift : -shift, 0 ];}diff --git a/apps/client/src/widgets/collections/geomap/MapToolbar.css b/apps/client/src/widgets/collections/geomap/MapToolbar.cssindex a0a1648ad2..6d3f439583 100644--- a/apps/client/src/widgets/collections/geomap/MapToolbar.css+++ b/apps/client/src/widgets/collections/geomap/MapToolbar.css@@ -13,12 +13,8 @@*/.geo-map-container .geo-map-toolbar {bottom: var(--geo-map-inset);- /* Past whatever stands against that edge, which today is the detail pane and by default nothing- (see DetailPane.css, which is what sets it). The bar sliding clear as a pane opens is what- makes the pane read as a wall of the map rather than as something laid on top of it. */- inset-inline-end: calc(var(--geo-map-inset) + var(--geo-pane-width, 0px));+ inset-inline-end: var(--geo-map-inset);z-index: 3;- transition: inset-inline-end 150ms ease;}/*diff --git a/apps/client/src/widgets/collections/geomap/index.css b/apps/client/src/widgets/collections/geomap/index.cssindex acec8a97a2..b67034c3e5 100644--- a/apps/client/src/widgets/collections/geomap/index.css+++ b/apps/client/src/widgets/collections/geomap/index.css@@ -16,6 +16,11 @@agree, and matching the room the mind map gives its bars (see MindMap.css). */--geo-map-inset: 20px;+ /* How tall the bar of buttons in the corner stands, which is what anything else opened over that+ corner has to end above (see DetailPane.css). The mind map's bar is the same height, being the+ same bar (see MindMap.css). */+ --geo-map-toolbar-height: 42px;+/** What everything standing over the map is dressed in — our own bar and MapLibre's scale and* attribution alike, so that the three read as one set rather than as ours beside theirs. The