Spaces:
Running on Zero
Running on Zero
fix(ui): drawer toggle via JS class-flip — Gradio CSS scope breaks :has()
Browse files
app.py
CHANGED
|
@@ -147,7 +147,6 @@ _CUSTOM_CSS = """
|
|
| 147 |
border-bottom: 1px solid #262C35;
|
| 148 |
background: #12161B;
|
| 149 |
}
|
| 150 |
-
.aio-ham-toggle { display: none; } /* hidden checkbox drives drawer state */
|
| 151 |
.aio-ham-label {
|
| 152 |
display: none;
|
| 153 |
width: 32px; height: 32px;
|
|
@@ -244,10 +243,11 @@ _CUSTOM_CSS = """
|
|
| 244 |
max-width: 80vw;
|
| 245 |
overflow: hidden;
|
| 246 |
}
|
| 247 |
-
/*
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
|
|
|
| 251 |
content: ""; position: fixed; inset: 0;
|
| 252 |
background: rgba(0,0,0,0.55); z-index: 9;
|
| 253 |
}
|
|
@@ -310,12 +310,14 @@ _TOPAZ_THEME = gr.themes.Base(
|
|
| 310 |
|
| 311 |
def build_app() -> gr.Blocks:
|
| 312 |
with gr.Blocks(theme=_TOPAZ_THEME, title="LTX 2.3 Studio", css=_CUSTOM_CSS) as app:
|
| 313 |
-
# Header: hamburger
|
| 314 |
-
#
|
| 315 |
gr.HTML(
|
| 316 |
'<div class="aio-header">'
|
| 317 |
-
' <
|
| 318 |
-
'
|
|
|
|
|
|
|
| 319 |
' <span class="aio-title">LTX 2.3 <span class="accent">Studio</span></span>'
|
| 320 |
' <span class="aio-mode-tag" id="aio-mode-tag">T2V</span>'
|
| 321 |
'</div>'
|
|
@@ -376,8 +378,7 @@ def build_app() -> gr.Blocks:
|
|
| 376 |
f"const el = document.getElementById('aio-mode-tag'); "
|
| 377 |
f"if (el) el.textContent = {tag!r}; "
|
| 378 |
f"if (window.matchMedia('(max-width: 1023px)').matches) {{ "
|
| 379 |
-
f"
|
| 380 |
-
f" if (t) t.checked = false; "
|
| 381 |
f"}} return []; }}",
|
| 382 |
)
|
| 383 |
|
|
|
|
| 147 |
border-bottom: 1px solid #262C35;
|
| 148 |
background: #12161B;
|
| 149 |
}
|
|
|
|
| 150 |
.aio-ham-label {
|
| 151 |
display: none;
|
| 152 |
width: 32px; height: 32px;
|
|
|
|
| 243 |
max-width: 80vw;
|
| 244 |
overflow: hidden;
|
| 245 |
}
|
| 246 |
+
/* `.aio-shell.drawer-open` is toggled by the hamburger's inline JS.
|
| 247 |
+
`body:has(:checked)` would be cleaner but Gradio prefixes user CSS
|
| 248 |
+
with `.gradio-container .contain `, breaking ancestor selectors. */
|
| 249 |
+
.aio-shell.drawer-open .aio-drawer { left: 0; }
|
| 250 |
+
.aio-shell.drawer-open::before {
|
| 251 |
content: ""; position: fixed; inset: 0;
|
| 252 |
background: rgba(0,0,0,0.55); z-index: 9;
|
| 253 |
}
|
|
|
|
| 310 |
|
| 311 |
def build_app() -> gr.Blocks:
|
| 312 |
with gr.Blocks(theme=_TOPAZ_THEME, title="LTX 2.3 Studio", css=_CUSTOM_CSS) as app:
|
| 313 |
+
# Header: hamburger button toggles `.drawer-open` class on `.aio-shell`
|
| 314 |
+
# via inline JS (Gradio prefixes user CSS so `body:has(:checked)` breaks).
|
| 315 |
gr.HTML(
|
| 316 |
'<div class="aio-header">'
|
| 317 |
+
' <button type="button" class="aio-ham-label" '
|
| 318 |
+
' onclick="document.querySelector(\'.aio-shell\')'
|
| 319 |
+
'?.classList.toggle(\'drawer-open\')" '
|
| 320 |
+
' aria-label="Toggle navigation">≡</button>'
|
| 321 |
' <span class="aio-title">LTX 2.3 <span class="accent">Studio</span></span>'
|
| 322 |
' <span class="aio-mode-tag" id="aio-mode-tag">T2V</span>'
|
| 323 |
'</div>'
|
|
|
|
| 378 |
f"const el = document.getElementById('aio-mode-tag'); "
|
| 379 |
f"if (el) el.textContent = {tag!r}; "
|
| 380 |
f"if (window.matchMedia('(max-width: 1023px)').matches) {{ "
|
| 381 |
+
f" document.querySelector('.aio-shell')?.classList.remove('drawer-open'); "
|
|
|
|
| 382 |
f"}} return []; }}",
|
| 383 |
)
|
| 384 |
|