Fixed first time theme change from dark mode
If the theme is detected as dark, the first click on the toggle theme button will now change to light mode. Preveously no change would occur, since it would switch from default dark to force dark mode.
This commit is contained in:
parent
345c1cb020
commit
de360c4ca4
1 changed files with 7 additions and 1 deletions
|
@ -27,8 +27,14 @@ function detectOSColorTheme() {
|
||||||
function switchTheme(e) {
|
function switchTheme(e) {
|
||||||
if (chosenThemeIsDark) {
|
if (chosenThemeIsDark) {
|
||||||
localStorage.setItem("theme", "light");
|
localStorage.setItem("theme", "light");
|
||||||
} else {
|
} else if (chosenThemeIsLight) {
|
||||||
localStorage.setItem("theme", "dark");
|
localStorage.setItem("theme", "dark");
|
||||||
|
} else {
|
||||||
|
if (document.documentElement.getAttribute("data-theme") == "dark") {
|
||||||
|
localStorage.setItem("theme", "light");
|
||||||
|
} else {
|
||||||
|
localStorage.setItem("theme", "dark");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
detectOSColorTheme();
|
detectOSColorTheme();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue