Spaces:
Paused
Paused
Amber Tanaka
commited on
Fix Sub-Navigation Bar (#8)
Browse files- app.py +16 -1
- content.py +23 -8
- leaderboard_transformer.py +1 -0
- ui_components.py +28 -8
app.py
CHANGED
|
@@ -16,6 +16,21 @@ PROJECT_NAME = "asta-bench" + ("-internal" if IS_INTERNAL else "")
|
|
| 16 |
LEADERBOARD_PATH = f"{OWNER}/{PROJECT_NAME}-leaderboard"
|
| 17 |
api = HfApi()
|
| 18 |
LOGO_PATH = "assets/logo.svg"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
|
|
@@ -75,7 +90,7 @@ def render_logo():
|
|
| 75 |
elem_id="logo-image"
|
| 76 |
)
|
| 77 |
# --- Gradio App Definition ---
|
| 78 |
-
demo = gr.Blocks(theme=theme, css=css)
|
| 79 |
with demo:
|
| 80 |
render_logo()
|
| 81 |
main_page.demo.render()
|
|
|
|
| 16 |
LEADERBOARD_PATH = f"{OWNER}/{PROJECT_NAME}-leaderboard"
|
| 17 |
api = HfApi()
|
| 18 |
LOGO_PATH = "assets/logo.svg"
|
| 19 |
+
# This function will be available on ALL pages of your app.
|
| 20 |
+
scroll_script = """
|
| 21 |
+
<script>
|
| 22 |
+
function scroll_to_element(id) {
|
| 23 |
+
console.log("Global scroll_to_element called for ID:", id);
|
| 24 |
+
const element = document.querySelector('#' + id);
|
| 25 |
+
if (element) {
|
| 26 |
+
console.log("Element found:", element);
|
| 27 |
+
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 28 |
+
} else {
|
| 29 |
+
console.error("Error: Element with ID '" + id + "' not found in the document.");
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
</script>
|
| 33 |
+
"""
|
| 34 |
|
| 35 |
|
| 36 |
|
|
|
|
| 90 |
elem_id="logo-image"
|
| 91 |
)
|
| 92 |
# --- Gradio App Definition ---
|
| 93 |
+
demo = gr.Blocks(theme=theme, css=css, head=scroll_script)
|
| 94 |
with demo:
|
| 95 |
render_logo()
|
| 96 |
main_page.demo.render()
|
content.py
CHANGED
|
@@ -209,16 +209,31 @@ nav.svelte-ti537g.svelte-ti537g {
|
|
| 209 |
.dark block.svelte-1svsvh2 {
|
| 210 |
background: #032629 !important;
|
| 211 |
}
|
| 212 |
-
.
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
}
|
| 215 |
-
.sub-nav-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
font-size: 16px;
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
|
|
|
| 220 |
}
|
| 221 |
-
.
|
| 222 |
-
|
| 223 |
}
|
| 224 |
"""
|
|
|
|
| 209 |
.dark block.svelte-1svsvh2 {
|
| 210 |
background: #032629 !important;
|
| 211 |
}
|
| 212 |
+
.padding.svelte-phx28p {
|
| 213 |
+
padding: 0 !important;
|
| 214 |
+
}
|
| 215 |
+
.dark .sub-nav-link-button {
|
| 216 |
+
color: #0fcb8c !important;
|
| 217 |
+
}
|
| 218 |
+
.sub-nav-bar-container {
|
| 219 |
+
display: flex !important;
|
| 220 |
+
flex-wrap: nowrap !important;
|
| 221 |
+
align-items: center !important;
|
| 222 |
+
gap: 20px !important;
|
| 223 |
}
|
| 224 |
+
.sub-nav-link-button {
|
| 225 |
+
background: none;
|
| 226 |
+
border: none;
|
| 227 |
+
padding: 0;
|
| 228 |
+
margin: 0;
|
| 229 |
+
font-family: inherit;
|
| 230 |
font-size: 16px;
|
| 231 |
+
color: #F263A6;
|
| 232 |
+
text-decoration: none;
|
| 233 |
+
cursor: pointer;
|
| 234 |
+
white-space: nowrap;
|
| 235 |
}
|
| 236 |
+
.sub-nav-link-button:hover {
|
| 237 |
+
text-decoration: underline;
|
| 238 |
}
|
| 239 |
"""
|
leaderboard_transformer.py
CHANGED
|
@@ -19,6 +19,7 @@ INFORMAL_TO_FORMAL_NAME_MAP = {
|
|
| 19 |
"sqa_dev": "Sqa Dev",
|
| 20 |
"litqa2_validation": "Litqa2 Validation",
|
| 21 |
"paper_finder_validation": "Paper Finder Validation",
|
|
|
|
| 22 |
"discoverybench_validation": "Discoverybench Validation",
|
| 23 |
"core_bench_validation": "Core Bench Validation",
|
| 24 |
"ds1000_validation": "DS1000 Validation",
|
|
|
|
| 19 |
"sqa_dev": "Sqa Dev",
|
| 20 |
"litqa2_validation": "Litqa2 Validation",
|
| 21 |
"paper_finder_validation": "Paper Finder Validation",
|
| 22 |
+
"paper_finder_litqa2_validation": "Paper Finder Litqa2 Validation",
|
| 23 |
"discoverybench_validation": "Discoverybench Validation",
|
| 24 |
"core_bench_validation": "Core Bench Validation",
|
| 25 |
"ds1000_validation": "DS1000 Validation",
|
ui_components.py
CHANGED
|
@@ -247,22 +247,42 @@ def create_gradio_anchor_id(text: str) -> str:
|
|
| 247 |
return f"h-{text}-leaderboard"
|
| 248 |
def create_sub_navigation_bar(tag_map: dict, category_name: str):
|
| 249 |
"""
|
| 250 |
-
|
|
|
|
| 251 |
"""
|
| 252 |
benchmark_names = tag_map.get(category_name, [])
|
| 253 |
if not benchmark_names:
|
| 254 |
-
|
|
|
|
| 255 |
|
| 256 |
-
|
|
|
|
| 257 |
for name in benchmark_names:
|
| 258 |
-
# Use the helper function to create the correct ID format
|
| 259 |
target_id = create_gradio_anchor_id(name)
|
| 260 |
-
anchor_links.append(f"<a href='#{target_id}'>{name}</a>")
|
| 261 |
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
-
#
|
| 265 |
-
gr.HTML(
|
| 266 |
|
| 267 |
# # --- Detailed Benchmark Display ---
|
| 268 |
def create_benchmark_details_display(
|
|
|
|
| 247 |
return f"h-{text}-leaderboard"
|
| 248 |
def create_sub_navigation_bar(tag_map: dict, category_name: str):
|
| 249 |
"""
|
| 250 |
+
Builds the entire sub-navigation bar as a single, self-contained HTML component.
|
| 251 |
+
This bypasses Gradio's layout components, giving us full control.
|
| 252 |
"""
|
| 253 |
benchmark_names = tag_map.get(category_name, [])
|
| 254 |
if not benchmark_names:
|
| 255 |
+
# Return an empty HTML component to prevent errors
|
| 256 |
+
return gr.HTML()
|
| 257 |
|
| 258 |
+
# Start building the list of HTML button elements as strings
|
| 259 |
+
html_buttons = []
|
| 260 |
for name in benchmark_names:
|
|
|
|
| 261 |
target_id = create_gradio_anchor_id(name)
|
|
|
|
| 262 |
|
| 263 |
+
# Create a standard HTML button.
|
| 264 |
+
# The onclick attribute calls our global JS function directly.
|
| 265 |
+
# Note the mix of double and single quotes.
|
| 266 |
+
button_str = f"""
|
| 267 |
+
<button
|
| 268 |
+
class="sub-nav-link-button"
|
| 269 |
+
onclick="scroll_to_element('{target_id}')"
|
| 270 |
+
>
|
| 271 |
+
{name}
|
| 272 |
+
</button>
|
| 273 |
+
"""
|
| 274 |
+
html_buttons.append(button_str)
|
| 275 |
+
|
| 276 |
+
# Join the button strings and wrap them in a single div container
|
| 277 |
+
# This container will be our flexbox row.
|
| 278 |
+
full_html = f"""
|
| 279 |
+
<div class="sub-nav-bar-container">
|
| 280 |
+
{''.join(html_buttons)}
|
| 281 |
+
</div>
|
| 282 |
+
"""
|
| 283 |
|
| 284 |
+
# Return the entire navigation bar as one single Gradio HTML component
|
| 285 |
+
return gr.HTML(full_html)
|
| 286 |
|
| 287 |
# # --- Detailed Benchmark Display ---
|
| 288 |
def create_benchmark_details_display(
|