Spaces:
Running
Running
Space: force light theme (dark-mode text was white on parchment), remove per-page brand text, picker as sidebar + framed canvas stage
Browse files
app.py
CHANGED
|
@@ -51,9 +51,20 @@ THEME = ('<style>'
|
|
| 51 |
'body,gradio-app,.gradio-container{background:#f3ebdc !important;color:#141821;'
|
| 52 |
"font-family:'Space Grotesk',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif !important;}"
|
| 53 |
".gradio-container h1{font-family:'Fraunces',Georgia,serif !important;color:#141821;}"
|
|
|
|
|
|
|
|
|
|
| 54 |
'</style>')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
HEAD = ('<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">'
|
| 56 |
-
+ HIDE_TABS + FONTS + THEME +
|
| 57 |
'<link rel="stylesheet" href="/web/shell/sidebar.css">'
|
| 58 |
'<link rel="stylesheet" href="/web/shell/spriteScene.css">'
|
| 59 |
'<script type="module" src="/web/tiny.js"></script>'
|
|
@@ -108,16 +119,15 @@ def diary(unit: str, traits: str) -> str:
|
|
| 108 |
|
| 109 |
with gr.Blocks(title="Tiny Army") as demo:
|
| 110 |
gr.HTML(SIDEBAR_HTML)
|
| 111 |
-
gr.Markdown("# ⚔️ Tiny Army\n*Every fighter writes its own legend — and the "
|
| 112 |
-
"legend is true.* Built on Gradio; sprites + engine reused from "
|
| 113 |
-
"auto-battler, rendered with Pixi.")
|
| 114 |
with gr.Tabs():
|
| 115 |
with gr.Tab("Battle") as battle_tab:
|
| 116 |
gr.HTML(f'<div id="battle-stage" style="{STAGE}"></div>')
|
| 117 |
with gr.Tab("Sprite Animations") as sprite_tab:
|
| 118 |
# The shared playground (web/playground.js) builds the whole page —
|
| 119 |
-
# team picker
|
| 120 |
-
|
|
|
|
|
|
|
| 121 |
# Pixi canvases start hidden (0×0); re-measure them when a tab is shown.
|
| 122 |
battle_tab.select(None, None, None, js="()=>window.tinyResize&&window.tinyResize()")
|
| 123 |
sprite_tab.select(None, None, None, js="()=>window.tinyResize&&window.tinyResize()")
|
|
|
|
| 51 |
'body,gradio-app,.gradio-container{background:#f3ebdc !important;color:#141821;'
|
| 52 |
"font-family:'Space Grotesk',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif !important;}"
|
| 53 |
".gradio-container h1{font-family:'Fraunces',Georgia,serif !important;color:#141821;}"
|
| 54 |
+
# Sprite tab: picker = unframed sidebar, canvas = the framed pixi stage.
|
| 55 |
+
'#sprite-stage .movement-picker{border-right:0;}'
|
| 56 |
+
'#sprite-stage .movement-stage{border:2px solid #141821;}'
|
| 57 |
'</style>')
|
| 58 |
+
# Force Gradio's LIGHT theme. Gradio honours the OS dark mode, where its text goes
|
| 59 |
+
# white (#f3f4f6) — unreadable on our parchment background. Redirecting to
|
| 60 |
+
# `?__theme=light` makes it use light component backgrounds + dark text everywhere.
|
| 61 |
+
# The session guard prevents a redirect loop if the query were ever stripped.
|
| 62 |
+
FORCE_LIGHT = ('<script>(function(){try{var u=new URL(location.href);'
|
| 63 |
+
"if(u.searchParams.get('__theme')!=='light'&&!sessionStorage.getItem('ta_themed')){"
|
| 64 |
+
"sessionStorage.setItem('ta_themed','1');u.searchParams.set('__theme','light');"
|
| 65 |
+
'location.replace(u.href);}}catch(e){}})();</script>')
|
| 66 |
HEAD = ('<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">'
|
| 67 |
+
+ FORCE_LIGHT + HIDE_TABS + FONTS + THEME +
|
| 68 |
'<link rel="stylesheet" href="/web/shell/sidebar.css">'
|
| 69 |
'<link rel="stylesheet" href="/web/shell/spriteScene.css">'
|
| 70 |
'<script type="module" src="/web/tiny.js"></script>'
|
|
|
|
| 119 |
|
| 120 |
with gr.Blocks(title="Tiny Army") as demo:
|
| 121 |
gr.HTML(SIDEBAR_HTML)
|
|
|
|
|
|
|
|
|
|
| 122 |
with gr.Tabs():
|
| 123 |
with gr.Tab("Battle") as battle_tab:
|
| 124 |
gr.HTML(f'<div id="battle-stage" style="{STAGE}"></div>')
|
| 125 |
with gr.Tab("Sprite Animations") as sprite_tab:
|
| 126 |
# The shared playground (web/playground.js) builds the whole page —
|
| 127 |
+
# team picker (a sidebar) + the framed canvas stage + chrome — into this
|
| 128 |
+
# div. No dark box here: the picker is the sidebar, the canvas is the
|
| 129 |
+
# stage (framed by CSS), so it mirrors auto-battler's layout.
|
| 130 |
+
gr.HTML('<div id="sprite-stage" style="height:64vh;overflow:hidden"></div>')
|
| 131 |
# Pixi canvases start hidden (0×0); re-measure them when a tab is shown.
|
| 132 |
battle_tab.select(None, None, None, js="()=>window.tinyResize&&window.tinyResize()")
|
| 133 |
sprite_tab.select(None, None, None, js="()=>window.tinyResize&&window.tinyResize()")
|