Skip to content

Commit aee2522

Browse files
committed
fix: actually fix theme problems
if local storage was lightmode, it didn't properlly go to light mode lol, and i missed the .matches
1 parent 8661051 commit aee2522

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

index.html

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
<title>jumpyjacko | Home</title>
88

99
<script>
10-
if (
11-
!("theme" in localStorage) &&
12-
window.matchMedia("(prefers-color-scheme: dark)")
13-
) {
14-
localStorage.theme = "dark";
10+
if (!("theme" in localStorage)) {
11+
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
12+
localStorage.theme = "dark";
13+
} else {
14+
localStorage.theme = "light";
15+
}
1516
}
17+
18+
document.documentElement.classList.toggle(
19+
"dark",
20+
localStorage.theme === "dark" ||
21+
(!("theme" in localStorage) &&
22+
window.matchMedia("(prefers-color-scheme: dark)").matches),
23+
);
1624
</script>
1725
</head>
1826
<body class="bg-cream text-midnight dark:bg-midnight dark:text-cream">

0 commit comments

Comments
 (0)