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
11 changes: 5 additions & 6 deletions 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>
<div class="btn-spinner"></div>
</button>
</div>
</div>

Expand All @@ -143,11 +146,7 @@ <h2>Poster</h2>
</main>
</div>
<div id="toastContainer" class="toast-container"></div>
<div id="loadingOverlay" class="loading-overlay" style="display: none;">
<div class="spinner"></div>
<p>Generating your masterpiece...</p>
</div>
<script src="/static/script.js?v=21"></script>
<script src="/static/script.js?v=22"></script>
</body>

</html>
18 changes: 13 additions & 5 deletions web_app/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const startLineInput = document.getElementById('startLine');
const endLineInput = document.getElementById('endLine');
const themeInput = document.getElementById('themeInput');
const fontInput = document.getElementById('fontInput');
const loadingOverlay = document.getElementById('loadingOverlay');

let currentMetadata = null;
let searchDebounceTimer = null;
Expand Down Expand Up @@ -613,7 +612,8 @@ function handleLyricLineClick(lineNumber) {
async function generatePoster() {
if (!currentMetadata) return;

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

const indexingToggle = document.getElementById('indexingToggle');
const accentToggle = document.getElementById('accentToggle');
Expand All @@ -635,8 +635,9 @@ 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");
generateBtn.disabled = false;
generateBtn.classList.remove('loading');
return;
}

Expand Down Expand Up @@ -669,13 +670,20 @@ async function generatePoster() {
posterContainer.innerHTML = '';
posterContainer.appendChild(img);
showDownloadButton(imageUrl, data.filename);
loadingOverlay.style.display = 'none';
generateBtn.disabled = false;
generateBtn.classList.remove('loading');
};
img.onerror = () => {
showToast('Failed to load generated poster.', 'error');
generateBtn.disabled = false;
generateBtn.classList.remove('loading');
};

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

Expand Down
41 changes: 39 additions & 2 deletions web_app/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,11 @@ input:focus {
}

@keyframes spin {
from {
transform: translate(-50%, -50%) rotate(0deg);
}
to {
transform: rotate(360deg);
transform: translate(-50%, -50%) rotate(360deg);
}
}

Expand Down Expand Up @@ -908,4 +911,38 @@ input:focus {

.result-action svg {
pointer-events: none;
}
}
/* --- Button Loading State --- */
.primary-btn {
position: relative; /* Anchor for spinner */
}

.primary-btn:disabled {
opacity: 0.65;
cursor: not-allowed;
transform: none; /* Cancel hover effect */
background-color: var(--accent-color);
}

.primary-btn.loading .btn-text {
visibility: hidden;
opacity: 0;
}

.btn-spinner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 24px;
height: 24px;
border: 3px solid rgba(26, 26, 31, 0.2); /* Use a darker transparent for contrast on the accent bg */
border-top-color: #1a1a1f; /* Match button text color */
border-radius: 50%;
animation: spin 0.8s linear infinite;
display: none; /* Hidden by default */
}

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