from __future__ import annotations import gradio as gr from pages import PAGES, render_page from website_texts import COI_HTML, TITLE CSS = """ /* Use the full page width instead of gradio's narrow centered column. */ .gradio-container { max-width: 100% !important; } .markdown-text-box { padding: 4px; border-radius: 2px; } /* Intro tagline as a full-width card inside the hero group, above the stat boxes. Tinted with the app accent (blue) so it stands out from the neutral stat cards. */ .ta-intro { flex: 1 1 100%; padding: 11px 16px; border: 1px solid rgba(110, 140, 245, 0.5); border-radius: 10px; background: linear-gradient(135deg, rgba(110, 140, 245, 0.22), rgba(110, 140, 245, 0.07)); text-align: center; font-size: 1.05em; font-weight: 600; line-height: 1.4; color: #e6ebff; } .tab-buttons { margin-top: -4px !important; margin-bottom: -14px !important; } /* Top-level page tabs: size each header to its label instead of stretching one full width. */ #top-tabs > .tab-nav { justify-content: flex-start !important; } #top-tabs > .tab-nav > button { flex: 0 0 auto !important; width: auto !important; } /* View toggles (imputation / Lite) below the subset tabs, set apart in a panel. */ .view-toggles { margin: 2px 0 10px 0; padding: 6px 14px; gap: 18px; align-items: center; background: #ffffff0a; border: 1px solid #ffffff26; border-radius: 8px; } .view-toggles::before { content: "View:"; font-size: 0.85em; font-weight: 600; opacity: 0.7; align-self: center; } .view-toggles label span { font-size: 0.85em !important; } /* Row of external links/buttons (e.g. on a linked-leaderboard page). Rendered as real anchors so they open in a new tab instead of navigating inside the embedded Hugging Face Space iframe. */ .link-row { display: flex; margin: 12px 0; gap: 12px; align-items: center; flex-wrap: wrap; } .ta-link-btn { display: inline-block; padding: 10px 20px; border-radius: 8px; font-weight: 600; text-decoration: none; border: 1px solid transparent; transition: background .15s ease, border-color .15s ease; } .ta-link-btn.primary { background: rgba(110, 140, 245, 0.85); border-color: rgba(110, 140, 245, 1); color: #ffffff; } .ta-link-btn.primary:hover { background: rgba(110, 140, 245, 1); } .ta-link-btn.secondary { background: #ffffff14; border-color: #ffffff3d; color: #e6ebff; } .ta-link-btn.secondary:hover { background: #ffffff24; border-color: #ffffff5c; } /* Compact "Metric:" selector panel above the overview table. */ .metric-select { margin: -18px 0 0 0; padding: 6px 14px; gap: 12px; align-items: center; background: #ffffff0a; border: 1px solid #ffffff26; border-radius: 8px; } .metric-select::before { content: "📈 Aggregation:"; font-size: 0.85em; font-weight: 600; opacity: 0.7; white-space: nowrap; } .metric-tldr { font-size: 0.85em; opacity: 0.75; font-style: italic; } .metric-tldr p { margin: 0; } /* Pull the overview (type legend + table) up tight under the aggregation box. */ .ta-overview-block { margin-top: -8px; } /* "Jump to detailed results" pill link. */ .ta-jump { display: inline-block; margin: 0; font-size: 0.9em; padding: 4px 14px; border: 1px solid #ffffff2e; border-radius: 999px; text-decoration: none; opacity: 0.85; } .ta-jump:hover { opacity: 1; border-color: #ffffff5c; } /* Section header: title (and optional jump link) on one row, summary directly below. */ .ta-section-head { margin: 10px 0 6px 0; } .ta-section-head h2 { margin: 0; } .ta-section-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; } .ta-section-sub { margin: 3px 0 0 0; font-size: 0.95em; opacity: 0.8; line-height: 1.4; } /* Info topic pills + the single reveal panel (replaces the stacked accordions). */ .info-pills { gap: 8px; flex-wrap: wrap; justify-content: center; margin: -6px 0 2px 0; } .info-pills button { border-radius: 999px !important; flex: 0 0 auto !important; font-weight: 600 !important; font-size: 1em !important; padding: 8px 20px !important; color: #cdd7ff !important; background: rgba(110, 140, 245, 0.18) !important; border: 1px solid rgba(110, 140, 245, 0.55) !important; } .info-pills button:hover { background: rgba(110, 140, 245, 0.32) !important; border-color: rgba(110, 140, 245, 0.9) !important; } .info-pills button.primary { background: rgba(110, 140, 245, 0.85) !important; border-color: rgba(110, 140, 245, 1) !important; color: #ffffff !important; } .info-panel { margin: 6px 0 12px 0; padding: 4px 18px; border: 1px solid #ffffff1f; border-radius: 12px; background: #ffffff08; } /* Column key above the full table: a boxed panel with a title + hint, a chip row below, and one shared reveal panel (CSS-radio toggled, one definition open at a time). */ .ta-metric-key { margin: 10px 0 12px 0; padding: 11px 14px 12px; background: #ffffff08; border: 1px solid #ffffff1f; border-radius: 10px; } .ta-mk-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 10px; margin-bottom: 10px; } .ta-mk-title { font-size: 1.05em; font-weight: 700; } .ta-mk-hint { font-size: 0.85em; opacity: 0.6; } .ta-mk-radio { display: none; } .ta-mk-chips { display: flex; flex-wrap: wrap; gap: 7px; } .ta-mk-chip { display: inline-block; cursor: pointer; font-size: 0.82em; padding: 3px 11px; border-radius: 999px; border: 1px solid #ffffff24; background: #ffffff0d; white-space: nowrap; } .ta-mk-chip:hover { border-color: #ffffff5c; background: #ffffff1a; } .ta-mk-def { display: none; margin-top: 8px; max-width: 760px; padding: 9px 13px; border-radius: 10px; background: #1d1d26; border: 1px solid #ffffff33; font-size: 0.82em; line-height: 1.4; color: #dcdce6; } .ta-mk-close { float: right; cursor: pointer; opacity: 0.55; margin-left: 12px; font-weight: 700; } .ta-mk-close:hover { opacity: 1; } /* Hero stat cards shown above the info boxes (emoji on the left of the text, compact). */ .ta-hero { display: flex; flex-wrap: wrap; gap: 10px; margin: -8px 0 0 0; } .ta-hero .ta-card { flex: 1 1 210px; min-width: 210px; display: flex; align-items: center; gap: 11px; padding: 9px 13px; border: 1px solid #ffffff1f; border-radius: 10px; background: linear-gradient(135deg, #ffffff12, #ffffff05); text-align: left; transition: transform .15s ease, border-color .15s ease; } .ta-hero .ta-card:hover { transform: translateY(-2px); border-color: #ffffff40; } .ta-hero .ta-card-ico { font-size: 1.5em; line-height: 1; flex: 0 0 auto; } .ta-hero .ta-card-body { min-width: 0; } .ta-hero .ta-card-num { font-size: 1.1em; font-weight: 700; line-height: 1.2; } .ta-hero .ta-card-lbl { font-size: 0.8em; opacity: 0.75; margin-top: 1px; line-height: 1.3; } .ta-hero .ta-card-lbl a { color: inherit; } /* "Your Benchmark?" invite page: two "path" cards side by side. */ .ta-paths { display: flex; flex-wrap: wrap; gap: 16px; margin: 18px 0 6px 0; } .ta-path { flex: 1 1 320px; min-width: 280px; padding: 18px 22px; border: 1px solid rgba(110, 140, 245, 0.45); border-radius: 12px; background: linear-gradient(135deg, rgba(110, 140, 245, 0.16), rgba(110, 140, 245, 0.04)); transition: transform .15s ease, border-color .15s ease; } .ta-path:hover { transform: translateY(-2px); border-color: rgba(110, 140, 245, 0.85); } .ta-path-ico { font-size: 1.9em; line-height: 1; } .ta-path h3 { margin: 8px 0 8px 0; font-size: 1.18em; } .ta-path p { margin: 0; opacity: 0.88; line-height: 1.55; } /* Soft "independent benchmarks" note on the invite page (mirrors the RamanBench callout). */ .ta-invite-note { margin: 14px 0 4px 0; padding: 11px 16px; border: 1px solid rgba(110, 140, 245, 0.4); border-left: 4px solid rgba(110, 140, 245, 0.85); border-radius: 8px; background: rgba(110, 140, 245, 0.08); font-size: 0.95em; line-height: 1.5; opacity: 0.95; } /* --- Conflict-of-interest corner hint + CSS-only popup --------------------- A small pill pinned to the top-right corner; clicking it reveals a modal. Built with the checkbox hack so it needs no JS and works inside the embedded Hugging Face Space iframe. */ .coi-toggle { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; } .coi-badge { position: fixed; top: 10px; right: 14px; z-index: 1000; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 6px 13px; font-size: 0.85em; font-weight: 600; color: #cdd7ff; background: rgba(110, 140, 245, 0.2); border: 1px solid rgba(110, 140, 245, 0.6); border-radius: 999px; user-select: none; transition: background .15s ease, border-color .15s ease; } .coi-badge:hover { background: rgba(110, 140, 245, 0.34); border-color: rgba(110, 140, 245, 0.95); } .coi-overlay { display: none; position: fixed; inset: 0; z-index: 1001; align-items: flex-start; justify-content: center; padding: 32px 20px; overflow-y: auto; background: rgba(0, 0, 0, 0.66); } .coi-toggle:checked ~ .coi-overlay { display: flex; } .coi-backdrop { position: absolute; inset: 0; cursor: default; } .coi-modal { position: relative; width: 100%; max-width: min(1040px, 94vw); margin: 0 auto; /* Fixed base font (in rem) so the popup does not inherit Gradio's smaller in-app font; all sizes below scale from this. */ font-size: 1.06rem; padding: 34px 44px 38px; border-radius: 16px; background: #1b1b24; border: 1px solid rgba(110, 140, 245, 0.45); box-shadow: 0 18px 55px rgba(0, 0, 0, 0.55); color: #eef1ff; line-height: 1.7; } .coi-modal h2 { margin: 0 0 6px 0; font-size: 1.85em; line-height: 1.25; } .coi-modal h3 { margin: 26px 0 8px 0; font-size: 1.28em; color: #cdd7ff; } .coi-modal p, .coi-modal li { font-size: 1em; opacity: 0.96; } .coi-modal ul { margin: 8px 0; padding-left: 24px; } .coi-modal li { margin: 7px 0; } .coi-modal a { color: #9db4ff; } .coi-lead { font-size: 1.18em !important; opacity: 1 !important; line-height: 1.55; } .coi-tldr { margin: 16px 0 4px 0; padding: 16px 20px; border: 1px solid rgba(110, 140, 245, 0.4); border-left: 4px solid rgba(110, 140, 245, 0.85); border-radius: 8px; background: rgba(110, 140, 245, 0.1); font-size: 1.05em; line-height: 1.6; } .coi-x { position: absolute; top: 14px; right: 20px; font-size: 2em; line-height: 1; cursor: pointer; opacity: 0.55; user-select: none; } .coi-x:hover { opacity: 1; } .coi-cta { display: block; width: fit-content; margin: 28px auto 0; text-align: center; padding: 12px 24px; border-radius: 8px; font-weight: 600; font-size: 1.02em; text-decoration: none; color: #ffffff !important; background: rgba(110, 140, 245, 0.85); border: 1px solid rgba(110, 140, 245, 1); } .coi-cta:hover { background: rgba(110, 140, 245, 1); } /* On wider screens, give the prose a touch more size still. */ @media (min-width: 900px) { .coi-modal { font-size: 1.12rem; } } /* BeyondArena "What do the subsets mean?" expander: larger label + blue highlight box. */ .beyond-subsets-accordion { border: 1px solid #5aa9e6 !important; border-radius: 10px !important; background: rgba(90, 169, 230, 0.08) !important; } .beyond-subsets-accordion .label-wrap, .beyond-subsets-accordion .label-wrap span, .beyond-subsets-accordion > button { font-size: 1.15rem !important; font-weight: 600 !important; color: #8cc4f0 !important; } """ # Force the dark theme (TabArena's figures are exported for a dark background). FORCE_DARK_THEME_JS = """ function refresh() { const url = new URL(window.location); if (url.searchParams.get('__theme') !== 'dark') { url.searchParams.set('__theme', 'dark'); window.location.href = url.href; } } """ def main() -> None: with gr.Blocks(css=CSS, js=FORCE_DARK_THEME_JS, title="TabArena", fill_width=True) as website: gr.HTML(TITLE) # Conflict-of-interest corner hint (🔍 pill, top-right) + CSS-only popup. gr.HTML(COI_HTML) # Top-level navigation: one tab per leaderboard (current + future + links). with gr.Tabs(elem_id="top-tabs"): for page in PAGES: with gr.TabItem(page.name): render_page(page) website.launch(show_error=True, ssr_mode=False, debug=True) if __name__ == "__main__": main()