Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client/overlay): let the controls dress themselves, not the theme

Elian Doran0dc9063a2285
diff --git a/apps/client/src/stylesheets/theme-next/forms.css b/apps/client/src/stylesheets/theme-next/forms.css
index b73b8109f9..98d8f23ca2 100644
--- a/apps/client/src/stylesheets/theme-next/forms.css
+++ b/apps/client/src/stylesheets/theme-next/forms.css
@@ -289,82 +289,6 @@ button.tn-low-profile:hover {
box-shadow: 1px 1px 1px var(--button-group-active-button-shadow-color);
}
-/*
- * Overlay buttons
- */
-
-:where(.tn-overlay-control-group) {
- display: flex;
- align-items: stretch;
- gap: 0px;
- border-radius: var(--overlay-button-border-radius);
- border-right: 1px solid var(--overlay-button-shadow-color);
- border-bottom: 1px solid var(--overlay-button-shadow-color);
-
- :where(button) {
- display: inline-flex;
- justify-content: center;
- align-items: center;
- border: none;
- margin: 0;
- backdrop-filter: var(--overlay-button-backdrop-filter);
- background-color: var(--overlay-button-background);
- color: var(--overlay-button-color);
-
- &:not(:disabled):hover {
- background-color: var(--opaque-icon-button-hover-background-color);
- color: var(--opaque-icon-button-hover-color);
- }
-
- /* A button standing for a choice in force is shown held down — the geo map's + while the
- map is armed for a placement. Held through a hover as well, so that pointing at the one
- already chosen does not lower it. */
- &.active,
- &.active:not(:disabled):hover {
- background-color: var(--active-item-background-color);
- color: var(--active-item-text-color);
- }
-
- &.tn-overlay-icon-button {
- height: var(--overlay-button-height);
- width: 32px;
- font-size: var(--overlay-button-icon-size);
-
- &:active {
- font-size: calc(var(--overlay-button-icon-size) * .85);
- }
- }
-
- &.tn-overlay-text-button {
- height: var(--overlay-button-height);
- min-width: 50px;
- font-size: var(--overlay-button-text-size);
- }
-
- &:first-child {
- --_start-border-radius: var(--overlay-button-border-radius);
- }
-
- &:last-child {
- --_end-border-radius: var(--overlay-button-border-radius);
- }
-
- /* Reboot sets `button { border-radius: 0 }` (specificity 0,0,1), so the rounding must live on
- these end selectors (0,1,0) to out-specify it; middle buttons keep Reboot's square corners. */
- &:first-child,
- &:last-child {
- border-radius: var(--_start-border-radius, 0) var(--_end-border-radius, 0) var(--_end-border-radius, 0) var(--_start-border-radius, 0);
- }
-
- /* A button that would do nothing says as much rather than merely failing to answer. */
- &:disabled {
- opacity: .4;
- pointer-events: none;
- }
-
- }
-}
-
/*
* Input boxes
*/
diff --git a/apps/client/src/widgets/collections/geomap/EditToolbar.css b/apps/client/src/widgets/collections/geomap/EditToolbar.css
index b446fd62c6..46194bad54 100644
--- a/apps/client/src/widgets/collections/geomap/EditToolbar.css
+++ b/apps/client/src/widgets/collections/geomap/EditToolbar.css
@@ -1,11 +1,3 @@
-/*
- * The editing group stands in the middle of the map's foot — the one stretch of edge left free, the
- * corners being spoken for (see EditToolbar.tsx). That is all it has to name (see `placement` on
- * OverlayControlGroup, which is also where the centring itself lives); the room it is held off the
- * edges by, the layer it stands on and the palette it wears are handed to every group over this map
- * at once, in index.css.
- */
-
/* The + speaks in words as well as the glyph, so it is given the room a sentence needs and a seam
between the two — the glyph at the size its icon-button neighbours are drawn at. */
.geo-map-container .geo-edit-toolbar .geo-add-marker-button {
diff --git a/apps/client/src/widgets/collections/geomap/MapToolbar.css b/apps/client/src/widgets/collections/geomap/MapToolbar.css
index 9425a0256d..af42428efb 100644
--- a/apps/client/src/widgets/collections/geomap/MapToolbar.css
+++ b/apps/client/src/widgets/collections/geomap/MapToolbar.css
@@ -1,14 +1,3 @@
-/*
- * The controls stand in the bottom corner, where every other set of zoom controls floating over
- * content in the app stands — the image viewer's, whose control group this is — rather than in the
- * top corner MapLibre keeps its zoom buttons in. The corner is the map's to give: its attribution
- * has been moved to the foot of the other side, beside the scale (see map.tsx).
- *
- * That corner is all the group has to name (see `placement` on OverlayControlGroup); the room it is
- * held off the edges by, the layer it stands on and the palette it is dressed in are handed to every
- * group over this map at once, in index.css.
- */
-
/* The tilt wears text — 3D or 2D, a word the icon set has no glyph for — but it is one action, so
it keeps an icon button's width rather than the readout's roomier chip. */
.geo-map-container .geo-map-toolbar .geo-map-tilt-button {
diff --git a/apps/client/src/widgets/collections/geomap/MapToolbar.tsx b/apps/client/src/widgets/collections/geomap/MapToolbar.tsx
index 13faed1305..77ebc2cfed 100644
--- a/apps/client/src/widgets/collections/geomap/MapToolbar.tsx
+++ b/apps/client/src/widgets/collections/geomap/MapToolbar.tsx
@@ -21,6 +21,11 @@ import { ParentMap, useMapPitch } from "./map";
* 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.
*
+ * In the foot corner, where every other set of zoom controls floating over content in the app
+ * stands, rather than in the top corner MapLibre keeps its own zoom buttons in. The corner is the
+ * map's to give: its attribution has been moved to the foot of the other side, beside the scale
+ * (see map.tsx).
+ *
* 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
* remembered from the last press — MapLibre tilts for Ctrl and a drag as well, and a button that
diff --git a/apps/client/src/widgets/react/OverlayControlGroup.css b/apps/client/src/widgets/react/OverlayControlGroup.css
index 957b2ff0cf..cf46f5c93a 100644
--- a/apps/client/src/widgets/react/OverlayControlGroup.css
+++ b/apps/client/src/widgets/react/OverlayControlGroup.css
@@ -1,28 +1,109 @@
/*
- * Where a placed group stands over what it is put on: the corner it names (see `placement` in
- * OverlayControlGroup.tsx) against the nearest positioned ancestor, held off the edges by the room
- * the caller hands over. Said once here rather than at each of the nine sites that used to pin a
- * group of their own — the same three declarations for a centred one every time, and nothing to
- * catch a site that wrote the insets but forgot to take the group out of the flow.
+ * A run of buttons standing over content, joined edge to edge into one segmented chip: what it is
+ * made of, and where it stands.
*
- * The group's own dress — its surface, the seams between its buttons and the rounding of the two
- * ends — is the theme's to give (see the overlay buttons in theme-next/forms.css). Standing is not:
- * a group is pinned to its corner whatever it is wearing, so it is settled here, beside the
- * component that names the corner.
+ * Both are settled here rather than by the theme, so that a group is a chip in whatever theme the
+ * reader has chosen — the Next theme is one of several, and the others have never heard of an
+ * overlay button. Every value below is a name the theme may fill in, with what the app draws
+ * otherwise beside it; the Next theme fills them all in (see the overlay buttons in
+ * theme-next/base.css), and what it hands over is the whole difference in looks: a surface you can
+ * see through and the frosting behind it. Nothing here asks for either.
*
- * A group without a placement is untouched: laid out where it stands, for the caller that has
- * somewhere of its own to put it.
- *
- * What a group stands above is left to whoever puts it there. It is not about the group but about
- * the company it keeps — a map's own furniture, a note's floating buttons, an error card over a
- * preview — and every corner answers that differently.
+ * A group without a placement is untouched as to standing: laid out where it stands, for the caller
+ * that has somewhere of its own to put it. What a group stands above is left to whoever puts it
+ * there — it is not about the group but about the company it keeps (a map's own furniture, a note's
+ * floating buttons, an error card over a preview), and every corner answers that differently.
*/
-/* The room a placed group keeps from the edges it is pinned to, which is the room every overlay
- button in the app keeps (named by the theme, where one names it). At no specificity at all, so
- that whoever puts the group somewhere can say otherwise — per edge, where one edge differs. */
:where(.tn-overlay-control-group) {
+ /* The room a placed group keeps from the edges it is pinned to, which is the room every overlay
+ button in the app keeps. At no specificity at all, so that whoever puts the group somewhere
+ can say otherwise — per edge, where one edge differs. */
--overlay-group-inset: var(--overlay-button-inset, 10px);
+
+ /* What the chip is drawn with: the theme's names first, then the ones every theme has, then a
+ plain value for a theme that has neither. The surfaces are opaque here — a translucent one is
+ the Next theme's own answer, and it is only readable with the frosting that comes with it. */
+ --_overlay-radius: var(--overlay-button-border-radius, 6px);
+ --_overlay-height: var(--overlay-button-height, 28px);
+ --_overlay-surface: var(--overlay-button-background, var(--menu-background-color, #fff));
+ --_overlay-ink: var(--overlay-button-color, var(--menu-text-color, inherit));
+ --_overlay-hover-surface: var(--opaque-icon-button-hover-background-color, var(--more-accented-background-color, #ddd));
+ --_overlay-hover-ink: var(--opaque-icon-button-hover-color, var(--menu-text-color, inherit));
+ --_overlay-edge: var(--overlay-button-shadow-color, var(--main-border-color, #0000002e));
+
+ display: flex;
+ align-items: stretch;
+ gap: 0px;
+ border-radius: var(--_overlay-radius);
+ /* Two edges rather than four, which is a shadow said in the cheapest way there is: a chip over
+ content wants lifting off it, and the light in this app comes from the top leading corner. */
+ border-right: 1px solid var(--_overlay-edge);
+ border-bottom: 1px solid var(--_overlay-edge);
+
+ :where(button) {
+ display: inline-flex;
+ justify-content: center;
+ align-items: center;
+ border: none;
+ margin: 0;
+ /* Nothing to frost unless the theme asks for it, the surface below being opaque otherwise. */
+ backdrop-filter: var(--overlay-button-backdrop-filter, none);
+ background-color: var(--_overlay-surface);
+ color: var(--_overlay-ink);
+
+ &:not(:disabled):hover {
+ background-color: var(--_overlay-hover-surface);
+ color: var(--_overlay-hover-ink);
+ }
+
+ /* A button standing for a choice in force is shown held down — the geo map's + while the
+ map is armed for a placement. Held through a hover as well, so that pointing at the one
+ already chosen does not lower it. The fill the app marks a chosen thing with, which every
+ theme names. */
+ &.active,
+ &.active:not(:disabled):hover {
+ background-color: var(--active-item-background-color);
+ color: var(--active-item-text-color);
+ }
+
+ &.tn-overlay-icon-button {
+ height: var(--_overlay-height);
+ width: 32px;
+ font-size: var(--overlay-button-icon-size, 16px);
+
+ &:active {
+ font-size: calc(var(--overlay-button-icon-size, 16px) * .85);
+ }
+ }
+
+ &.tn-overlay-text-button {
+ height: var(--_overlay-height);
+ min-width: 50px;
+ font-size: var(--overlay-button-text-size, 14px);
+ }
+
+ &:first-child {
+ --_start-border-radius: var(--_overlay-radius);
+ }
+
+ &:last-child {
+ --_end-border-radius: var(--_overlay-radius);
+ }
+
+ /* Reboot sets `button { border-radius: 0 }` (specificity 0,0,1), so the rounding must live on
+ these end selectors (0,1,0) to out-specify it; middle buttons keep Reboot's square corners. */
+ &:first-child,
+ &:last-child {
+ border-radius: var(--_start-border-radius, 0) var(--_end-border-radius, 0) var(--_end-border-radius, 0) var(--_start-border-radius, 0);
+ }
+
+ /* A button that would do nothing says as much rather than merely failing to answer. */
+ &:disabled {
+ opacity: .4;
+ pointer-events: none;
+ }
+ }
}
.tn-overlay-control-group[data-placement] {
diff --git a/apps/client/src/widgets/react/OverlayToolbar.css b/apps/client/src/widgets/react/OverlayToolbar.css
index eccbfb9c86..8aa80479d9 100644
--- a/apps/client/src/widgets/react/OverlayToolbar.css
+++ b/apps/client/src/widgets/react/OverlayToolbar.css
@@ -9,15 +9,16 @@
align-items: center;
gap: 4px;
padding: 4px;
- background: var(--menu-background-color);
- color: var(--menu-text-color);
- border: 1px solid var(--dropdown-border-color);
+ background: var(--menu-background-color, #fff);
+ color: var(--menu-text-color, inherit);
+ border: 1px solid var(--dropdown-border-color, var(--main-border-color, #0000002e));
border-radius: 8px;
box-shadow: 0 2px 8px #0003;
/* 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));
+ looks like in the app (see shell.css in theme-next, the one theme that sets it), and a bar
+ over a map is the one place it is looked through at something with colour in it. Nothing to
+ frost in a theme that names none: its menus are opaque, and so is this bar. */
+ backdrop-filter: var(--dropdown-backdrop-filter, none);
}
/*
@@ -37,6 +38,39 @@
color: inherit;
}
+/*
+ * What a tool button is otherwise given by the theme — its size, its rounding, how big the mark
+ * inside it is drawn and what a hover fills it with — said again here for the themes that give it
+ * nothing, which is every theme but Next (see the icon buttons in theme-next/forms.css).
+ *
+ * At a specificity below the theme's on purpose (`:where`), so that this is only ever what a bar
+ * falls back to: where the theme speaks, the theme wins, and these buttons go on looking like the
+ * icon buttons the rest of that theme is made of.
+ */
+.tn-overlay-toolbar :where(.tn-tool-button) {
+ width: var(--icon-button-size, 32px);
+ height: var(--icon-button-size, 32px);
+ border: none;
+ border-radius: 8px;
+ padding: 0;
+ background: transparent;
+}
+
+.tn-overlay-toolbar :where(.tn-tool-button)::before {
+ display: block;
+ line-height: 1;
+ font-size: calc(var(--icon-button-size, 32px) * var(--icon-button-icon-ratio, 0.65));
+}
+
+.tn-overlay-toolbar :where(.tn-tool-button):hover {
+ background: var(--icon-button-hover-background, var(--more-accented-background-color, #ddd));
+ color: var(--icon-button-hover-color, var(--menu-text-color, inherit));
+}
+
+.tn-overlay-toolbar :where(.tn-tool-button):active::before {
+ transform: scale(0.85);
+}
+
/* A button that would do nothing says as much rather than merely failing to answer. */
.tn-overlay-toolbar .tn-tool-button:disabled {
opacity: .4;