From 53f0c5d6ee21f5280bd15483ab852806024f4312 Mon Sep 17 00:00:00 2001 From: Maarten Breddels Date: Tue, 6 Feb 2024 11:54:25 +0100 Subject: [PATCH] Update Themes.js --- js/src/Themes.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/src/Themes.js b/js/src/Themes.js index 955b3222..8ae47018 100644 --- a/js/src/Themes.js +++ b/js/src/Themes.js @@ -35,7 +35,7 @@ export class ThemeModel extends WidgetModel { } }, this); } - + if (this.get("dark") !== null) { vuetify.framework.theme.dark = this.get("dark"); } else if (document.body.dataset.jpThemeLight) { @@ -50,9 +50,18 @@ export class ThemeModel extends WidgetModel { } else if (document.body.classList.contains("theme-light")) { this.set("dark", false); this.save_changes(); + } else if(window.Jupyter) { + this.set("dark", false); + this.save_changes(); + } else { + // e.g. solara + let osPrefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches + this.set("dark_jlab", osPrefersDark); + this.save_changes(); } this.on("change:dark", () => { vuetify.framework.theme.dark = this.get("dark"); + // TODO: call the same code as in the constructor }); } }