fix: hero visible, polling replaces MutationObserver for Svelte compat
Browse files
app.py
CHANGED
|
@@ -24,7 +24,9 @@ except Exception as e:
|
|
| 24 |
CSS = """
|
| 25 |
/* ββ Base ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 26 |
footer { display: none !important; }
|
| 27 |
-
header
|
|
|
|
|
|
|
| 28 |
* { box-sizing: border-box; }
|
| 29 |
body { background: #0A0F1E !important; margin: 0 !important; }
|
| 30 |
|
|
@@ -41,14 +43,19 @@ body { background: #0A0F1E !important; margin: 0 !important; }
|
|
| 41 |
.contain { padding: 0 !important; }
|
| 42 |
#component-0 { padding: 0 !important; }
|
| 43 |
|
| 44 |
-
/* ββ
|
| 45 |
#upload-row {
|
| 46 |
max-width: 760px !important;
|
| 47 |
-
margin
|
| 48 |
-
|
| 49 |
-
padding: 0 20px !important;
|
| 50 |
flex-direction: column !important;
|
| 51 |
gap: 12px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
}
|
| 53 |
|
| 54 |
/* ββ Completely hide the thin-line rows (DOM still present for JS) βββββββββββββ */
|
|
@@ -141,8 +148,11 @@ body { background: #0A0F1E !important; margin: 0 !important; }
|
|
| 141 |
pointer-events: none !important;
|
| 142 |
}
|
| 143 |
|
| 144 |
-
/* ββ
|
| 145 |
-
#hidden-feedback-output
|
|
|
|
|
|
|
|
|
|
| 146 |
position: fixed !important;
|
| 147 |
top: -9999px !important;
|
| 148 |
left: -9999px !important;
|
|
@@ -298,35 +308,23 @@ with gr.Blocks(title="PaperProf", css=CSS) as demo:
|
|
| 298 |
|
| 299 |
gr.HTML("""
|
| 300 |
<script>
|
| 301 |
-
|
| 302 |
-
|
| 303 |
let lastStatus = '';
|
|
|
|
| 304 |
|
| 305 |
-
// Inject status bar before quiz-card
|
| 306 |
function ensureStatusBar() {
|
| 307 |
if (document.getElementById('gradio-status-bar')) return;
|
| 308 |
-
const
|
| 309 |
-
if (!
|
| 310 |
const bar = document.createElement('div');
|
| 311 |
bar.id = 'gradio-status-bar';
|
| 312 |
-
bar.style.cssText =
|
| 313 |
-
|
| 314 |
-
'max-width:760px',
|
| 315 |
-
'margin:0 auto',
|
| 316 |
-
'padding:12px 20px',
|
| 317 |
-
'border-radius:10px',
|
| 318 |
-
'font-size:.9rem',
|
| 319 |
-
'font-weight:500',
|
| 320 |
-
'font-family:Inter,system-ui,sans-serif',
|
| 321 |
-
'transition:all .3s ease',
|
| 322 |
-
].join(';');
|
| 323 |
-
quizCard.parentNode.insertBefore(bar, quizCard);
|
| 324 |
}
|
| 325 |
|
| 326 |
function applyStatus(text) {
|
| 327 |
if (text === lastStatus) return;
|
| 328 |
lastStatus = text;
|
| 329 |
-
|
| 330 |
ensureStatusBar();
|
| 331 |
const bar = document.getElementById('gradio-status-bar');
|
| 332 |
if (!bar) return;
|
|
@@ -339,44 +337,43 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 339 |
|
| 340 |
if (isError) {
|
| 341 |
bar.style.background = 'rgba(239,68,68,0.12)';
|
| 342 |
-
bar.style.border
|
| 343 |
-
bar.style.color
|
| 344 |
} else if (isSuccess) {
|
| 345 |
bar.style.background = 'rgba(16,185,129,0.12)';
|
| 346 |
-
bar.style.border
|
| 347 |
-
bar.style.color
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
});
|
| 365 |
}
|
| 366 |
} else {
|
| 367 |
bar.style.background = 'rgba(6,182,212,0.12)';
|
| 368 |
-
bar.style.border
|
| 369 |
-
bar.style.color
|
| 370 |
}
|
| 371 |
}
|
| 372 |
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
});
|
| 380 |
</script>
|
| 381 |
""")
|
| 382 |
|
|
|
|
| 24 |
CSS = """
|
| 25 |
/* ββ Base ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 26 |
footer { display: none !important; }
|
| 27 |
+
/* Only hide Gradio's own header chrome β NOT our custom <header class="hero"> */
|
| 28 |
+
.gradio-container > header,
|
| 29 |
+
.app > header { display: none !important; }
|
| 30 |
* { box-sizing: border-box; }
|
| 31 |
body { background: #0A0F1E !important; margin: 0 !important; }
|
| 32 |
|
|
|
|
| 43 |
.contain { padding: 0 !important; }
|
| 44 |
#component-0 { padding: 0 !important; }
|
| 45 |
|
| 46 |
+
/* ββ Upload row: centred column, card look ββββββββββββββββββββββββββββββββββββ */
|
| 47 |
#upload-row {
|
| 48 |
max-width: 760px !important;
|
| 49 |
+
margin: 0 auto !important;
|
| 50 |
+
padding: 20px !important;
|
|
|
|
| 51 |
flex-direction: column !important;
|
| 52 |
gap: 12px !important;
|
| 53 |
+
background: rgba(10,15,30,0.65) !important;
|
| 54 |
+
border: 1px solid rgba(255,255,255,0.08) !important;
|
| 55 |
+
border-radius: 18px !important;
|
| 56 |
+
backdrop-filter: blur(24px) !important;
|
| 57 |
+
-webkit-backdrop-filter: blur(24px) !important;
|
| 58 |
+
box-shadow: 0 8px 32px rgba(0,0,0,0.45) !important;
|
| 59 |
}
|
| 60 |
|
| 61 |
/* ββ Completely hide the thin-line rows (DOM still present for JS) βββββββββββββ */
|
|
|
|
| 148 |
pointer-events: none !important;
|
| 149 |
}
|
| 150 |
|
| 151 |
+
/* ββ Standalone hidden components (no row wrapper) ββββββββββββββββββββββββββββ */
|
| 152 |
+
#hidden-feedback-output,
|
| 153 |
+
#hidden-answer-input,
|
| 154 |
+
#hidden-submit-btn,
|
| 155 |
+
#hidden-question-btn {
|
| 156 |
position: fixed !important;
|
| 157 |
top: -9999px !important;
|
| 158 |
left: -9999px !important;
|
|
|
|
| 308 |
|
| 309 |
gr.HTML("""
|
| 310 |
<script>
|
| 311 |
+
(function() {
|
|
|
|
| 312 |
let lastStatus = '';
|
| 313 |
+
let quizRevealed = false;
|
| 314 |
|
|
|
|
| 315 |
function ensureStatusBar() {
|
| 316 |
if (document.getElementById('gradio-status-bar')) return;
|
| 317 |
+
const anchor = document.getElementById('quiz-card') || document.getElementById('app');
|
| 318 |
+
if (!anchor) return;
|
| 319 |
const bar = document.createElement('div');
|
| 320 |
bar.id = 'gradio-status-bar';
|
| 321 |
+
bar.style.cssText = 'display:none;max-width:760px;margin:8px auto 0;padding:12px 20px;border-radius:10px;font-size:.9rem;font-weight:500;font-family:Inter,system-ui,sans-serif;transition:all .3s ease;';
|
| 322 |
+
anchor.parentNode.insertBefore(bar, anchor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
}
|
| 324 |
|
| 325 |
function applyStatus(text) {
|
| 326 |
if (text === lastStatus) return;
|
| 327 |
lastStatus = text;
|
|
|
|
| 328 |
ensureStatusBar();
|
| 329 |
const bar = document.getElementById('gradio-status-bar');
|
| 330 |
if (!bar) return;
|
|
|
|
| 337 |
|
| 338 |
if (isError) {
|
| 339 |
bar.style.background = 'rgba(239,68,68,0.12)';
|
| 340 |
+
bar.style.border = '1px solid rgba(239,68,68,0.3)';
|
| 341 |
+
bar.style.color = '#FCA5A5';
|
| 342 |
} else if (isSuccess) {
|
| 343 |
bar.style.background = 'rgba(16,185,129,0.12)';
|
| 344 |
+
bar.style.border = '1px solid rgba(16,185,129,0.3)';
|
| 345 |
+
bar.style.color = '#6EE7B7';
|
| 346 |
+
|
| 347 |
+
if (!quizRevealed) {
|
| 348 |
+
quizRevealed = true;
|
| 349 |
+
const quizCard = document.getElementById('quiz-card');
|
| 350 |
+
if (quizCard) {
|
| 351 |
+
quizCard.classList.remove('hidden');
|
| 352 |
+
setTimeout(() => quizCard.scrollIntoView({ behavior: 'smooth', block: 'start' }), 400);
|
| 353 |
+
}
|
| 354 |
+
// Recede upload row
|
| 355 |
+
const uploadRow = document.getElementById('upload-row');
|
| 356 |
+
if (uploadRow) {
|
| 357 |
+
uploadRow.style.opacity = '0.5';
|
| 358 |
+
uploadRow.style.transform = 'scale(0.97)';
|
| 359 |
+
uploadRow.style.transition = 'all .4s ease';
|
| 360 |
+
uploadRow.style.pointerEvents = 'none';
|
| 361 |
+
}
|
|
|
|
| 362 |
}
|
| 363 |
} else {
|
| 364 |
bar.style.background = 'rgba(6,182,212,0.12)';
|
| 365 |
+
bar.style.border = '1px solid rgba(6,182,212,0.3)';
|
| 366 |
+
bar.style.color = '#67E8F9';
|
| 367 |
}
|
| 368 |
}
|
| 369 |
|
| 370 |
+
// Poll every 300ms β Svelte updates textarea.value as a property,
|
| 371 |
+
// which MutationObserver characterData does NOT catch.
|
| 372 |
+
setInterval(function() {
|
| 373 |
+
const el = document.querySelector('#hidden-status-output textarea');
|
| 374 |
+
if (el && el.value) applyStatus(el.value);
|
| 375 |
+
}, 300);
|
| 376 |
+
})();
|
| 377 |
</script>
|
| 378 |
""")
|
| 379 |
|