Skip to content

Commit

Permalink
Check actual .matches result with matchMedia calls
Browse files Browse the repository at this point in the history
Fixes #211
  • Loading branch information
philwebb committed Feb 28, 2024
1 parent 1ddb7d8 commit 280a584
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/partials/head-styles.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
!function (theme, navWidth) {
if (theme === 'dark') document.documentElement.classList.add('dark-theme')
if (navWidth) document.documentElement.style.setProperty('--nav-width', `${navWidth}px`)
}(localStorage && localStorage.getItem('theme') || (matchMedia('(prefers-color-scheme: dark)') && 'dark'),
}(localStorage && localStorage.getItem('theme') || (matchMedia('(prefers-color-scheme: dark)')?.matches && 'dark'),
localStorage && localStorage.getItem('nav-width'))
</script>
<link rel="stylesheet" href="{{{uiRootPath}}}/css/site.css">
Expand Down
2 changes: 1 addition & 1 deletion src/partials/header-content.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,5 @@
if (theme === 'dark') {
document.getElementById('switch-theme-checkbox').parentElement.classList.add('active')
}
}(localStorage && localStorage.getItem('theme') || (matchMedia('(prefers-color-scheme: dark)') && 'dark'))
}(localStorage && localStorage.getItem('theme') || (matchMedia('(prefers-color-scheme: dark)')?.matches && 'dark'))
</script>

0 comments on commit 280a584

Please sign in to comment.