From 8e3e76a52414d925af37ffe8253a779231b5e6a3 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 4 Jun 2026 04:50:42 +0000 Subject: [PATCH] feat(ux): Add loading states to auth forms - Implemented async loading states with try/finally to handleLogin and handleRegister in app.js - Disabled the button and changed text to "Loading..." during authentication requests - Added `.btn:disabled` CSS rule for visual feedback - Appended learning to `.Jules/palette.md` Co-authored-by: singhaditya21 <53948039+singhaditya21@users.noreply.github.com> --- .Jules/palette.md | 3 +++ web-demo/css/style.css | 5 +++++ web-demo/js/app.js | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 .Jules/palette.md diff --git a/.Jules/palette.md b/.Jules/palette.md new file mode 100644 index 0000000..d148f30 --- /dev/null +++ b/.Jules/palette.md @@ -0,0 +1,3 @@ +## 2026-06-04 - Missing Loading State on Authentication Forms +**Learning:** Found that auth forms (login and register) in the vanilla JS app don't show a loading state on the submit button, keeping it clickable and confusing users during the API call. Also `.btn:disabled` styles were missing. +**Action:** Implemented async loading states with try/finally to ensure the UI handles API delays gracefully and buttons visually reflect the loading state. diff --git a/web-demo/css/style.css b/web-demo/css/style.css index e0d4506..cb13fc0 100644 --- a/web-demo/css/style.css +++ b/web-demo/css/style.css @@ -218,6 +218,11 @@ body { transition: all 0.3s ease; } +.btn:disabled { + opacity: 0.7; + cursor: not-allowed; +} + .btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: white; diff --git a/web-demo/js/app.js b/web-demo/js/app.js index 11508de..22e8787 100644 --- a/web-demo/js/app.js +++ b/web-demo/js/app.js @@ -144,6 +144,14 @@ class ClimaAI { e.preventDefault(); const email = document.getElementById('loginEmail').value; const password = document.getElementById('loginPassword').value; + const submitBtn = e.submitter; + let originalText = ''; + + if (submitBtn) { + originalText = submitBtn.innerHTML; + submitBtn.innerHTML = 'Loading...'; + submitBtn.disabled = true; + } try { this.showToast('Logging in...', 'info'); @@ -155,6 +163,11 @@ class ClimaAI { this.checkSubscription(); } catch (error) { this.showToast(error.message || 'Login failed', 'error'); + } finally { + if (submitBtn) { + submitBtn.innerHTML = originalText; + submitBtn.disabled = false; + } } } @@ -163,6 +176,14 @@ class ClimaAI { const name = document.getElementById('registerName').value; const email = document.getElementById('registerEmail').value; const password = document.getElementById('registerPassword').value; + const submitBtn = e.submitter; + let originalText = ''; + + if (submitBtn) { + originalText = submitBtn.innerHTML; + submitBtn.innerHTML = 'Loading...'; + submitBtn.disabled = true; + } try { this.showToast('Creating account...', 'info'); @@ -174,6 +195,11 @@ class ClimaAI { this.checkSubscription(); } catch (error) { this.showToast(error.message || 'Registration failed', 'error'); + } finally { + if (submitBtn) { + submitBtn.innerHTML = originalText; + submitBtn.disabled = false; + } } }