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
5 changes: 4 additions & 1 deletion web_app/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ <h2 id="contentHeading">Lyrics</h2>
</div>
</div>

<button id="generateBtn" class="primary-btn">Generate Poster</button>
<button id="generateBtn" class="primary-btn">
<span class="btn-text">Generate Poster</span>
<span class="spinner-inline"></span>
</button>
</div>
</div>

Expand Down
32 changes: 28 additions & 4 deletions web_app/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,15 @@ function handleLyricLineClick(lineNumber) {
async function generatePoster() {
if (!currentMetadata) return;

loadingOverlay.style.display = 'flex';
const btn = document.getElementById('generateBtn');
const btnText = btn.querySelector('.btn-text');
const spinner = btn.querySelector('.spinner-inline');

// UX: Disable button and show spinner
btn.classList.add('loading');
btn.disabled = true;
btn.setAttribute('aria-label', 'Generating poster, please wait');


const indexingToggle = document.getElementById('indexingToggle');
const accentToggle = document.getElementById('accentToggle');
Expand All @@ -635,8 +643,11 @@ async function generatePoster() {
const end = endVal;

if (isNaN(start) || isNaN(end) || start >= end) {
loadingOverlay.style.display = 'none';
showToast("Please enter a valid range (Start must be less than End).", "error");
// UX: Reset button state on failure
btn.classList.remove('loading');
btn.disabled = false;
btn.removeAttribute('aria-label');
return;
}

Expand Down Expand Up @@ -669,13 +680,26 @@ async function generatePoster() {
posterContainer.innerHTML = '';
posterContainer.appendChild(img);
showDownloadButton(imageUrl, data.filename);
loadingOverlay.style.display = 'none';
// UX: Reset button state on success
btn.classList.remove('loading');
btn.disabled = false;
btn.removeAttribute('aria-label');
};
img.onerror = () => {
showToast("Error loading generated image.", "error");
// UX: Reset button state on failure
btn.classList.remove('loading');
btn.disabled = false;
btn.removeAttribute('aria-label');
};

} catch (error) {
console.error("Generation failed", error);
showToast(`Error: ${error.message}`, "error");
loadingOverlay.style.display = 'none';
// UX: Reset button state on failure
btn.classList.remove('loading');
btn.disabled = false;
btn.removeAttribute('aria-label');
}
}

Expand Down
30 changes: 30 additions & 0 deletions web_app/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -908,4 +908,34 @@ input:focus {

.result-action svg {
pointer-events: none;
}

/* --- Inline Spinner for Buttons --- */
.spinner-inline {
display: none; /* Hidden by default */
width: 20px;
height: 20px;
border: 2px solid rgba(0, 0, 0, 0.2);
border-top-color: #1a1a1f; /* Match button text color */
border-radius: 50%;
animation: spin 0.8s linear infinite;
}

.primary-btn.loading {
cursor: not-allowed;
background: var(--accent-hover);
}

.primary-btn.loading .btn-text {
display: none;
}

.primary-btn.loading .spinner-inline {
display: block;
}

@keyframes spin {
to {
transform: rotate(360deg);
}
}