Skip to content

Commit

Permalink
add support for prefers-color-scheme: dark
Browse files Browse the repository at this point in the history
  • Loading branch information
ar363 committed May 19, 2021
1 parent 336a2c7 commit 4b8c765
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion _includes/layouts/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
})
}
if (localStorage.prefsDark === 'true') {
if (
localStorage.prefsDark === 'true' ||
(
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches &&
localStorage.prefsDark !== 'false')
) {
document.body.classList.add('dark')
changeDarkToggleBtnIcon()
}
Expand Down

1 comment on commit 4b8c765

@vercel
Copy link

@vercel vercel bot commented on 4b8c765 May 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.