Fix error in theme switcher

This commit is contained in:
Simon Detheridge 2023-10-16 19:55:08 +01:00
parent ab61ad1a67
commit a84195497e
Signed by: simon
GPG Key ID: 38640971DA1E704E
3 changed files with 8 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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)
}