Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions web-demo/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions web-demo/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
}
}
}

Expand All @@ -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');
Expand All @@ -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;
}
}
}

Expand Down