FIX: dark mode is default now/Pressing enter

This commit is contained in:
Zakaria
2026-05-21 13:26:30 -04:00
parent 166eacdbfd
commit 08724192b3
4 changed files with 35 additions and 25 deletions
+12 -5
View File
@@ -1406,17 +1406,24 @@ function danceTiles(tiles) {
function restoreTheme() {
const selectedTheme = localStorage.getItem("selected-theme")
if (selectedTheme === "dark") {
document.body.classList.add("dark-theme")
themeButton.setAttribute("aria-label", "Switch to light mode")
}
const shouldUseDarkTheme = selectedTheme !== "light"
document.body.classList.toggle("dark-theme", shouldUseDarkTheme)
themeButton.setAttribute(
"aria-label",
shouldUseDarkTheme ? "Switch to light mode" : "Switch to dark mode"
)
}
function toggleTheme() {
function toggleTheme(event) {
document.body.classList.toggle("dark-theme")
const theme = document.body.classList.contains("dark-theme") ? "dark" : "light"
localStorage.setItem("selected-theme", theme)
themeButton.setAttribute("aria-label", theme === "dark" ? "Switch to light mode" : "Switch to dark mode")
if (event?.currentTarget instanceof HTMLElement) {
event.currentTarget.blur()
}
}
async function openStats() {