LaelaZ commited on
Commit
42998b1
·
verified ·
1 Parent(s): 75bd1a0

Force light theme + light-surface safety (HF defaults to dark)

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -149,6 +149,9 @@ CSS = """
149
  --nn-card:#ffffff; --nn-line:rgba(15,23,42,.08); --nn-accent:%s;
150
  --nn-font:'Plus Jakarta Sans','Inter',system-ui,sans-serif;
151
  }
 
 
 
152
  .gradio-container { max-width: 880px !important; background:
153
  radial-gradient(1200px 500px at 15%% -10%%, var(--nn-bg1), transparent 60%%),
154
  radial-gradient(1000px 500px at 110%% 10%%, var(--nn-bg2), transparent 55%%) !important; }
@@ -236,7 +239,19 @@ theme = gr.themes.Soft(
236
  "system-ui", "sans-serif"],
237
  )
238
 
239
- with gr.Blocks(title="Neural Net From Scratch (NumPy)", theme=theme, css=CSS) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
240
  gr.HTML(
241
  '<div id="nn-head"><span class="nn-pill">DEEP LEARNING · NO FRAMEWORK</span>'
242
  "<h1>A neural network I wrote by hand</h1>"
 
149
  --nn-card:#ffffff; --nn-line:rgba(15,23,42,.08); --nn-accent:%s;
150
  --nn-font:'Plus Jakarta Sans','Inter',system-ui,sans-serif;
151
  }
152
+ /* Safety: keep a light surface even before the light-theme redirect settles. */
153
+ html, body, gradio-app, .dark { background:#ffffff !important; }
154
+ .gradio-container, .gradio-container * { color: var(--nn-ink); }
155
  .gradio-container { max-width: 880px !important; background:
156
  radial-gradient(1200px 500px at 15%% -10%%, var(--nn-bg1), transparent 60%%),
157
  radial-gradient(1000px 500px at 110%% 10%%, var(--nn-bg2), transparent 55%%) !important; }
 
239
  "system-ui", "sans-serif"],
240
  )
241
 
242
+ # Hugging Face Spaces default to dark mode. This bespoke UI is designed light, so
243
+ # force the light theme on load (one redirect if the param is missing, then never again).
244
+ FORCE_LIGHT = """
245
+ function() {
246
+ const u = new URL(window.location.href);
247
+ if (u.searchParams.get('__theme') !== 'light') {
248
+ u.searchParams.set('__theme', 'light');
249
+ window.location.replace(u.href);
250
+ }
251
+ }
252
+ """
253
+
254
+ with gr.Blocks(title="Neural Net From Scratch (NumPy)", theme=theme, css=CSS, js=FORCE_LIGHT) as demo:
255
  gr.HTML(
256
  '<div id="nn-head"><span class="nn-pill">DEEP LEARNING · NO FRAMEWORK</span>'
257
  "<h1>A neural network I wrote by hand</h1>"