Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -599,9 +599,9 @@ def export_txt_zip(table_value: Any, dataset_name: str) -> str:
|
|
| 599 |
def _render_header_html(auto: bool, px: int, scale: float) -> str:
|
| 600 |
auto_js = "true" if auto else "false"
|
| 601 |
return f"""
|
| 602 |
-
<div class="cf-hero">
|
| 603 |
-
{logo_b64_img()}
|
| 604 |
-
<div class="cf-text">
|
| 605 |
<h1 class="cf-title">ForgeCaptions</h1>
|
| 606 |
<div class="cf-sub">Batch captioning</div>
|
| 607 |
<div class="cf-sub">Scrollable editor & autosave</div>
|
|
@@ -610,37 +610,64 @@ def _render_header_html(auto: bool, px: int, scale: float) -> str:
|
|
| 610 |
</div>
|
| 611 |
<hr>
|
| 612 |
<style>
|
| 613 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 614 |
</style>
|
| 615 |
<script>
|
| 616 |
(function() {{
|
| 617 |
-
const AUTO
|
| 618 |
-
const PX
|
| 619 |
const SCALE = {float(scale)};
|
|
|
|
| 620 |
function fit() {{
|
|
|
|
|
|
|
| 621 |
const logo = document.querySelector(".cf-logo");
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
}}
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
}}
|
|
|
|
| 637 |
window.addEventListener("resize", fit, {{ passive: true }});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 638 |
setTimeout(fit, 0);
|
|
|
|
|
|
|
| 639 |
}})();
|
| 640 |
</script>
|
| 641 |
"""
|
| 642 |
|
| 643 |
|
|
|
|
| 644 |
# ------------------------------
|
| 645 |
# 11) UI (Blocks)
|
| 646 |
# ------------------------------
|
|
@@ -649,11 +676,17 @@ BASE_CSS = """
|
|
| 649 |
.gradio-container{max-width:100%!important}
|
| 650 |
|
| 651 |
/* Header */
|
| 652 |
-
.cf-hero{
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 657 |
|
| 658 |
/* Results area + robust scrollbars */
|
| 659 |
.cf-scroll{border:1px solid #e6e6e6; border-radius:10px; padding:8px}
|
|
|
|
| 599 |
def _render_header_html(auto: bool, px: int, scale: float) -> str:
|
| 600 |
auto_js = "true" if auto else "false"
|
| 601 |
return f"""
|
| 602 |
+
<div class="cf-hero" id="cfHero">
|
| 603 |
+
{logo_b64_img() or '<div class="cf-logo"></div>'}
|
| 604 |
+
<div class="cf-text" id="cfText">
|
| 605 |
<h1 class="cf-title">ForgeCaptions</h1>
|
| 606 |
<div class="cf-sub">Batch captioning</div>
|
| 607 |
<div class="cf-sub">Scrollable editor & autosave</div>
|
|
|
|
| 610 |
</div>
|
| 611 |
<hr>
|
| 612 |
<style>
|
| 613 |
+
/* Let the hero stretch to tallest child; we’ll force exact height via JS */
|
| 614 |
+
#cfHero {{ align-items: stretch; }}
|
| 615 |
+
.cf-logo {{
|
| 616 |
+
display: block;
|
| 617 |
+
width: auto;
|
| 618 |
+
height: auto; /* JS will set explicit px height */
|
| 619 |
+
object-fit: contain;
|
| 620 |
+
max-height: 480px; /* safety clamp */
|
| 621 |
+
}}
|
| 622 |
</style>
|
| 623 |
<script>
|
| 624 |
(function() {{
|
| 625 |
+
const AUTO = {auto_js};
|
| 626 |
+
const PX = {int(px)};
|
| 627 |
const SCALE = {float(scale)};
|
| 628 |
+
|
| 629 |
function fit() {{
|
| 630 |
+
const hero = document.getElementById("cfHero");
|
| 631 |
+
const text = document.getElementById("cfText");
|
| 632 |
const logo = document.querySelector(".cf-logo");
|
| 633 |
+
if (!hero || !text || !logo) return;
|
| 634 |
+
|
| 635 |
+
// Include vertical margins so we truly match the whole text stack
|
| 636 |
+
const cs = getComputedStyle(text);
|
| 637 |
+
const rect = text.getBoundingClientRect();
|
| 638 |
+
const fullH = rect.height + parseFloat(cs.marginTop) + parseFloat(cs.marginBottom);
|
| 639 |
+
|
| 640 |
+
const target = AUTO
|
| 641 |
+
? Math.max(80, Math.min(480, Math.round(fullH * SCALE)))
|
| 642 |
+
: Math.max(80, Math.min(480, PX));
|
| 643 |
+
|
| 644 |
+
hero.style.minHeight = target + "px"; // ensure the flex row is that tall
|
| 645 |
+
logo.style.height = target + "px"; // logo matches exactly
|
| 646 |
+
logo.style.width = "auto"; // preserve aspect ratio
|
| 647 |
}}
|
| 648 |
+
|
| 649 |
+
// Recompute on font load, hydration, resizes, and text changes
|
| 650 |
+
if (document.fonts && document.fonts.ready) {{
|
| 651 |
+
document.fonts.ready.then(fit);
|
| 652 |
}}
|
| 653 |
+
window.addEventListener("load", fit, {{ passive: true }});
|
| 654 |
window.addEventListener("resize", fit, {{ passive: true }});
|
| 655 |
+
|
| 656 |
+
const textEl = document.getElementById("cfText");
|
| 657 |
+
if (window.ResizeObserver && textEl) {{
|
| 658 |
+
new ResizeObserver(fit).observe(textEl);
|
| 659 |
+
}}
|
| 660 |
+
|
| 661 |
+
// A couple of deferred passes to catch late reflows
|
| 662 |
setTimeout(fit, 0);
|
| 663 |
+
setTimeout(fit, 200);
|
| 664 |
+
setTimeout(fit, 800);
|
| 665 |
}})();
|
| 666 |
</script>
|
| 667 |
"""
|
| 668 |
|
| 669 |
|
| 670 |
+
|
| 671 |
# ------------------------------
|
| 672 |
# 11) UI (Blocks)
|
| 673 |
# ------------------------------
|
|
|
|
| 676 |
.gradio-container{max-width:100%!important}
|
| 677 |
|
| 678 |
/* Header */
|
| 679 |
+
.cf-hero{
|
| 680 |
+
display:flex;
|
| 681 |
+
align-items:stretch; /* was center; stretch lets the logo fill the row */
|
| 682 |
+
justify-content:center;
|
| 683 |
+
gap:16px;
|
| 684 |
+
margin:4px 0 12px;
|
| 685 |
+
text-align:center;
|
| 686 |
+
}
|
| 687 |
+
.cf-hero .cf-text{ text-align:center; }
|
| 688 |
+
.cf-title{ margin:0; font-size:3.25rem; line-height:1; letter-spacing:.2px; }
|
| 689 |
+
.cf-sub{ margin:6px 0 0; font-size:1.1rem; color:#cfd3da; }
|
| 690 |
|
| 691 |
/* Results area + robust scrollbars */
|
| 692 |
.cf-scroll{border:1px solid #e6e6e6; border-radius:10px; padding:8px}
|