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): dress the map's scale and attribution as our own panels
Elian Dorancf5e3b94a98f
diff --git a/apps/client/src/widgets/collections/geomap/MapToolbar.css b/apps/client/src/widgets/collections/geomap/MapToolbar.cssindex 0b3105e2d4..6d3f439583 100644--- a/apps/client/src/widgets/collections/geomap/MapToolbar.css+++ b/apps/client/src/widgets/collections/geomap/MapToolbar.css@@ -18,28 +18,20 @@}/*- * On a dark map the bar goes dark with it, whatever the app itself is wearing — a built-in dark style- * or one a note has said is dark (`#map:darkStyle`, see `useLayerData`). A pale bar over a dark map is- * a lamp standing in the corner of it: the eye goes to the bar rather than to what the bar is for.- *- * The colours are ones the app already keeps dark in both of its themes — what a tooltip is drawn in —- * so this follows the theme rather than setting up a second one beside it. The hairline and the hover- * are the dark surface's own, the theme's being settled against a background this bar no longer has:- * its light-theme border would ring a dark bar in white, and its hover would put dark text on a dark- * fill.+ * The bar is dressed in the set the map's furniture shares (see index.css, which is where a dark map+ * darkens it), handed over here under the names the shared bar reads.** Set on the bar rather than on the map, so that nothing else standing over the map is dressed for a* theme the reader did not choose — a marker's preview is the app's own note tooltip, and it belongs- * to the app.+ * to the app. The last pair is for whatever this bar comes to hold that stands for a choice in force+ * (see OverlayToolbar.css), which today is nothing.*/-.geo-map-container.dark .geo-map-toolbar {- --menu-background-color: var(--tooltip-background-color);- --menu-text-color: var(--tooltip-foreground-color);- --dropdown-border-color: rgb(255 255 255 / 15%);- --icon-button-hover-background: rgb(255 255 255 / 12%);- --icon-button-hover-color: var(--tooltip-foreground-color);- /* For whatever this bar comes to hold that stands for a choice in force (see OverlayToolbar.css),- which today is nothing. */- --active-item-background-color: rgb(255 255 255 / 22%);- --active-item-text-color: var(--tooltip-foreground-color);+.geo-map-container .geo-map-toolbar {+ --menu-background-color: var(--geo-map-panel-background);+ --menu-text-color: var(--geo-map-panel-text-color);+ --dropdown-border-color: var(--geo-map-panel-border-color);+ --icon-button-hover-background: var(--geo-map-panel-hover-background);+ --icon-button-hover-color: var(--geo-map-panel-hover-text-color);+ --active-item-background-color: var(--geo-map-panel-active-background);+ --active-item-text-color: var(--geo-map-panel-active-text-color);}diff --git a/apps/client/src/widgets/collections/geomap/index.css b/apps/client/src/widgets/collections/geomap/index.cssindex 6fd35b5d0c..acec8a97a2 100644--- a/apps/client/src/widgets/collections/geomap/index.css+++ b/apps/client/src/widgets/collections/geomap/index.css@@ -16,6 +16,30 @@agree, and matching the room the mind map gives its bars (see MindMap.css). */--geo-map-inset: 20px;+ /*+ * 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+ * app's menu surface, which is what every panel floating over content in Trilium is drawn on+ * (see OverlayToolbar.css); the map's furniture asks for it by these names, and the bar has them+ * handed to it under the names the shared component reads (see MapToolbar.css).+ *+ * Thinner than a menu's, though, and that is the whole of the difference: a menu is opened over a+ * page that is mostly one flat colour, where 85% of that colour over the rest of it is glass+ * enough. These stand over a picture. At the same fill the frosting behind them (see below) has+ * nothing left to show — on a dark map especially, where what little comes through is dark to+ * begin with — and a panel meant to look like glass reads as a chip of plastic laid on the map.+ * Two thirds of the fill leaves the streets under it as shapes rather than as detail, which is+ * what a frosted pane does, and still carries text at the size these are set in.+ */+ --geo-map-panel-fill: 66%;+ --geo-map-panel-background: color-mix(in srgb, var(--menu-background-color) var(--geo-map-panel-fill), transparent);+ --geo-map-panel-text-color: var(--menu-text-color);+ --geo-map-panel-border-color: var(--dropdown-border-color);+ --geo-map-panel-hover-background: var(--icon-button-hover-background);+ --geo-map-panel-hover-text-color: var(--hover-item-text-color);+ --geo-map-panel-active-background: var(--active-item-background-color);+ --geo-map-panel-active-text-color: var(--active-item-text-color);+height: 100%;overflow: hidden;@@ -32,6 +56,101 @@}}+/*+ * On a dark map everything standing over it goes dark too, whatever the app itself is wearing — a+ * built-in dark style or one a note has said is dark (`#map:darkStyle`, see `useLayerData`). A pale+ * panel over a dark map is a lamp standing in the corner of it: the eye goes to the panel rather+ * than to what the panel is for.+ *+ * The colours are ones the app already keeps dark in both of its themes — what a tooltip is drawn in+ * — so this follows the theme rather than setting up a second one beside it. The hairline and the+ * hover are the dark surface's own, the theme's being settled against a background these panels no+ * longer have: its light-theme border would ring a dark panel in white, and its hover would put dark+ * text on a dark fill.+ *+ * Only what we dress is dressed: a marker's preview is the app's own note tooltip, and it belongs to+ * the app rather than to the map, so it is left in the theme the reader chose.+ */+.geo-map-container.dark {+ --geo-map-panel-background: color-mix(in srgb, var(--tooltip-background-color) var(--geo-map-panel-fill), transparent);+ --geo-map-panel-text-color: var(--tooltip-foreground-color);+ --geo-map-panel-border-color: rgb(255 255 255 / 15%);+ --geo-map-panel-hover-background: rgb(255 255 255 / 12%);+ --geo-map-panel-hover-text-color: var(--tooltip-foreground-color);+ --geo-map-panel-active-background: rgb(255 255 255 / 22%);+ --geo-map-panel-active-text-color: var(--tooltip-foreground-color);+}++/*+ * MapLibre's own furniture, dressed as the bar opposite it is.+ *+ * It ships them as white boxes with hairlines of their own and nothing to switch: there is no dark+ * mode in maplibre-gl.css, only literal colours (the scale a white fill with a `#333` rule around+ * it, the attribution a flat white pill), so the only way for them to belong to the map they stand+ * on is to be dressed here. Selectors carry both of the control's own classes, which is what it+ * takes to outweigh MapLibre's `.maplibregl-ctrl-attrib.maplibregl-compact` without `!important`.+ */+.geo-map-container .maplibregl-ctrl.maplibregl-ctrl-scale,+.geo-map-container .maplibregl-ctrl.maplibregl-ctrl-attrib {+ background: var(--geo-map-panel-background);+ color: var(--geo-map-panel-text-color);+ border: 1px solid var(--geo-map-panel-border-color);+ border-radius: 8px;+ box-shadow: 0 2px 8px #0003;+ /* The frosting the bar opposite wears, which is a menu's (see OverlayToolbar.css). */+ backdrop-filter: var(--dropdown-backdrop-filter, blur(10px));+}++/* The scale is a ruler as much as a label: its width says what the distance is worth, so it keeps+ the room MapLibre gives its text rather than being squeezed into a chip. */+.geo-map-container .maplibregl-ctrl.maplibregl-ctrl-scale {+ padding: 1px 6px;+}++/* Folded into a corner, and unfolded there, the attribution is rounded further by MapLibre than our+ panels are (12px against 8px) — by rules as specific as the one above, so its corners are asked+ for once more with a class to spare. */+.geo-map-container .maplibregl-ctrl.maplibregl-ctrl-attrib.maplibregl-compact,+.geo-map-container .maplibregl-ctrl.maplibregl-ctrl-attrib.maplibregl-compact-show {+ border-radius: 8px;+}++/* The links are the attribution — every word of it but the separators — so they are the text rather+ than something coloured apart from it, and say they can be followed when pointed at. */+.geo-map-container .maplibregl-ctrl-attrib a {+ color: inherit;+}++.geo-map-container .maplibregl-ctrl-attrib a:hover {+ color: inherit;+ text-decoration: underline;+}++/*+ * The mark on the button that folds the attribution away, drawn as the mask of a shape filled with+ * the panel's own colour rather than as the picture MapLibre paints there.+ *+ * That picture is a black glyph baked into a data URI, so on a dark panel it is a black mark on a+ * dark ground with no way to recolour it — and inverting it would be a guess at which panels are+ * dark. Worn as a mask it takes whatever colour the panel is wearing, in either theme and on either+ * kind of map. The shape is MapLibre's own (BSD-3-Clause, © MapLibre contributors), the very one it+ * would have drawn.+ *+ * Named by four of its classes, which is what it takes to outweigh the faint black MapLibre washes+ * the button with while the attribution is unfolded — three classes of its own, and enough to leave+ * the mark filled with a colour that cannot be seen against anything.+ */+.geo-map-container .maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button {+ background-color: currentColor;+ background-image: none;+ -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");+ mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");+ -webkit-mask-position: center;+ mask-position: center;+ -webkit-mask-repeat: no-repeat;+ mask-repeat: no-repeat;+}+.geo-view.placing-note .geo-map-container {cursor: crosshair;}diff --git a/apps/client/src/widgets/react/OverlayToolbar.css b/apps/client/src/widgets/react/OverlayToolbar.cssindex 22bf8a271e..eccbfb9c86 100644--- a/apps/client/src/widgets/react/OverlayToolbar.css+++ b/apps/client/src/widgets/react/OverlayToolbar.css@@ -14,7 +14,10 @@border: 1px solid var(--dropdown-border-color);border-radius: 8px;box-shadow: 0 2px 8px #0003;- backdrop-filter: blur(10px);+ /* The frosting a menu is given, rather than a blur of this bar's own: the theme sets what glass+ looks like in the app (see shell.css), and a bar over a map is the one place it is looked+ through at something with colour in it. A plain blur where a theme names none. */+ backdrop-filter: var(--dropdown-backdrop-filter, blur(10px));}/*diff --git a/apps/client/src/widgets/type_widgets/mind_map/NodePanel.css b/apps/client/src/widgets/type_widgets/mind_map/NodePanel.cssindex dc1247b1f4..dec1df0a69 100644--- a/apps/client/src/widgets/type_widgets/mind_map/NodePanel.css+++ b/apps/client/src/widgets/type_widgets/mind_map/NodePanel.css@@ -24,7 +24,8 @@border: 1px solid var(--dropdown-border-color);border-radius: 8px;box-shadow: 0 2px 8px #0003;- backdrop-filter: blur(10px);+ /* The frosting the bars beside it wear, which is a menu's (see OverlayToolbar.css). */+ backdrop-filter: var(--dropdown-backdrop-filter, blur(10px));}/* On a screen of its own the panel starts where the map does, there being no note buttons over it