Fix error in theme switcher
This commit is contained in:
parent
ab61ad1a67
commit
a84195497e
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -18,6 +18,7 @@ function changeFavicon() {
|
||||
}
|
||||
|
||||
function changeTheme(useLight) {
|
||||
console.log({ useLight })
|
||||
document.documentElement.classList.remove('light-theme', 'dark-theme', 'has-light-text', 'has-dark-text')
|
||||
if (useLight) {
|
||||
document.documentElement.classList.add('light-theme', 'has-dark-text')
|
||||
@ -28,7 +29,7 @@ function changeTheme(useLight) {
|
||||
if (window.localStorage) {
|
||||
window.localStorage.setItem(
|
||||
"lightTheme",
|
||||
useLight)
|
||||
useLight ? "light" : "dark")
|
||||
}
|
||||
|
||||
changeFavicon()
|
||||
@ -38,8 +39,10 @@ themeToggle.addEventListener("click", () => {
|
||||
changeTheme(document.documentElement.classList.contains('dark-theme'))
|
||||
});
|
||||
|
||||
if (localTheme instanceof Boolean) {
|
||||
changeTheme(localTheme)
|
||||
console.log({ localTheme, isOSLight })
|
||||
|
||||
if (localTheme === "light") {
|
||||
changeTheme(true)
|
||||
} else {
|
||||
changeTheme(isOSLight)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user