jdesiree commited on
Commit
9fe7019
·
verified ·
1 Parent(s): 89d98dc

Forcing light mode at the application level using Javascript.

Browse files
Files changed (1) hide show
  1. app.py +18 -74
app.py CHANGED
@@ -317,50 +317,9 @@ custom_css = """
317
  /* Import Oswald font - Google Fonts */
318
  @import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap');
319
 
320
- /* Force light mode at root level */
321
- :root {
322
- color-scheme: light !important;
323
- }
324
-
325
- /* Override ALL dark mode media queries */
326
- @media (prefers-color-scheme: dark) {
327
- * {
328
- color-scheme: light !important;
329
- }
330
-
331
- html, body {
332
- background-color: rgb(240, 236, 230) !important;
333
- color: #120f0e !important;
334
- }
335
-
336
- .gradio-container-5-42-0 {
337
- color-scheme: light !important;
338
- background-color: rgb(240, 236, 230) !important;
339
- }
340
-
341
- /* Target ALL possible chat elements in dark mode */
342
- .placeholder-content,
343
- .placeholder-content.svelte-9pi8y1,
344
- .placeholder-content.svelte-9pi8y1[role="complementary"],
345
- div[role="complementary"],
346
- .gradio-chatbot,
347
- .gradio-chatbot *,
348
- .chatbot,
349
- [data-testid="chatbot"],
350
- [data-testid="chatbot"] *,
351
- .scroll-hide,
352
- .overflow-y-auto {
353
- background-color: #d9d1ce !important;
354
- background: #d9d1ce !important;
355
- color: #120f0e !important;
356
- }
357
- }
358
-
359
- html, body {
360
- color-scheme: light !important;
361
- background-color: rgb(240, 236, 230) !important;
362
- margin: 0 !important;
363
- padding: 0 !important;
364
  color: #120f0e !important;
365
  }
366
 
@@ -371,13 +330,6 @@ html, body {
371
  color: #120f0e !important;
372
  padding-top: 0 !important;
373
  margin-top: 0 !important;
374
- color-scheme: light !important;
375
- }
376
-
377
- /* Apply Oswald globally */
378
- *, *::before, *::after {
379
- font-family: "Oswald", sans-serif !important;
380
- color: #120f0e !important;
381
  }
382
 
383
  /* Title styling */
@@ -396,31 +348,15 @@ html, body {
396
  padding: 0;
397
  }
398
 
399
- /* AGGRESSIVE chat styling - target everything */
400
  .chat-container,
401
  .gradio-container-5-42-0 .gradio-chatbot,
402
- .gradio-container-5-42-0 #main-chatbot,
403
- .gradio-container-5-42-0 .gradio-chatbot > div,
404
- .gradio-container-5-42-0 .gradio-chatbot .scroll-hide,
405
- .gradio-container-5-42-0 .gradio-chatbot .overflow-y-auto,
406
- .placeholder-content,
407
- .placeholder-content.svelte-9pi8y1,
408
- .placeholder-content.svelte-9pi8y1[role="complementary"],
409
- div[role="complementary"] {
410
  background-color: #d9d1ce !important;
411
- background: #d9d1ce !important;
412
  border: 1pt solid #59524f !important;
413
  border-radius: 6px !important;
414
  padding: 20px !important;
415
  min-height: 900px;
416
- color: #120f0e !important;
417
- }
418
-
419
- /* Force all nested elements */
420
- .gradio-container-5-42-0 .gradio-chatbot *:not(.message) {
421
- background-color: #d9d1ce !important;
422
- background: #d9d1ce !important;
423
- color: #120f0e !important;
424
  }
425
 
426
  /* Message styling */
@@ -450,11 +386,6 @@ div[role="complementary"] {
450
  font-weight: 400 !important;
451
  }
452
 
453
- /* Hide avatars */
454
- .gradio-container-5-42-0 .gradio-chatbot .avatar-container {
455
- display: none !important;
456
- }
457
-
458
  /* Input section styling */
459
  .input-section {
460
  background-color: rgb(240, 236, 230) !important;
@@ -513,6 +444,19 @@ html_head_content = '''
513
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
514
  <link href="https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap" rel="stylesheet">
515
  <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
516
  '''
517
 
518
  # --- UI: MathJax Configuration ---
 
317
  /* Import Oswald font - Google Fonts */
318
  @import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap');
319
 
320
+ /* Apply Oswald globally */
321
+ *, *::before, *::after {
322
+ font-family: "Oswald", sans-serif !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  color: #120f0e !important;
324
  }
325
 
 
330
  color: #120f0e !important;
331
  padding-top: 0 !important;
332
  margin-top: 0 !important;
 
 
 
 
 
 
 
333
  }
334
 
335
  /* Title styling */
 
348
  padding: 0;
349
  }
350
 
351
+ /* Chat styling */
352
  .chat-container,
353
  .gradio-container-5-42-0 .gradio-chatbot,
354
+ .gradio-container-5-42-0 #main-chatbot {
 
 
 
 
 
 
 
355
  background-color: #d9d1ce !important;
 
356
  border: 1pt solid #59524f !important;
357
  border-radius: 6px !important;
358
  padding: 20px !important;
359
  min-height: 900px;
 
 
 
 
 
 
 
 
360
  }
361
 
362
  /* Message styling */
 
386
  font-weight: 400 !important;
387
  }
388
 
 
 
 
 
 
389
  /* Input section styling */
390
  .input-section {
391
  background-color: rgb(240, 236, 230) !important;
 
444
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
445
  <link href="https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap" rel="stylesheet">
446
  <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
447
+ <script>
448
+ // Force light theme in Gradio
449
+ window.addEventListener('DOMContentLoaded', function () {
450
+ const gradioURL = window.location.href;
451
+ const url = new URL(gradioURL);
452
+ const currentTheme = url.searchParams.get('__theme');
453
+
454
+ if (currentTheme !== 'light') {
455
+ url.searchParams.set('__theme', 'light');
456
+ window.location.replace(url.toString());
457
+ }
458
+ });
459
+ </script>
460
  '''
461
 
462
  # --- UI: MathJax Configuration ---