josefchen commited on
Commit
4851c45
·
verified ·
1 Parent(s): 56c3b09

Force light mode, fix iOS dark-mode hijack, stack 3 comparison tables on mobile, shrink spectrum bar on narrow screens

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-310.pyc +0 -0
  2. app.py +82 -17
__pycache__/app.cpython-310.pyc CHANGED
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
 
app.py CHANGED
@@ -554,41 +554,106 @@ THEME = gr.themes.Soft(
554
  )
555
 
556
  CUSTOM_CSS = f"""
557
- .gradio-container {{max-width: 1280px !important;}}
558
- footer {{visibility: hidden;}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
  .gradio-container label, .gradio-container .label,
560
- .gradio-container [data-testid="block-label"], .gradio-container .block-label {{
561
- color: #0f172a !important; font-weight: 600 !important; background: transparent !important;
 
 
 
 
 
 
 
 
562
  }}
563
- .gradio-container button[role="tab"] {{ color: #334155 !important; font-weight: 500 !important; }}
564
  .gradio-container button[role="tab"][aria-selected="true"] {{
565
  color: {KAIKAKU_ACCENT} !important; border-bottom-color: {KAIKAKU_ACCENT} !important; font-weight: 700 !important;
566
  }}
 
 
567
  .gradio-container button.primary, .gradio-container .primary > button {{
568
  background: {KAIKAKU_ACCENT} !important; color: #ffffff !important;
569
  border-color: {KAIKAKU_ACCENT} !important; font-weight: 600 !important;
570
  }}
571
- .gradio-container table thead th {{
 
 
 
 
572
  color: #0f172a !important; font-weight: 700 !important; background: #f8fafc !important;
573
  }}
574
- .gradio-container table tbody td {{ color: #0f172a !important; }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
 
576
  /* Spectrum bar */
577
  .spectrum-bar {{
578
- display: flex; align-items: stretch; margin: 12px 0 4px 0; height: 56px;
579
  border-radius: 8px; overflow: hidden;
580
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
581
  }}
582
  .spectrum-cell {{
583
  flex: 1; display: flex; flex-direction: column; justify-content: center;
584
- padding: 6px 14px; color: #0f172a;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  }}
586
- .spectrum-cell-1 {{ background: #f0f9f6; }}
587
- .spectrum-cell-2 {{ background: #d8efe7; }}
588
- .spectrum-cell-3 {{ background: #b8dfd1; }}
589
- .spectrum-name {{ font-weight: 700; font-size: 0.95em; }}
590
- .spectrum-sub {{ font-size: 0.8em; color: #475569; }}
591
- .spectrum-arrow {{ width: 16px; background: transparent; display:flex; align-items:center; justify-content:center; color: #94a3b8; }}
592
  """
593
 
594
  SPECTRUM_BAR = """
@@ -658,7 +723,7 @@ Three sibling ingredient embeddings from [arXiv:2605.22391](https://arxiv.org/ab
658
  label="Try a basket (one click)",
659
  )
660
 
661
- with gr.Row():
662
  ex_nb_cooc = gr.Dataframe(value=_INIT_NB_COOC, headers=["Cooc","cos"],
663
  label="Cooc (recipe-context)", interactive=False)
664
  ex_nb_core = gr.Dataframe(value=_INIT_NB_CORE, headers=["Core","cos"],
@@ -667,7 +732,7 @@ Three sibling ingredient embeddings from [arXiv:2605.22391](https://arxiv.org/ab
667
  label="Chem (chemistry)", interactive=False)
668
 
669
  with gr.Accordion("Closest modes (per sibling)", open=False):
670
- with gr.Row():
671
  ex_md_cooc = gr.Dataframe(value=_INIT_MD_COOC, headers=["id","label","kind","cos"],
672
  label="Cooc top modes", interactive=False, wrap=True)
673
  ex_md_core = gr.Dataframe(value=_INIT_MD_CORE, headers=["id","label","kind","cos"],
 
554
  )
555
 
556
  CUSTOM_CSS = f"""
557
+ /* Force LIGHT mode regardless of OS / browser preference (iOS dark-mode hijack fix) */
558
+ :root, html, body, .gradio-container, .dark {{
559
+ color-scheme: light !important;
560
+ background-color: #ffffff !important;
561
+ color: #0f172a !important;
562
+ }}
563
+ .dark {{ color-scheme: light !important; }}
564
+ .gradio-container, .gradio-container * {{
565
+ --body-background-fill: #ffffff !important;
566
+ --body-text-color: #0f172a !important;
567
+ --block-background-fill: #ffffff !important;
568
+ --block-label-background-fill: transparent !important;
569
+ --background-fill-primary: #ffffff !important;
570
+ --background-fill-secondary: #f8fafc !important;
571
+ --input-background-fill: #ffffff !important;
572
+ }}
573
+ .gradio-container {{ max-width: 1280px !important; background: #ffffff !important; }}
574
+ footer {{ visibility: hidden; }}
575
+
576
+ /* Labels: plain dark text, no chip background */
577
  .gradio-container label, .gradio-container .label,
578
+ .gradio-container [data-testid="block-label"], .gradio-container .block-label,
579
+ .gradio-container .gr-block-label, .gradio-container span.label-wrap {{
580
+ color: #0f172a !important; font-weight: 600 !important;
581
+ background: transparent !important; box-shadow: none !important;
582
+ padding: 0 !important; border: none !important;
583
+ }}
584
+
585
+ /* Tab labels readable */
586
+ .gradio-container button[role="tab"] {{
587
+ color: #334155 !important; font-weight: 500 !important; background: transparent !important;
588
  }}
 
589
  .gradio-container button[role="tab"][aria-selected="true"] {{
590
  color: {KAIKAKU_ACCENT} !important; border-bottom-color: {KAIKAKU_ACCENT} !important; font-weight: 700 !important;
591
  }}
592
+
593
+ /* Primary button */
594
  .gradio-container button.primary, .gradio-container .primary > button {{
595
  background: {KAIKAKU_ACCENT} !important; color: #ffffff !important;
596
  border-color: {KAIKAKU_ACCENT} !important; font-weight: 600 !important;
597
  }}
598
+
599
+ /* Tables readable on white */
600
+ .gradio-container table thead th,
601
+ .gradio-container .gr-dataframe thead th,
602
+ .gradio-container [class*="dataframe"] thead th {{
603
  color: #0f172a !important; font-weight: 700 !important; background: #f8fafc !important;
604
  }}
605
+ .gradio-container table tbody td,
606
+ .gradio-container .gr-dataframe tbody td,
607
+ .gradio-container [class*="dataframe"] tbody td {{
608
+ color: #0f172a !important; background: #ffffff !important;
609
+ }}
610
+ .gradio-container [class*="dataframe"] tbody tr:nth-child(even) td {{
611
+ background: #fafbfc !important;
612
+ }}
613
+
614
+ /* Dropdown / Textbox readable */
615
+ .gradio-container input, .gradio-container textarea, .gradio-container .gr-dropdown,
616
+ .gradio-container [data-testid="dropdown"] {{
617
+ background: #ffffff !important; color: #0f172a !important;
618
+ }}
619
+ .gradio-container .token, .gradio-container .gr-dropdown .token {{
620
+ background: #f1f5f9 !important; color: #0f172a !important;
621
+ }}
622
 
623
  /* Spectrum bar */
624
  .spectrum-bar {{
625
+ display: flex; align-items: stretch; margin: 12px 0 4px 0; min-height: 56px;
626
  border-radius: 8px; overflow: hidden;
627
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
628
  }}
629
  .spectrum-cell {{
630
  flex: 1; display: flex; flex-direction: column; justify-content: center;
631
+ padding: 8px 12px; color: #0f172a !important; min-width: 0;
632
+ }}
633
+ .spectrum-cell-1 {{ background: #f0f9f6 !important; }}
634
+ .spectrum-cell-2 {{ background: #d8efe7 !important; }}
635
+ .spectrum-cell-3 {{ background: #b8dfd1 !important; }}
636
+ .spectrum-name {{ font-weight: 700; font-size: 0.95em; color: #0f172a !important; }}
637
+ .spectrum-sub {{ font-size: 0.78em; color: #475569 !important; line-height: 1.3; }}
638
+ .spectrum-arrow {{ width: 18px; background: transparent !important; display: flex; align-items: center; justify-content: center; color: #94a3b8 !important; flex-shrink: 0; }}
639
+
640
+ /* Mobile responsive: stack the three sibling result tables on narrow screens */
641
+ @media (max-width: 768px) {{
642
+ .gradio-container .compare-row {{ flex-direction: column !important; }}
643
+ .gradio-container .compare-row > * {{ width: 100% !important; min-width: 0 !important; }}
644
+ .spectrum-cell {{ padding: 6px 8px; }}
645
+ .spectrum-sub {{ font-size: 0.7em; }}
646
+ .spectrum-name {{ font-size: 0.85em; }}
647
+ .spectrum-bar {{ min-height: 64px; }}
648
+ .gradio-container {{ padding: 0 8px !important; }}
649
+ h1 {{ font-size: 1.4em !important; }}
650
+ }}
651
+ @media (max-width: 480px) {{
652
+ .spectrum-sub {{ display: none; }}
653
+ .spectrum-arrow {{ width: 12px; }}
654
+ .spectrum-bar {{ min-height: 40px; }}
655
+ .spectrum-cell {{ padding: 4px 6px; }}
656
  }}
 
 
 
 
 
 
657
  """
658
 
659
  SPECTRUM_BAR = """
 
723
  label="Try a basket (one click)",
724
  )
725
 
726
+ with gr.Row(elem_classes=["compare-row"]):
727
  ex_nb_cooc = gr.Dataframe(value=_INIT_NB_COOC, headers=["Cooc","cos"],
728
  label="Cooc (recipe-context)", interactive=False)
729
  ex_nb_core = gr.Dataframe(value=_INIT_NB_CORE, headers=["Core","cos"],
 
732
  label="Chem (chemistry)", interactive=False)
733
 
734
  with gr.Accordion("Closest modes (per sibling)", open=False):
735
+ with gr.Row(elem_classes=["compare-row"]):
736
  ex_md_cooc = gr.Dataframe(value=_INIT_MD_COOC, headers=["id","label","kind","cos"],
737
  label="Cooc top modes", interactive=False, wrap=True)
738
  ex_md_core = gr.Dataframe(value=_INIT_MD_CORE, headers=["id","label","kind","cos"],