NathanRoll commited on
Commit
cf113fe
·
verified ·
1 Parent(s): e17c443

Fix family navigation and compact landing page

Browse files
Files changed (1) hide show
  1. app.py +32 -10
app.py CHANGED
@@ -29,6 +29,7 @@ DATA_DIR = SPACE_ROOT / "data"
29
  DATA_DIR.mkdir(parents=True, exist_ok=True)
30
  HYDRATE_STATUS = maybe_hydrate_from_dataset(DATA_DIR)
31
  STORE = SolutionStore(DATA_DIR)
 
32
 
33
 
34
  CSS = """
@@ -91,7 +92,7 @@ gradio-app,
91
  }
92
 
93
  .packing-shell {
94
- min-height: 100vh;
95
  background: var(--page);
96
  color: var(--ink);
97
  font-family: Helvetica, Arial, sans-serif !important;
@@ -1168,9 +1169,7 @@ def top_nav() -> str:
1168
 
1169
 
1170
  def directory_html() -> str:
1171
- summaries = [setup_summary(setup) for setup in setup_choices()]
1172
- coordinates = coordinate_records_by_case()
1173
- family_cards = "".join(family_card(summary, coordinates) for summary in summaries)
1174
  return f"""
1175
  <main class="packing-shell" id="top">
1176
  <section class="hero-stage">
@@ -1183,6 +1182,7 @@ def directory_html() -> str:
1183
  Friedman rows keep their credited finder; rendered cards report our verified coordinate metric and
1184
  mark unrecovered references in orange.
1185
  </p>
 
1186
  </div>
1187
  </div>
1188
  </section>
@@ -1193,11 +1193,10 @@ def directory_html() -> str:
1193
  <div>
1194
  <h2>Choose a family</h2>
1195
  <p class="section-note">
1196
- Use the Family Records page to open a family. Each tile previews the n=10 rendering for that setup.
1197
  </p>
1198
  </div>
1199
  </div>
1200
- <div class="family-grid">{family_cards}</div>
1201
  </div>
1202
  </section>
1203
  </main>
@@ -1208,6 +1207,20 @@ def browse_html() -> str:
1208
  return directory_html()
1209
 
1210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1211
  def leaderboard_html() -> str:
1212
  rows: dict[str, dict[str, Any]] = {}
1213
  coordinates = coordinate_records_by_case()
@@ -1360,6 +1373,8 @@ def submit_solution(
1360
 
1361
 
1362
  def update_family_page(setup: str):
 
 
1363
  return family_page_html(setup)
1364
 
1365
 
@@ -1370,17 +1385,23 @@ with gr.Blocks(title="Packing Benchmark") as demo:
1370
  with gr.Tabs():
1371
  with gr.Tab("Families"):
1372
  browse_page = gr.HTML(directory_html())
 
 
 
 
 
 
 
1373
 
1374
  with gr.Tab("Family Records"):
1375
  choices = setup_choices()
1376
- initial_setup = choices[0] if choices else ""
1377
  family_select = gr.Dropdown(
1378
- choices=choices,
1379
- value=initial_setup,
1380
  label="Family",
1381
  elem_id="family-selector",
1382
  )
1383
- family_page = gr.HTML(family_page_html(initial_setup))
1384
 
1385
  with gr.Tab("Leaderboard"):
1386
  leaderboard_page = gr.HTML(leaderboard_html())
@@ -1404,6 +1425,7 @@ with gr.Blocks(title="Packing Benchmark") as demo:
1404
  preview = gr.HTML(label="Browser render")
1405
  normalized_json = gr.Code(label="Normalized JSON", language="json", lines=10)
1406
 
 
1407
  family_select.change(update_family_page, inputs=[family_select], outputs=[family_page])
1408
  verify_btn.click(verify_only, inputs=[json_code, json_file, tolerance], outputs=[report, preview, normalized_json])
1409
  submit_btn.click(
 
29
  DATA_DIR.mkdir(parents=True, exist_ok=True)
30
  HYDRATE_STATUS = maybe_hydrate_from_dataset(DATA_DIR)
31
  STORE = SolutionStore(DATA_DIR)
32
+ FAMILY_PROMPT = "Select a family..."
33
 
34
 
35
  CSS = """
 
92
  }
93
 
94
  .packing-shell {
95
+ min-height: 0;
96
  background: var(--page);
97
  color: var(--ink);
98
  font-family: Helvetica, Arial, sans-serif !important;
 
1169
 
1170
 
1171
  def directory_html() -> str:
1172
+ choices = setup_choices()
 
 
1173
  return f"""
1174
  <main class="packing-shell" id="top">
1175
  <section class="hero-stage">
 
1182
  Friedman rows keep their credited finder; rendered cards report our verified coordinate metric and
1183
  mark unrecovered references in orange.
1184
  </p>
1185
+ <p class="hero-stats">{len(choices)} supported families. Choose one below to load its records.</p>
1186
  </div>
1187
  </div>
1188
  </section>
 
1193
  <div>
1194
  <h2>Choose a family</h2>
1195
  <p class="section-note">
1196
+ Use the selector below. Records load only after a family is selected, so the front page stays short.
1197
  </p>
1198
  </div>
1199
  </div>
 
1200
  </div>
1201
  </section>
1202
  </main>
 
1207
  return directory_html()
1208
 
1209
 
1210
+ def empty_family_html() -> str:
1211
+ return """
1212
+ <main class="packing-shell">
1213
+ <section class="section">
1214
+ <div class="contain">
1215
+ <div class="page-card">
1216
+ <p>Select a family to view verified coordinate renderings and record details.</p>
1217
+ </div>
1218
+ </div>
1219
+ </section>
1220
+ </main>
1221
+ """
1222
+
1223
+
1224
  def leaderboard_html() -> str:
1225
  rows: dict[str, dict[str, Any]] = {}
1226
  coordinates = coordinate_records_by_case()
 
1373
 
1374
 
1375
  def update_family_page(setup: str):
1376
+ if not setup or setup == FAMILY_PROMPT:
1377
+ return empty_family_html()
1378
  return family_page_html(setup)
1379
 
1380
 
 
1385
  with gr.Tabs():
1386
  with gr.Tab("Families"):
1387
  browse_page = gr.HTML(directory_html())
1388
+ home_family_select = gr.Dropdown(
1389
+ choices=[FAMILY_PROMPT, *setup_choices()],
1390
+ value=FAMILY_PROMPT,
1391
+ label="Family",
1392
+ elem_id="home-family-selector",
1393
+ )
1394
+ home_family_page = gr.HTML(empty_family_html())
1395
 
1396
  with gr.Tab("Family Records"):
1397
  choices = setup_choices()
 
1398
  family_select = gr.Dropdown(
1399
+ choices=[FAMILY_PROMPT, *choices],
1400
+ value=FAMILY_PROMPT,
1401
  label="Family",
1402
  elem_id="family-selector",
1403
  )
1404
+ family_page = gr.HTML(empty_family_html())
1405
 
1406
  with gr.Tab("Leaderboard"):
1407
  leaderboard_page = gr.HTML(leaderboard_html())
 
1425
  preview = gr.HTML(label="Browser render")
1426
  normalized_json = gr.Code(label="Normalized JSON", language="json", lines=10)
1427
 
1428
+ home_family_select.change(update_family_page, inputs=[home_family_select], outputs=[home_family_page])
1429
  family_select.change(update_family_page, inputs=[family_select], outputs=[family_page])
1430
  verify_btn.click(verify_only, inputs=[json_code, json_file, tolerance], outputs=[report, preview, normalized_json])
1431
  submit_btn.click(