mirror of
https://github.com/ShaYmez/FreeSTAR-Status-Engine.git
synced 2026-06-02 22:24:52 -04:00
add darkmode detection
This commit is contained in:
@@ -53,3 +53,10 @@ function resetTheme() {
|
||||
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");
|
||||
});
|
||||
Reference in New Issue
Block a user