add darkmode detection
This commit is contained in:
parent
6cecff3cc3
commit
313c8b1db0
|
@ -53,3 +53,10 @@ function resetTheme() {
|
||||||
localStorage.removeItem("darkSwitch");
|
localStorage.removeItem("darkSwitch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
||||||
|
document.body.setAttribute("data-theme", "dark");
|
||||||
|
}
|
||||||
|
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (e) => {
|
||||||
|
const newColorScheme = e.matches ? document.body.setAttribute("data-theme", "dark") : document.body.removeAttribute("data-theme");
|
||||||
|
});
|
Loading…
Reference in New Issue