293droid commited on
Commit
4c2e7ee
·
1 Parent(s): 532ce3a

fix: UI polish - cream header, full recipe cards, wider layout

Browse files
Files changed (1) hide show
  1. app.py +60 -71
app.py CHANGED
@@ -344,7 +344,7 @@ body {
344
  #soap-shell {
345
  border: 0 !important;
346
  border-radius: 0 !important;
347
- padding: 0 !important;
348
  background: var(--soap-cream) !important;
349
  box-shadow: none !important;
350
  }
@@ -521,11 +521,12 @@ body {
521
  .section-divider {
522
  height: 1px;
523
  margin: 24px 0 18px;
524
- background: rgba(212, 168, 83, 0.58);
525
  }
526
 
527
  .output-row {
528
  background: transparent !important;
 
529
  }
530
 
531
  .output-row > *,
@@ -535,90 +536,58 @@ body {
535
  background: transparent !important;
536
  }
537
 
538
- .examples-card {
539
  margin: 18px 0 20px;
 
540
  }
541
 
542
- .examples-card .table-wrap,
543
- .examples-card table,
544
- .examples .table-wrap,
545
- .examples table {
546
- overflow: visible !important;
547
- }
548
-
549
- .examples-card table,
550
- .examples table {
551
- display: grid !important;
552
- grid-template-columns: repeat(2, minmax(0, 1fr));
553
- gap: 12px;
554
- border: 0 !important;
555
- }
556
-
557
- .examples-card thead,
558
- .examples thead {
559
- display: none !important;
560
- }
561
-
562
- .examples-card tbody,
563
- .examples-card tr,
564
- .examples-card td,
565
- .examples tbody,
566
- .examples tr,
567
- .examples td {
568
- display: contents !important;
569
  }
570
 
571
- .examples table td {
572
- white-space: normal !important;
573
- overflow: visible !important;
574
- max-width: none !important;
575
- text-overflow: unset !important;
576
  }
577
 
578
- .examples .label-wrap {
579
- display: none !important;
580
  }
581
 
582
- .examples-card td:first-child,
583
- .examples td:first-child {
584
- display: block !important;
585
- min-height: 70px;
586
  height: auto !important;
587
- padding: 14px 16px !important;
588
- border: 1.5px solid rgba(212, 168, 83, 0.62) !important;
589
- border-left: 6px solid var(--soap-amber) !important;
590
  border-radius: 12px !important;
591
- background: #FFF9EF !important;
592
  color: var(--soap-ink) !important;
593
- box-shadow: 0 8px 16px rgba(61, 43, 31, 0.09);
594
- cursor: pointer;
595
- transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
 
 
596
  white-space: normal !important;
597
  overflow: visible !important;
598
  text-overflow: unset !important;
599
- line-height: 1.35;
600
  }
601
 
602
- .examples-card td:first-child *,
603
- .examples td:first-child * {
 
604
  white-space: normal !important;
605
  overflow: visible !important;
606
  max-width: none !important;
607
  text-overflow: unset !important;
608
- -webkit-line-clamp: unset !important;
609
- line-clamp: unset !important;
610
  }
611
 
612
- .examples-card td:first-child:hover,
613
- .examples td:first-child:hover {
614
  transform: translateY(-2px);
615
- border-color: var(--soap-amber-dark) !important;
616
- box-shadow: 0 12px 22px rgba(61, 43, 31, 0.14);
617
- }
618
-
619
- .examples-card td:nth-child(2),
620
- .examples td:nth-child(2) {
621
- display: none !important;
622
  }
623
 
624
  .safety-note {
@@ -640,7 +609,7 @@ footer,
640
  }
641
 
642
  #soap-shell {
643
- padding: 0 !important;
644
  border-radius: 0 !important;
645
  }
646
 
@@ -648,8 +617,8 @@ footer,
648
  font-size: 14px;
649
  }
650
 
651
- .examples-card table {
652
- grid-template-columns: 1fr;
653
  }
654
 
655
  .notebook-card {
@@ -679,6 +648,14 @@ soap_theme = gr.themes.Base(
679
  input_background_fill="#FFFDF8",
680
  )
681
 
 
 
 
 
 
 
 
 
682
  with gr.Blocks(title="🧼 Soap Lab") as demo:
683
  with gr.Group(elem_id="soap-shell"):
684
  with gr.Group(elem_id="soap-header", elem_classes=["header-panel"]):
@@ -701,12 +678,18 @@ with gr.Blocks(title="🧼 Soap Lab") as demo:
701
  vegan_toggle = gr.Checkbox(label="🌿 Plant-based only", value=False)
702
  submit_btn = gr.Button("Calculate →", variant="primary", size="lg", elem_id="calculate-btn")
703
 
704
- with gr.Group(elem_classes=["examples-card"]):
705
- gr.Examples(
706
- examples=EXAMPLES,
707
- inputs=[user_input, vegan_toggle],
708
- label="Recipe cards",
709
- )
 
 
 
 
 
 
710
 
711
  gr.HTML("<div class='section-divider'></div>")
712
 
@@ -744,6 +727,12 @@ with gr.Blocks(title="🧼 Soap Lab") as demo:
744
  inputs=[user_input, vegan_toggle],
745
  outputs=[lye_output, scores_output, explanation_output],
746
  )
 
 
 
 
 
 
747
 
748
  if __name__ == "__main__":
749
  demo.launch(css=CSS, theme=soap_theme)
 
344
  #soap-shell {
345
  border: 0 !important;
346
  border-radius: 0 !important;
347
+ padding: 16px !important;
348
  background: var(--soap-cream) !important;
349
  box-shadow: none !important;
350
  }
 
521
  .section-divider {
522
  height: 1px;
523
  margin: 24px 0 18px;
524
+ background: transparent !important;
525
  }
526
 
527
  .output-row {
528
  background: transparent !important;
529
+ padding: 16px 0 !important;
530
  }
531
 
532
  .output-row > *,
 
536
  background: transparent !important;
537
  }
538
 
539
+ .recipe-card-grid {
540
  margin: 18px 0 20px;
541
+ background: transparent !important;
542
  }
543
 
544
+ .recipe-card-grid .form,
545
+ .recipe-card-grid .block {
546
+ background: transparent !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
  }
548
 
549
+ .recipe-card-row {
550
+ gap: 12px !important;
551
+ margin-bottom: 12px !important;
552
+ background: transparent !important;
 
553
  }
554
 
555
+ .recipe-card {
556
+ width: 100%;
557
  }
558
 
559
+ .recipe-card button {
560
+ width: 100% !important;
561
+ min-height: 70px !important;
 
562
  height: auto !important;
563
+ padding: 12px 14px !important;
564
+ border: 1.5px solid var(--soap-amber-dark) !important;
 
565
  border-radius: 12px !important;
566
+ background: #D4A853 !important;
567
  color: var(--soap-ink) !important;
568
+ box-shadow: 0 6px 14px rgba(169, 120, 34, 0.18);
569
+ font-family: Georgia, "Times New Roman", serif !important;
570
+ font-size: 14px !important;
571
+ line-height: 1.35 !important;
572
+ text-align: left !important;
573
  white-space: normal !important;
574
  overflow: visible !important;
575
  text-overflow: unset !important;
 
576
  }
577
 
578
+ .recipe-card button span,
579
+ .recipe-card button div,
580
+ .recipe-card button p {
581
  white-space: normal !important;
582
  overflow: visible !important;
583
  max-width: none !important;
584
  text-overflow: unset !important;
 
 
585
  }
586
 
587
+ .recipe-card button:hover {
 
588
  transform: translateY(-2px);
589
+ background: #DEB766 !important;
590
+ box-shadow: 0 10px 20px rgba(169, 120, 34, 0.24);
 
 
 
 
 
591
  }
592
 
593
  .safety-note {
 
609
  }
610
 
611
  #soap-shell {
612
+ padding: 16px !important;
613
  border-radius: 0 !important;
614
  }
615
 
 
617
  font-size: 14px;
618
  }
619
 
620
+ .recipe-card-row {
621
+ gap: 10px !important;
622
  }
623
 
624
  .notebook-card {
 
648
  input_background_fill="#FFFDF8",
649
  )
650
 
651
+
652
+ def make_example_loader(example_text: str):
653
+ def load_example() -> str:
654
+ return example_text
655
+
656
+ return load_example
657
+
658
+
659
  with gr.Blocks(title="🧼 Soap Lab") as demo:
660
  with gr.Group(elem_id="soap-shell"):
661
  with gr.Group(elem_id="soap-header", elem_classes=["header-panel"]):
 
678
  vegan_toggle = gr.Checkbox(label="🌿 Plant-based only", value=False)
679
  submit_btn = gr.Button("Calculate →", variant="primary", size="lg", elem_id="calculate-btn")
680
 
681
+ recipe_buttons = []
682
+ with gr.Group(elem_classes=["recipe-card-grid"]):
683
+ for row_start in range(0, len(EXAMPLES), 2):
684
+ with gr.Row(elem_classes=["recipe-card-row"]):
685
+ for example_text, _ in EXAMPLES[row_start:row_start + 2]:
686
+ recipe_buttons.append(
687
+ gr.Button(
688
+ example_text,
689
+ variant="secondary",
690
+ elem_classes=["recipe-card"],
691
+ )
692
+ )
693
 
694
  gr.HTML("<div class='section-divider'></div>")
695
 
 
727
  inputs=[user_input, vegan_toggle],
728
  outputs=[lye_output, scores_output, explanation_output],
729
  )
730
+ for recipe_button, example in zip(recipe_buttons, EXAMPLES):
731
+ recipe_button.click(
732
+ fn=make_example_loader(example[0]),
733
+ inputs=[],
734
+ outputs=user_input,
735
+ )
736
 
737
  if __name__ == "__main__":
738
  demo.launch(css=CSS, theme=soap_theme)