techfreakworm commited on
Commit
666a16c
·
unverified ·
1 Parent(s): c726478

feat(ui): mode tag updates + auto-close drawer on mobile select

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -357,12 +357,26 @@ def build_app() -> gr.Blocks:
357
  outputs=[h["status"], h["video_out"]],
358
  )
359
 
360
- # Sidebar mode buttons drive Tabs.selected via Gradio's update.
 
 
 
 
 
 
361
  for name, btn in mode_buttons.items():
 
362
  btn.click(
363
  fn=lambda mode_id=name: gr.Tabs(selected=mode_id),
364
  inputs=None,
365
  outputs=[tabs_component],
 
 
 
 
 
 
 
366
  )
367
 
368
  # Sidebar model info wiring
 
357
  outputs=[h["status"], h["video_out"]],
358
  )
359
 
360
+ # JS to update the header mode tag without a server round-trip.
361
+ # Each mode button injects a tiny on-click that rewrites #aio-mode-tag
362
+ # and (on mobile) auto-collapses the drawer.
363
+ _MODE_TAG_BY_NAME = {
364
+ "t2v": "T2V", "a2v": "A2V", "i2v": "I2V",
365
+ "lipsync": "LIPSYNC", "keyframe": "KEY", "style": "STYLE",
366
+ }
367
  for name, btn in mode_buttons.items():
368
+ tag = _MODE_TAG_BY_NAME.get(name, name.upper())
369
  btn.click(
370
  fn=lambda mode_id=name: gr.Tabs(selected=mode_id),
371
  inputs=None,
372
  outputs=[tabs_component],
373
+ js=f"() => {{ "
374
+ f"const el = document.getElementById('aio-mode-tag'); "
375
+ f"if (el) el.textContent = {tag!r}; "
376
+ f"if (window.matchMedia('(max-width: 1023px)').matches) {{ "
377
+ f" const t = document.getElementById('aio-ham-toggle'); "
378
+ f" if (t) t.checked = false; "
379
+ f"}} return []; }}",
380
  )
381
 
382
  # Sidebar model info wiring