Skip to content

Commit

Permalink
made website detect user prefers color scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
ulughann committed Feb 18, 2024
1 parent b4ba63c commit 41e1d28
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/navbar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
---

<script lang="js">
if (
localStorage.theme === "dark" ||
(!("theme" in localStorage) &&
window.matchMedia("(prefers-color-scheme: dark)").matches)
) {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}

const HSThemeAppearance = {
init() {
const defaultTheme = "default";
Expand Down

0 comments on commit 41e1d28

Please sign in to comment.