Spaces:
Sleeping
Sleeping
File size: 4,330 Bytes
331f0f2 bf9c9e3 331f0f2 bf9c9e3 331f0f2 57fa516 331f0f2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | """Top header β brand mark + Generation + Preset + chrome nav.
Linear-inspired: hairline border, 13px nav labels, restrained type, light pill CTA.
NOTE: NO `gr.Radio` for chrome. Preset uses two `gr.Button`s with active class
flipped via state in app.py. Generation stays as `gr.Dropdown`.
"""
from __future__ import annotations
import gradio as gr
def build_header() -> dict:
with gr.Row(elem_id="ws-header", elem_classes=["ws-header-row"]):
# ββ Brand mark ββββββββββββββββββββββββββββββββββββββββββββββββββββ
with gr.Column(scale=1, min_width=240, elem_classes=["ws-chrome-col", "ws-brand-col"]):
# Brand + hamburger live together so the mobile drawer trigger
# sits naturally to the left of the monogram. The hamburger is
# hidden via CSS on desktop (β₯1024px); click is wired in the
# nav-JS block in app.py (no Gradio event handler).
gr.HTML(
"""
<div class="ws-brand">
<button class="ws-hamburger" id="ws-hamburger" type="button" aria-label="Open menu" aria-controls="ws-sidebar">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
<line x1="3" y1="6" x2="21" y2="6"/>
<line x1="3" y1="12" x2="21" y2="12"/>
<line x1="3" y1="18" x2="21" y2="18"/>
</svg>
</button>
<div class="ws-brand-mark"></div>
<div class="ws-brand-text">
<span class="ws-brand-name">Wan Studio</span>
<span class="ws-brand-sub">studio Β· video diffusion</span>
</div>
</div>
""",
elem_id="ws-brand-html",
)
# ββ Generation dropdown ββββββββββββββββββββββββββββββββββββββββββ
with gr.Column(scale=0, min_width=150, elem_classes=["ws-chrome-col"]):
generation = gr.Dropdown(
choices=[("Wan 2.1", "wan2.1"), ("Wan 2.2", "wan2.2")],
value="wan2.1",
label="Generation",
show_label=False,
interactive=True,
container=False,
elem_classes=["ws-dropdown"],
)
# ββ Preset toggle (two pill buttons + state) βββββββββββββββββββββ
with gr.Column(scale=0, min_width=160, elem_classes=["ws-chrome-col"]):
preset_state = gr.State("fast")
with gr.Row(elem_classes=["ws-preset-group"]):
preset_fast = gr.Button(
"Fast",
elem_classes=["ws-pill", "ws-pill-active"],
elem_id="ws-preset-fast",
)
preset_quality = gr.Button(
"Quality",
elem_classes=["ws-pill"],
elem_id="ws-preset-quality",
)
# ββ Chrome nav buttons βββββββββββββββββββββββββββββββββββββββββββ
with gr.Column(scale=0, min_width=200, elem_classes=["ws-chrome-col", "ws-chrome-right"]):
with gr.Row(elem_classes=["ws-chrome-actions"]):
history_btn = gr.Button(
"History",
elem_classes=["ws-nav-btn"],
elem_id="ws-history-btn",
)
settings_btn = gr.Button(
"Settings",
elem_classes=["ws-nav-btn"],
elem_id="ws-settings-btn",
)
return {
"generation": generation,
# back-compat alias: app.py reads header["preset"] to seed about-block.
"preset": preset_state,
"preset_state": preset_state,
"preset_fast": preset_fast,
"preset_quality": preset_quality,
"history_btn": history_btn,
"settings_btn": settings_btn,
}
|