1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

Move web to apps/web and bitwarden_license/bit-web

This commit is contained in:
Hinton
2022-06-02 11:55:37 +02:00
parent fb35805202
commit 02fe715903
619 changed files with 2 additions and 7 deletions

24
apps/web/src/theme.js Normal file
View File

@@ -0,0 +1,24 @@
// Set theme on page load
// This is done outside the Angular app to avoid a flash of unthemed content before it loads
// The defaultTheme is also set in the html itself to make sure that some theming is always applied
(function () {
const defaultTheme = "light";
const htmlEl = document.documentElement;
let theme = defaultTheme;
const globalState = window.localStorage.getItem("global");
if (globalState != null) {
const globalStateJson = JSON.parse(globalState);
if (globalStateJson != null && globalStateJson.theme != null) {
if (globalStateJson.theme.indexOf("system") > -1) {
theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
} else if (globalStateJson.theme.indexOf("dark") > -1) {
theme = "dark";
}
}
if (!htmlEl.classList.contains("theme_" + theme)) {
htmlEl.classList.remove("theme_" + defaultTheme);
htmlEl.classList.add("theme_" + theme);
}
}
})();