Skip to content

Build your personal knowledge base with Trilium Notes

style/space usage: customize the colors of the treemap

Adorian Doran23a7ab578650
diff --git a/apps/client/src/stylesheets/theme-next-dark.css b/apps/client/src/stylesheets/theme-next-dark.css
index 99fd7e9fa8..e0ecc28e58 100644
--- a/apps/client/src/stylesheets/theme-next-dark.css
+++ b/apps/client/src/stylesheets/theme-next-dark.css
@@ -362,7 +362,23 @@
--task-checkbox-done-hover-color: #41b441;
--task-checkbox-unknown-state-color: #e95d5d;
--task-checkbox-glyph-color: white;
-
+
+ --space-usage-treemap-cell-background: var(--accented-background-color);
+ --space-usage-treemap-cell-icon-color: var(--muted-text-color);
+ --space-usage-treemap-cell-hover-color: var(--main-text-color);
+ --space-usage-treemap-cell-selected-color: var(--main-text-color);
+
+ --space-usage-treemap-cell-saturation: 35%;
+ --space-usage-treemap-cell-lightness: 40%;
+
+ --space-usage-treemap-icon-saturation: 60%;
+ --space-usage-treemap-icon-lightness: 70%;
+
+ --space-usage-treemap-hover-saturation: 60%;
+ --space-usage-treemap-hover-lightness: 70%;
+
+ --space-usage-treemap-selected-saturation: 70%;
+ --space-usage-treemap-selected-lightness: 70%;
}
/*
@@ -483,4 +499,4 @@ body.backdrop-effects-disabled :is(.calendar-event-popover, .geo-detail-pane).wi
:where(.ck-content .todo-list li[data-trilium-task-state]), .tn-task-checkbox {
--task-state-custom-hover-background-color: hsl(var(--task-state-hue), 50%, 60%);
-}
\ No newline at end of file
+}
diff --git a/apps/client/src/stylesheets/theme-next-light.css b/apps/client/src/stylesheets/theme-next-light.css
index 13b0d842fe..ba364a583c 100644
--- a/apps/client/src/stylesheets/theme-next-light.css
+++ b/apps/client/src/stylesheets/theme-next-light.css
@@ -362,6 +362,23 @@
--task-checkbox-unknown-state-color: #e95d5d;
--task-checkbox-glyph-color: white;
+ --space-usage-treemap-cell-background: var(--accented-background-color);
+ --space-usage-treemap-cell-icon-color: var(--muted-text-color);
+ --space-usage-treemap-cell-hover-color: var(--main-text-color);
+ --space-usage-treemap-cell-selected-color: var(--main-text-color);
+
+ --space-usage-treemap-cell-saturation: 65%;
+ --space-usage-treemap-cell-lightness: 80%;
+
+ --space-usage-treemap-icon-saturation: 50%;
+ --space-usage-treemap-icon-lightness: 40%;
+
+ --space-usage-treemap-hover-saturation: 70%;
+ --space-usage-treemap-hover-lightness: 35%;
+
+ --space-usage-treemap-selected-saturation: 35%;
+ --space-usage-treemap-selected-lightness: 50%;
+
}
#left-pane .fancytree-node.tinted,
diff --git a/apps/client/src/widgets/react/charts/Treemap.css b/apps/client/src/widgets/react/charts/Treemap.css
index 3f791c516a..e0bc6a7416 100644
--- a/apps/client/src/widgets/react/charts/Treemap.css
+++ b/apps/client/src/widgets/react/charts/Treemap.css
@@ -1,25 +1,39 @@
+/* Zero specificity, so a theme overrides these from its own `:root` block and never has to outweigh
+ this stylesheet. A cell's hue is its own and comes in inline with the geometry; a theme sets the
+ saturation and lightness struck from it, one set per color scheme. */
+:where(:root) {
+ /* A cell with no hue of its own: a bucket, standing for a crowd rather than a thing. */
+ --space-usage-treemap-cell-background: var(--accented-background-color);
+ --space-usage-treemap-cell-icon-color: var(--muted-text-color);
+ --space-usage-treemap-cell-hover-color: var(--main-text-color);
+ --space-usage-treemap-cell-selected-color: var(--main-text-color);
+
+ /* The cell's fill. */
+ --space-usage-treemap-cell-saturation: 50%;
+ --space-usage-treemap-cell-lightness: 78%;
+
+ /* The icon, pushed away from the fill it sits on so it stays legible against it. */
+ --space-usage-treemap-icon-saturation: 70%;
+ --space-usage-treemap-icon-lightness: 12%;
+
+ /* The hovered cell's ring: deep against the fill, and short of the chosen cell's full strength
+ so the two never read as the same state. */
+ --space-usage-treemap-hover-saturation: 60%;
+ --space-usage-treemap-hover-lightness: 35%;
+
+ /* The chosen cell's border: the hue at full strength, standing well clear of the fill. */
+ --space-usage-treemap-selected-saturation: 100%;
+ --space-usage-treemap-selected-lightness: 50%;
+}
+
.treemap {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
- /* The icon's tint is composed in HSL from the cell's own hue, so it reads as belonging to the
- cell rather than sitting on it. Kept as separate knobs a theme can retune — how saturated and
- how light the tint is, and how much of it survives the mix into the theme's text color — so
- the contrast can be adjusted without restating the derivation below. */
- --treemap-icon-saturation: 70%;
- --treemap-icon-lightness: 30%;
- --treemap-icon-tint: 40%;
-
- /* How a chosen cell's border is struck from the cell's own hue: that hue at full strength, which
- reads as belonging to the cell while standing well clear of the tint mixed into the theme's
- surface. Knobs of the same kind as the icon's above, for a theme to retune. */
- --treemap-selected-saturation: 100%;
- --treemap-selected-lightness: 50%;
-
- /* Painted through a variable, not a competing rule: consumers set `--treemap-cell-background`
- and never race this stylesheet's cascade position. */
+ /* Painted through a variable, not a competing rule: consumers set the cell's background and
+ never race this stylesheet's cascade position. */
/* The corner rounding is per cell — a cell rounds only the corners its block owns — so it is
computed with the geometry rather than set here. */
.treemap-cell {
@@ -27,36 +41,34 @@
position: absolute;
align-items: center;
justify-content: center;
- background: var(--treemap-cell-background, var(--accented-background-color));
+ background: var(--space-usage-treemap-cell-background);
overflow: hidden;
cursor: pointer;
}
- /* The group tint stays a mix into the theme's own surface, so the map keeps a coherent look
- under light and dark themes alike. */
+ /* Struck on the cell itself, where the hue is: a custom property resolves `var()` against the
+ element it is declared on, so these cannot be composed up in the root block. */
.treemap-cell.treemap-colored {
- --treemap-cell-background: color-mix(
- in srgb,
- var(--accented-background-color) 55%,
- hsl(var(--treemap-hue) 65% 55%) 45%
+ --space-usage-treemap-cell-background: hsl(
+ var(--treemap-hue)
+ var(--space-usage-treemap-cell-saturation)
+ var(--space-usage-treemap-cell-lightness)
);
}
/* Sized inline from the cell's geometry; the pointer belongs to the cell, so the glyph never
intercepts a hover, a click or a right-click meant for it. */
.treemap-cell-icon {
- color: var(--treemap-cell-icon-color, var(--muted-text-color));
+ color: var(--space-usage-treemap-cell-icon-color);
line-height: 1;
pointer-events: none;
}
- /* Same hue as the cell it sits in, pushed away from it in saturation and lightness, then mixed
- into the theme's text color so it stays legible under light and dark themes alike. */
.treemap-cell.treemap-colored > .treemap-cell-icon {
- --treemap-cell-icon-color: color-mix(
- in srgb,
- hsl(var(--treemap-hue) var(--treemap-icon-saturation) var(--treemap-icon-lightness)) var(--treemap-icon-tint),
- var(--main-text-color)
+ --space-usage-treemap-cell-icon-color: hsl(
+ var(--treemap-hue)
+ var(--space-usage-treemap-icon-saturation)
+ var(--space-usage-treemap-icon-lightness)
);
}
@@ -64,10 +76,18 @@
the next one is tapped, which would put a second ring on the map beside the chosen cell's. */
@media (hover: hover) {
.treemap-cell:hover {
- outline: 2px solid var(--main-text-color);
+ outline: 2px solid var(--space-usage-treemap-cell-hover-color);
outline-offset: -1px;
z-index: 1;
}
+
+ .treemap-cell.treemap-colored:hover {
+ --space-usage-treemap-cell-hover-color: hsl(
+ var(--treemap-hue)
+ var(--space-usage-treemap-hover-saturation)
+ var(--space-usage-treemap-hover-lightness)
+ );
+ }
}
/* The chosen cell, where identity is a selection rather than a hover. A border rather than an
@@ -76,14 +96,14 @@
map's inset is thinner than this. */
.treemap-cell.treemap-cell-selected {
z-index: 2;
- border: 3px solid var(--treemap-cell-selected-color, var(--main-text-color));
+ border: 3px solid var(--space-usage-treemap-cell-selected-color);
}
- /* The cell's own hue at full strength. A cell without one — a consumer's bucket, standing for a
- crowd rather than a thing — has no hue to strike this from and keeps the plain default above. */
.treemap-cell.treemap-colored.treemap-cell-selected {
- --treemap-cell-selected-color: hsl(
- var(--treemap-hue) var(--treemap-selected-saturation) var(--treemap-selected-lightness)
+ --space-usage-treemap-cell-selected-color: hsl(
+ var(--treemap-hue)
+ var(--space-usage-treemap-selected-saturation)
+ var(--space-usage-treemap-selected-lightness)
);
}
}
diff --git a/apps/client/src/widgets/type_widgets/space_usage/index.css b/apps/client/src/widgets/type_widgets/space_usage/index.css
index 6aadd0db42..85eaee095f 100644
--- a/apps/client/src/widgets/type_widgets/space_usage/index.css
+++ b/apps/client/src/widgets/type_widgets/space_usage/index.css
@@ -197,7 +197,7 @@ body.mobile {
.treemap-cell.treemap-cell-hidden,
.treemap-cell.treemap-cell-revisions,
.treemap-cell.treemap-cell-deleted {
- --treemap-cell-background: repeating-linear-gradient(
+ --space-usage-treemap-cell-background: repeating-linear-gradient(
-45deg,
var(--accented-background-color) 0 5px,
transparent 5px 10px