Simplify auth UI with single toggle and headings

This commit is contained in:
2026-02-02 17:41:37 +01:00
parent 7a71e4831d
commit 30b0bf8481
3 changed files with 23 additions and 9 deletions

View File

@@ -53,9 +53,14 @@ function setAuthMode(mode) {
document.querySelectorAll(".auth-form").forEach(form => {
form.classList.toggle("hidden", form.dataset.mode !== mode);
});
document.querySelectorAll("[data-auth-tab]").forEach(btn => {
btn.classList.toggle("active", btn.dataset.authTab === mode);
});
const title = $("auth-title");
const toggleBtn = $("auth-toggle");
if (title) {
title.textContent = mode === "login" ? t("auth.loginHeading") : t("auth.registerHeading");
}
if (toggleBtn) {
toggleBtn.textContent = mode === "login" ? t("auth.switchToRegister") : t("auth.switchToLogin");
}
}
function clearUserState() {
@@ -299,9 +304,10 @@ function renderPhaseTitles() {
}
function setupHandlers() {
document.querySelectorAll("[data-auth-tab]").forEach(btn => {
btn.addEventListener("click", () => setAuthMode(btn.dataset.authTab));
});
const toggleAuth = $("auth-toggle");
if (toggleAuth) {
toggleAuth.addEventListener("click", () => setAuthMode(state.authMode === "login" ? "register" : "login"));
}
setAuthMode(state.authMode);
const langSelects = Array.from(document.querySelectorAll(".lang-select"));