Skip to content

Commit

Permalink
fix: apply dark mode on body
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperorb committed Mar 23, 2024
1 parent c06b191 commit 7eb46ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/components/ui/DarkModeToggle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
const change = (event: Event) => {
const target = event.target as HTMLInputElement;
const body = browser ? document.querySelector('body') : null;
if (body) {
const element = browser ? document.querySelector('html') : null;
if (element) {
if (target.checked) {
body.setAttribute('data-dark-mode', 'true');
element.setAttribute('data-dark-mode', 'true');
} else {
body.removeAttribute('data-dark-mode');
element.removeAttribute('data-dark-mode');
}
}
};
Expand Down

0 comments on commit 7eb46ab

Please sign in to comment.