techatcreated commited on
Commit
c2beb41
·
verified ·
1 Parent(s): 840c45d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +144 -52
app.py CHANGED
@@ -426,69 +426,48 @@ def age_preview(age_text, parse_mode):
426
  # =========================
427
  CSS = """
428
  /* =========================================================
429
- FORCE SINGLE LIGHT THEME (fix dark-mode device issues)
430
  ========================================================= */
431
 
432
- /* Stop UA dark rendering on inputs/cards */
433
- html, body, .gradio-container {
 
 
434
  color-scheme: light !important;
435
  background: #f6f7fb !important;
436
  color: #0f172a !important;
437
  }
438
 
439
- /* Gradio toggles dark mode using one of these (varies by version) */
440
  .dark, .dark body, .dark .gradio-container,
441
- [data-theme="dark"], [data-theme="dark"] body, [data-theme="dark"] .gradio-container {
442
  color-scheme: light !important;
443
  background: #f6f7fb !important;
444
  color: #0f172a !important;
445
-
446
- /* Override Gradio theme tokens */
447
- --body-background-fill: #f6f7fb !important;
448
- --body-background-fill-secondary: #ffffff !important;
449
- --body-text-color: #0f172a !important;
450
- --body-text-color-subdued: #64748b !important;
451
-
452
- --background-fill-primary: #f6f7fb !important;
453
- --background-fill-secondary: #ffffff !important;
454
- --block-background-fill: #ffffff !important;
455
-
456
- --border-color-primary: #e5e7eb !important;
457
-
458
- --input-background-fill: #ffffff !important;
459
- --input-border-color: #e5e7eb !important;
460
- --input-text-color: #0f172a !important;
461
-
462
- --button-primary-background-fill: #2563eb !important;
463
- --button-primary-text-color: #ffffff !important;
464
- }
465
-
466
- /* Ensure hero/header never inherits "dark" text colors */
467
- .hero, .hero * {
468
- color: #0f172a !important;
469
- }
470
- .hero p {
471
- color: #64748b !important;
472
  }
473
 
474
- /* Force form controls to stay readable on mobile dark mode */
475
- .gradio-container input,
476
- .gradio-container textarea,
477
- .gradio-container select {
478
- color: #0f172a !important;
479
- background: #ffffff !important;
 
480
  }
481
 
482
- /* Hide any theme toggles (selectors differ across Gradio versions) */
483
  #theme-toggle,
484
  .theme-toggle,
485
  button[aria-label*="theme" i],
486
  button[aria-label*="dark" i],
487
  button[title*="theme" i],
488
  button[title*="dark" i]{
489
- display: none !important;
490
  }
491
 
 
 
 
492
  :root{
493
  --bg:#f6f7fb;
494
  --card:#ffffff;
@@ -502,18 +481,38 @@ button[title*="dark" i]{
502
  --radius: 16px;
503
  }
504
 
 
 
 
505
  .gradio-container{
506
- background: var(--bg);
507
- color: var(--text);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
508
  }
509
 
510
- /* Hide Gradio footer / API bar */
511
  footer, .footer, #footer, .gradio-footer { display:none !important; height:0 !important; }
512
 
513
- /* Page wrapper */
514
  #wrap{ max-width: 980px; margin: 0 auto; padding: 14px 12px 28px; }
515
-
516
- /* Make Rows wrap on small screens */
517
  .gr-row{ flex-wrap: wrap !important; gap: 12px !important; }
518
  .gr-column{ min-width: 280px; }
519
 
@@ -526,10 +525,10 @@ footer, .footer, #footer, .gradio-footer { display:none !important; height:0 !im
526
  box-shadow: var(--shadow);
527
  margin-bottom: 12px;
528
  }
529
- .hero h1{ margin:0; font-size: 18px; font-weight: 800; letter-spacing:.2px; }
530
- .hero p{ margin:6px 0 0; color: var(--muted); font-size: 13px; line-height:1.35; }
531
 
532
- /* Card wrapper for inputs/outputs */
533
  .card{
534
  background: var(--card);
535
  border: 1px solid var(--border);
@@ -540,7 +539,100 @@ footer, .footer, #footer, .gradio-footer { display:none !important; height:0 !im
540
 
541
  .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
542
 
543
- /* Results */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
544
  .result-card{
545
  background: #ffffff;
546
  border: 1px solid var(--border);
@@ -549,7 +641,7 @@ footer, .footer, #footer, .gradio-footer { display:none !important; height:0 !im
549
  box-shadow: var(--shadow);
550
  }
551
  .result-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
552
- .result-title{ font-size: 13px; font-weight: 900; letter-spacing:.3px; }
553
 
554
  .grid2{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
555
  .grid3{ display:grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@@ -615,7 +707,7 @@ footer, .footer, #footer, .gradio-footer { display:none !important; height:0 !im
615
  background: #ffffff;
616
  }
617
 
618
- /* Primary button styling + full width on mobile */
619
  #primaryBtn button{
620
  border-radius: 14px !important;
621
  border: 1px solid rgba(37,99,235,.35) !important;
 
426
  # =========================
427
  CSS = """
428
  /* =========================================================
429
+ FIX: Force single LIGHT theme across HF / Gradio / devices
430
  ========================================================= */
431
 
432
+ /* Always render as light */
433
+ :root { color-scheme: light !important; }
434
+
435
+ html, body, .gradio-container{
436
  color-scheme: light !important;
437
  background: #f6f7fb !important;
438
  color: #0f172a !important;
439
  }
440
 
441
+ /* HF + Gradio sometimes set dark theme via class or data attr */
442
  .dark, .dark body, .dark .gradio-container,
443
+ html[data-theme="dark"], body[data-theme="dark"], [data-theme="dark"] .gradio-container{
444
  color-scheme: light !important;
445
  background: #f6f7fb !important;
446
  color: #0f172a !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  }
448
 
449
+ /* Also override when OS prefers dark */
450
+ @media (prefers-color-scheme: dark){
451
+ html, body, .gradio-container{
452
+ color-scheme: light !important;
453
+ background: #f6f7fb !important;
454
+ color: #0f172a !important;
455
+ }
456
  }
457
 
458
+ /* Hide theme toggles (selectors vary by Gradio version) */
459
  #theme-toggle,
460
  .theme-toggle,
461
  button[aria-label*="theme" i],
462
  button[aria-label*="dark" i],
463
  button[title*="theme" i],
464
  button[title*="dark" i]{
465
+ display:none !important;
466
  }
467
 
468
+ /* =========================================================
469
+ Your design tokens
470
+ ========================================================= */
471
  :root{
472
  --bg:#f6f7fb;
473
  --card:#ffffff;
 
481
  --radius: 16px;
482
  }
483
 
484
+ /* =========================================================
485
+ Hard override Gradio theme tokens (this is the KEY fix)
486
+ ========================================================= */
487
  .gradio-container{
488
+ background: var(--bg) !important;
489
+ color: var(--text) !important;
490
+
491
+ --body-background-fill: var(--bg) !important;
492
+ --body-background-fill-secondary: var(--card) !important;
493
+
494
+ --body-text-color: var(--text) !important;
495
+ --body-text-color-subdued: var(--muted) !important;
496
+
497
+ --block-background-fill: var(--card) !important;
498
+ --border-color-primary: var(--border) !important;
499
+
500
+ --input-background-fill: #fbfcff !important;
501
+ --input-border-color: var(--border) !important;
502
+ --input-text-color: var(--text) !important;
503
+
504
+ --button-primary-background-fill: var(--accent) !important;
505
+ --button-primary-text-color: #ffffff !important;
506
+
507
+ --block-label-text-color: var(--text) !important;
508
+ --block-title-text-color: var(--text) !important;
509
  }
510
 
511
+ /* Hide Gradio footer */
512
  footer, .footer, #footer, .gradio-footer { display:none !important; height:0 !important; }
513
 
514
+ /* Wrapper */
515
  #wrap{ max-width: 980px; margin: 0 auto; padding: 14px 12px 28px; }
 
 
516
  .gr-row{ flex-wrap: wrap !important; gap: 12px !important; }
517
  .gr-column{ min-width: 280px; }
518
 
 
525
  box-shadow: var(--shadow);
526
  margin-bottom: 12px;
527
  }
528
+ .hero h1{ margin:0; font-size: 18px; font-weight: 800; letter-spacing:.2px; color: var(--text) !important; }
529
+ .hero p{ margin:6px 0 0; color: var(--muted) !important; font-size: 13px; line-height:1.35; }
530
 
531
+ /* Card wrapper */
532
  .card{
533
  background: var(--card);
534
  border: 1px solid var(--border);
 
539
 
540
  .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
541
 
542
+ /* =========================================================
543
+ FIX INPUTS: borders + dropdown inner-white box removal
544
+ ========================================================= */
545
+
546
+ /* Labels should ALWAYS be dark (not grey) */
547
+ .gradio-container label,
548
+ .gradio-container .label,
549
+ .gradio-container .block-label,
550
+ .gradio-container .wrap > label,
551
+ .gradio-container .form > label{
552
+ color: var(--text) !important;
553
+ font-weight: 600 !important;
554
+ }
555
+
556
+ /* Textbox border (Age) */
557
+ .gradio-container input[type="text"],
558
+ .gradio-container input[type="number"],
559
+ .gradio-container textarea{
560
+ border: 1px solid var(--border) !important;
561
+ background: #fbfcff !important;
562
+ color: var(--text) !important;
563
+ border-radius: 12px !important;
564
+ box-shadow: none !important;
565
+ }
566
+
567
+ /* Dropdown/Combobox wrapper should have border */
568
+ .gradio-container div[role="combobox"],
569
+ .gradio-container div[role="listbox"]{
570
+ border: 1px solid var(--border) !important;
571
+ background: #fbfcff !important;
572
+ border-radius: 12px !important;
573
+ box-shadow: none !important;
574
+ }
575
+
576
+ /* REMOVE the inner "white container" look inside dropdown */
577
+ .gradio-container div[role="combobox"] input{
578
+ background: transparent !important;
579
+ border: none !important;
580
+ box-shadow: none !important;
581
+ padding: 0 !important;
582
+ color: var(--text) !important;
583
+ }
584
+
585
+ /* =========================================================
586
+ FIX RADIO: ensure selection dot is visible + looks consistent
587
+ ========================================================= */
588
+
589
+ .gradio-container input[type="radio"]{
590
+ accent-color: var(--accent) !important;
591
+ }
592
+
593
+ /* Radiogroup option styling (works across Gradio v3/v4) */
594
+ .gradio-container div[role="radiogroup"] label{
595
+ display: flex !important;
596
+ align-items: center !important;
597
+ gap: 10px !important;
598
+ border: 1px solid var(--border) !important;
599
+ background: #fbfcff !important;
600
+ border-radius: 12px !important;
601
+ padding: 8px 10px !important;
602
+ color: var(--text) !important;
603
+ }
604
+
605
+ /* Make the radio circle always visible */
606
+ .gradio-container div[role="radiogroup"] input[type="radio"]{
607
+ width: 16px !important;
608
+ height: 16px !important;
609
+ margin: 0 !important;
610
+ }
611
+
612
+ /* =========================================================
613
+ Batch tab: file upload + dataframe keep same colors in “dark”
614
+ ========================================================= */
615
+
616
+ /* Upload area / dropzone (multiple selectors for HF/Gradio versions) */
617
+ .gradio-container .upload,
618
+ .gradio-container .file-upload,
619
+ .gradio-container [data-testid="file"],
620
+ .gradio-container [data-testid="file-upload"],
621
+ .gradio-container [aria-label*="Upload" i]{
622
+ background: #ffffff !important;
623
+ color: var(--text) !important;
624
+ border: 1px dashed rgba(100,116,139,.35) !important;
625
+ border-radius: 14px !important;
626
+ }
627
+
628
+ /* Dataframe readability */
629
+ .gradio-container table,
630
+ .gradio-container thead,
631
+ .gradio-container tbody{
632
+ color: var(--text) !important;
633
+ }
634
+
635
+ /* Results card */
636
  .result-card{
637
  background: #ffffff;
638
  border: 1px solid var(--border);
 
641
  box-shadow: var(--shadow);
642
  }
643
  .result-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
644
+ .result-title{ font-size: 13px; font-weight: 900; letter-spacing:.3px; color: var(--text) !important; }
645
 
646
  .grid2{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
647
  .grid3{ display:grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
 
707
  background: #ffffff;
708
  }
709
 
710
+ /* Primary button */
711
  #primaryBtn button{
712
  border-radius: 14px !important;
713
  border: 1px solid rgba(37,99,235,.35) !important;