Skip to content

Commit

Permalink
fix(theme): use stored preference to be the value of userPreference (
Browse files Browse the repository at this point in the history
…#1543)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
  • Loading branch information
zam157 and brc-dd committed Oct 27, 2022
1 parent b43d0d5 commit a7abf73
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/client/theme-default/components/VPSwitchAppearance.vue
Expand Up @@ -18,13 +18,13 @@ function useAppearance() {
const query = window.matchMedia('(prefers-color-scheme: dark)')
const classList = document.documentElement.classList
let userPreference =
localStorage.getItem(APPEARANCE_KEY) || site.value.appearance !== true
? site.value.appearance
: 'auto'
let userPreference = localStorage.getItem(APPEARANCE_KEY)
let isDark =
userPreference === 'auto' ? query.matches : userPreference === 'dark'
(site.value.appearance === 'dark' && userPreference == null) ||
(userPreference === 'auto' || userPreference == null
? query.matches
: userPreference === 'dark')
query.onchange = (e) => {
if (userPreference === 'auto') {
Expand Down

0 comments on commit a7abf73

Please sign in to comment.