space: force dark via CSS variable override (removes JS redirect lag)
Browse files
app.py
CHANGED
|
@@ -246,6 +246,9 @@ def refresh_gallery():
|
|
| 246 |
|
| 247 |
|
| 248 |
CUSTOM_CSS = r"""
|
|
|
|
|
|
|
|
|
|
| 249 |
:root {
|
| 250 |
--grad-a: #a78bfa;
|
| 251 |
--grad-b: #f472b6;
|
|
@@ -255,6 +258,50 @@ CUSTOM_CSS = r"""
|
|
| 255 |
--border-card: rgba(167, 139, 250, 0.32);
|
| 256 |
--text-main: #f1f5f9;
|
| 257 |
--text-mute: #94a3b8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
}
|
| 259 |
|
| 260 |
.gradio-container { max-width: 1100px !important; margin: 0 auto !important; padding-left: 1rem !important; padding-right: 1rem !important; }
|
|
@@ -1239,23 +1286,11 @@ That's the project's central constraint and its main flex on AMD's headline GPU.
|
|
| 1239 |
"""
|
| 1240 |
|
| 1241 |
|
| 1242 |
-
FORCE_DARK_JS = """
|
| 1243 |
-
() => {
|
| 1244 |
-
const url = new URL(window.location);
|
| 1245 |
-
if (url.searchParams.get('__theme') !== 'dark') {
|
| 1246 |
-
url.searchParams.set('__theme', 'dark');
|
| 1247 |
-
window.location.href = url.href;
|
| 1248 |
-
}
|
| 1249 |
-
}
|
| 1250 |
-
"""
|
| 1251 |
-
|
| 1252 |
-
|
| 1253 |
def build_ui():
|
| 1254 |
with gr.Blocks(
|
| 1255 |
theme=gr.themes.Base(primary_hue="violet", secondary_hue="pink",
|
| 1256 |
neutral_hue="slate"),
|
| 1257 |
css=CUSTOM_CSS,
|
| 1258 |
-
js=FORCE_DARK_JS,
|
| 1259 |
title="StudioMI300",
|
| 1260 |
) as demo:
|
| 1261 |
gr.HTML(HERO_HTML)
|
|
|
|
| 246 |
|
| 247 |
|
| 248 |
CUSTOM_CSS = r"""
|
| 249 |
+
/* Force dark theme regardless of system / browser preference.
|
| 250 |
+
Overrides Gradio's neutral scale (used as bg in light mode) to dark values
|
| 251 |
+
so the page renders the same way whether or not .dark class is present. */
|
| 252 |
:root {
|
| 253 |
--grad-a: #a78bfa;
|
| 254 |
--grad-b: #f472b6;
|
|
|
|
| 258 |
--border-card: rgba(167, 139, 250, 0.32);
|
| 259 |
--text-main: #f1f5f9;
|
| 260 |
--text-mute: #94a3b8;
|
| 261 |
+
color-scheme: dark;
|
| 262 |
+
}
|
| 263 |
+
html, body, gradio-app, .gradio-container {
|
| 264 |
+
background: #020617 !important;
|
| 265 |
+
color: #f1f5f9 !important;
|
| 266 |
+
}
|
| 267 |
+
.gradio-container,
|
| 268 |
+
gradio-app {
|
| 269 |
+
--body-background-fill: #020617;
|
| 270 |
+
--body-background-fill-dark: #020617;
|
| 271 |
+
--background-fill-primary: #0f172a;
|
| 272 |
+
--background-fill-primary-dark: #0f172a;
|
| 273 |
+
--background-fill-secondary: #1e293b;
|
| 274 |
+
--background-fill-secondary-dark: #1e293b;
|
| 275 |
+
--block-background-fill: #0f172a;
|
| 276 |
+
--block-background-fill-dark: #0f172a;
|
| 277 |
+
--block-border-color: rgba(167, 139, 250, 0.32);
|
| 278 |
+
--block-border-color-dark: rgba(167, 139, 250, 0.32);
|
| 279 |
+
--border-color-primary: rgba(167, 139, 250, 0.32);
|
| 280 |
+
--border-color-primary-dark: rgba(167, 139, 250, 0.32);
|
| 281 |
+
--input-background-fill: #0f172a;
|
| 282 |
+
--input-background-fill-dark: #0f172a;
|
| 283 |
+
--input-border-color: rgba(167, 139, 250, 0.32);
|
| 284 |
+
--input-border-color-dark: rgba(167, 139, 250, 0.32);
|
| 285 |
+
--button-secondary-background-fill: #1e293b;
|
| 286 |
+
--button-secondary-background-fill-dark: #1e293b;
|
| 287 |
+
--button-secondary-text-color: #f1f5f9;
|
| 288 |
+
--button-secondary-text-color-dark: #f1f5f9;
|
| 289 |
+
--body-text-color: #f1f5f9;
|
| 290 |
+
--body-text-color-dark: #f1f5f9;
|
| 291 |
+
--body-text-color-subdued: #94a3b8;
|
| 292 |
+
--body-text-color-subdued-dark: #94a3b8;
|
| 293 |
+
--color-accent: #a78bfa;
|
| 294 |
+
--color-accent-soft: rgba(167, 139, 250, 0.15);
|
| 295 |
+
--neutral-50: #1e293b;
|
| 296 |
+
--neutral-100: #1e293b;
|
| 297 |
+
--neutral-200: #334155;
|
| 298 |
+
--neutral-300: #475569;
|
| 299 |
+
--neutral-400: #64748b;
|
| 300 |
+
--neutral-500: #94a3b8;
|
| 301 |
+
--neutral-600: #cbd5e1;
|
| 302 |
+
--neutral-700: #e2e8f0;
|
| 303 |
+
--neutral-800: #f1f5f9;
|
| 304 |
+
--neutral-900: #f8fafc;
|
| 305 |
}
|
| 306 |
|
| 307 |
.gradio-container { max-width: 1100px !important; margin: 0 auto !important; padding-left: 1rem !important; padding-right: 1rem !important; }
|
|
|
|
| 1286 |
"""
|
| 1287 |
|
| 1288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1289 |
def build_ui():
|
| 1290 |
with gr.Blocks(
|
| 1291 |
theme=gr.themes.Base(primary_hue="violet", secondary_hue="pink",
|
| 1292 |
neutral_hue="slate"),
|
| 1293 |
css=CUSTOM_CSS,
|
|
|
|
| 1294 |
title="StudioMI300",
|
| 1295 |
) as demo:
|
| 1296 |
gr.HTML(HERO_HTML)
|