chore: initialize project
Some checks failed
Deploy monie-landing (kaniko) / build-and-deploy (push) Failing after 1m46s
Some checks failed
Deploy monie-landing (kaniko) / build-and-deploy (push) Failing after 1m46s
This commit is contained in:
23
public/theme-init.js
Normal file
23
public/theme-init.js
Normal file
@@ -0,0 +1,23 @@
|
||||
(function () {
|
||||
try {
|
||||
var stored = window.localStorage.getItem("theme");
|
||||
var mode =
|
||||
stored === "light" || stored === "dark" || stored === "auto"
|
||||
? stored
|
||||
: "auto";
|
||||
var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
var resolved = mode === "auto" ? (prefersDark ? "dark" : "light") : mode;
|
||||
var root = document.documentElement;
|
||||
|
||||
root.classList.remove("light", "dark");
|
||||
root.classList.add(resolved);
|
||||
|
||||
if (mode === "auto") {
|
||||
root.removeAttribute("data-theme");
|
||||
} else {
|
||||
root.setAttribute("data-theme", mode);
|
||||
}
|
||||
|
||||
root.style.colorScheme = resolved;
|
||||
} catch {}
|
||||
})();
|
||||
Reference in New Issue
Block a user