fix(theme): use stored preference to be the value of `userPreference` (#1543)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/1547/head
WT 2 years ago committed by GitHub
parent b43d0d5d2c
commit a7abf73e43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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') {

Loading…
Cancel
Save