Skip to content

Commit

Permalink
dhall-docs: dark mode - default to browser settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kukimik committed Apr 19, 2024
1 parent 43fa086 commit a312243
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dhall-docs/src/Dhall/data/assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const DARK_MODE_OPT = 'dark-mode'
const DARK_MODE_ACTIVE = 'dark-mode-active'
const DARK_MODE_INACTIVE = 'dark-mode-inactive'

if (localStorage.getItem(DARK_MODE_OPT) == DARK_MODE_ACTIVE) {
if (!localStorage.hasOwnProperty(DARK_MODE_OPT) && window.matchMedia('(prefers-color-scheme: dark)').matches
|| localStorage.getItem(DARK_MODE_OPT) == DARK_MODE_ACTIVE) {
document.documentElement.classList.add('dark-mode')
}

Expand Down

0 comments on commit a312243

Please sign in to comment.