File size: 474 Bytes
4dae10f 7173f4f 4dae10f 7173f4f 4dae10f 7173f4f 4dae10f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
export function switchTheme() {
const { classList } = document.querySelector("html") as HTMLElement;
const metaTheme = document.querySelector('meta[name="theme-color"]') as HTMLMetaElement;
if (classList.contains("dark")) {
classList.remove("dark");
metaTheme.setAttribute("content", "rgb(249, 250, 251)");
localStorage.theme = "light";
} else {
classList.add("dark");
metaTheme.setAttribute("content", "rgb(26, 36, 50)");
localStorage.theme = "dark";
}
}
|