Skip to content

Commit a3b55de

Browse files
committed
fix
1 parent 7a9d5be commit a3b55de

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

components/Layout.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@ export function GradientBackground({ variant, className }) {
1616

1717
export default function Layout({ children }) {
1818
const setAppTheme = () => {
19-
const darkMode =
20-
window.matchMedia("(prefers-color-scheme: dark)").matches ||
21-
localStorage.getItem("theme") === "dark";
22-
23-
const lightMode =
24-
window.matchMedia("(prefers-color-scheme: light)").matches ||
25-
localStorage.getItem("theme") === "light";
19+
const darkMode = localStorage.getItem("theme") === "dark";
20+
const lightMode = localStorage.getItem("theme") === "light";
2621

2722
if (darkMode) {
2823
document.documentElement.classList.add("dark");
@@ -38,8 +33,10 @@ export default function Layout({ children }) {
3833
darkQuery.onchange = (e) => {
3934
if (e.matches) {
4035
document.documentElement.classList.add("dark");
36+
localStorage.setItem("theme", "dark");
4137
} else {
4238
document.documentElement.classList.remove("dark");
39+
localStorage.setItem("theme", "light");
4340
}
4441
};
4542
};

0 commit comments

Comments
 (0)