Skip to content

Commit

Permalink
add dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Gab committed Dec 21, 2023
1 parent 8538f64 commit 09a0316
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/MainHead.astro
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const {
}
return window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
: "";
};
const isDark = getThemePreference() === "dark";
document.documentElement.classList[isDark ? "add" : "remove"]("theme-dark");
Expand All @@ -42,7 +42,7 @@ const {
// Watch the document element and persist user preference when it changes.
const observer = new MutationObserver(() => {
const isDark = document.documentElement.classList.contains("theme-dark");
localStorage.setItem("theme", isDark ? "dark" : "light");
localStorage.setItem("theme", isDark ? "dark" : "");
});
observer.observe(document.documentElement, {
attributes: true,
Expand Down
1 change: 1 addition & 0 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,5 @@ h5 {
.lg\:gap-48 {
gap: 12rem;
}

}

0 comments on commit 09a0316

Please sign in to comment.