Skip to content

Build your personal knowledge base with Trilium Notes

client/adaptive colors: fix some issues

Adorian Doran33bdf3b01d46
diff --git a/apps/client/src/services/adaptive_colors.spec.ts b/apps/client/src/services/adaptive_colors.spec.ts
index fb7338583b..0efc6870fb 100644
--- a/apps/client/src/services/adaptive_colors.spec.ts
+++ b/apps/client/src/services/adaptive_colors.spec.ts
@@ -26,8 +26,13 @@ describe("readAdaptiveColorBands", () => {
it("finds a limit for every variable in style.css, set to its default", () => {
const pattern = /--adaptive-([a-z-]+?)-(light|dark)-([a-z-]+):\s*([^;]+);/g;
- const variables = [ ...styleCss.matchAll(pattern) ];
+ // Themes load before style.css, so only a zero-specificity block lets their `:root` win.
+ const defaults = [ ...styleCss.matchAll(/:where\(:root\)\s*\{([^}]*)\}/g) ]
+ .map(([ , block ]) => block)
+ .join("\n");
+ const variables = [ ...defaults.matchAll(pattern) ];
expect(variables).toHaveLength(16);
+ expect([ ...styleCss.matchAll(pattern) ]).toHaveLength(16);
for (const [ , role, theme, bound, value ] of variables) {
const field = BOUNDS[bound as keyof typeof BOUNDS];
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index b1c1f034e7..807fe0e5b1 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -33,6 +33,12 @@
--tree-item-light-theme-max-color-lightness: 50;
--tree-item-dark-theme-min-color-lightness: 75;
+ /* Picks the half of the light-dark() text colors that matches the theme. */
+ color-scheme: var(--theme-style);
+}
+
+/* Zero specificity, so that a theme's :root wins although themes load before this file. */
+:where(:root) {
/* Adaptive font color limits */
--adaptive-text-light-max-lightness: 40;
--adaptive-text-light-max-chroma: none;
@@ -56,9 +62,6 @@
--adaptive-table-background-light-max-chroma: 20;
--adaptive-table-background-dark-max-lightness: 30;
--adaptive-table-background-dark-max-chroma: 30;
-
- /* Picks the half of the light-dark() text colors that matches the theme. */
- color-scheme: var(--theme-style);
}
body#trilium-app.motion-disabled *,