Skip to content

Commit

Permalink
Update theme.context.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ChurroC authored Mar 11, 2024
1 parent 1708c78 commit 12c9899
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/util/contexts/theme/theme.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) {
// Runs once on the client and uses reference to current theme to check if "system" and based of "prefers-color-scheme" add dark to body
useEffect(() => {
function themeChange({ matches }: MediaQueryListEventInit) {
if (matches && refTheme.current === "system") {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
if (refTheme.current === "system") {
if (matches) document.documentElement.classList.add("dark")
else document.documentElement.classList.remove("dark");
}
}

Expand Down

0 comments on commit 12c9899

Please sign in to comment.