Skip to content
Draft
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">
Generate Poster
<span class="spinner"></span>
</button>
</div>
</div>

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

loadingOverlay.style.display = 'flex';
generateBtn.classList.add('loading');
generateBtn.disabled = true;

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

if (isNaN(start) || isNaN(end) || start >= end) {
loadingOverlay.style.display = 'none';
generateBtn.classList.remove('loading');
generateBtn.disabled = false;
showToast("Please enter a valid range (Start must be less than End).", "error");
return;
}
Expand Down Expand Up @@ -669,13 +671,14 @@ async function generatePoster() {
posterContainer.innerHTML = '';
posterContainer.appendChild(img);
showDownloadButton(imageUrl, data.filename);
loadingOverlay.style.display = 'none';
};

} catch (error) {
console.error("Generation failed", error);
showToast(`Error: ${error.message}`, "error");
loadingOverlay.style.display = 'none';
} finally {
generateBtn.classList.remove('loading');
generateBtn.disabled = false;
}
}

Expand Down
26 changes: 26 additions & 0 deletions web_app/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ header p {
/* Buttons */
.primary-btn,
.secondary-btn {
position: relative; /* For spinner positioning */
display: inline-flex;
align-items: center;
justify-content: center;
Expand All @@ -166,6 +167,31 @@ header p {
transform: translateY(-1px);
}

.primary-btn.loading {
cursor: wait;
color: transparent;
pointer-events: none;
}

.primary-btn .spinner {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 20px;
height: 20px;
margin: 0;
border: 2px solid #1a1a1f;
border-top-color: transparent;
border-radius: 50%;
animation: spin 0.6s linear infinite;
}

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

.secondary-btn {
background: transparent;
border-color: var(--border-color);
Expand Down