Shreyas Meher commited on
Commit
72b9834
·
1 Parent(s): 4427b9a

Enhanced UI with modern orange theme and improved dark/light mode support

Browse files
Files changed (1) hide show
  1. app.py +293 -1
app.py CHANGED
@@ -428,7 +428,299 @@ def chatbot(task, text=None, context=None, question=None, file=None):
428
  return "Please select a valid task."
429
 
430
 
431
- with gr.Blocks(theme="allenai/gradio-theme") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  with gr.Column():
433
  with gr.Row(elem_id="header", elem_classes="header-container"):
434
  gr.Markdown("<div class='header-title-center'><a href='https://eventdata.utdallas.edu/conflibert/' style='font-size: 4rem; font-weight: 900;'>ConfliBERT</a></div>")
 
428
  return "Please select a valid task."
429
 
430
 
431
+ # Custom CSS for modern orange theme
432
+ custom_css = """
433
+ /* CSS Variables for Light and Dark Theme */
434
+ :root {
435
+ --primary-orange: #ff6b35;
436
+ --primary-orange-light: #ff8c5a;
437
+ --primary-orange-dark: #e55a2b;
438
+ --secondary-orange: #ffa366;
439
+ --accent-orange: #ff9f40;
440
+ --background-light: #fefefe;
441
+ --background-dark: #1a1a1a;
442
+ --surface-light: #ffffff;
443
+ --surface-dark: #2d2d2d;
444
+ --text-primary-light: #2c2c2c;
445
+ --text-primary-dark: #ffffff;
446
+ --text-secondary-light: #666666;
447
+ --text-secondary-dark: #cccccc;
448
+ --border-light: #e0e0e0;
449
+ --border-dark: #404040;
450
+ --shadow-light: rgba(0, 0, 0, 0.1);
451
+ --shadow-dark: rgba(0, 0, 0, 0.3);
452
+ --gradient-orange: linear-gradient(135deg, #ff6b35 0%, #ff9f40 100%);
453
+ --gradient-orange-subtle: linear-gradient(135deg, rgba(255, 107, 53, 0.1) 0%, rgba(255, 159, 64, 0.1) 100%);
454
+ }
455
+
456
+ /* Dark theme overrides */
457
+ .dark {
458
+ --background: var(--background-dark);
459
+ --surface: var(--surface-dark);
460
+ --text-primary: var(--text-primary-dark);
461
+ --text-secondary: var(--text-secondary-dark);
462
+ --border: var(--border-dark);
463
+ --shadow: var(--shadow-dark);
464
+ }
465
+
466
+ /* Light theme (default) */
467
+ .light, :root {
468
+ --background: var(--background-light);
469
+ --surface: var(--surface-light);
470
+ --text-primary: var(--text-primary-light);
471
+ --text-secondary: var(--text-secondary-light);
472
+ --border: var(--border-light);
473
+ --shadow: var(--shadow-light);
474
+ }
475
+
476
+ /* Global Styles */
477
+ * {
478
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
479
+ }
480
+
481
+ /* Main Container */
482
+ .gradio-container {
483
+ background: var(--background) !important;
484
+ color: var(--text-primary) !important;
485
+ min-height: 100vh;
486
+ }
487
+
488
+ /* Header Styling */
489
+ .header-container {
490
+ background: var(--gradient-orange) !important;
491
+ padding: 2rem 1rem !important;
492
+ margin: -1rem -1rem 2rem -1rem !important;
493
+ border-radius: 0 0 24px 24px !important;
494
+ box-shadow: 0 8px 32px var(--shadow) !important;
495
+ position: relative;
496
+ overflow: hidden;
497
+ }
498
+
499
+ .header-container::before {
500
+ content: '';
501
+ position: absolute;
502
+ top: 0;
503
+ left: 0;
504
+ right: 0;
505
+ bottom: 0;
506
+ background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") !important;
507
+ pointer-events: none;
508
+ }
509
+
510
+ .header-title-center {
511
+ text-align: center !important;
512
+ position: relative;
513
+ z-index: 1;
514
+ }
515
+
516
+ .header-title-center a {
517
+ color: white !important;
518
+ text-decoration: none !important;
519
+ font-weight: 900 !important;
520
+ font-size: 4rem !important;
521
+ text-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
522
+ letter-spacing: -0.02em !important;
523
+ transition: all 0.3s ease !important;
524
+ }
525
+
526
+ .header-title-center a:hover {
527
+ transform: translateY(-2px) !important;
528
+ text-shadow: 0 6px 16px rgba(0, 0, 0, 0.3) !important;
529
+ }
530
+
531
+ /* Task Container */
532
+ .task-container {
533
+ background: var(--surface) !important;
534
+ border-radius: 16px !important;
535
+ padding: 2rem !important;
536
+ box-shadow: 0 4px 24px var(--shadow) !important;
537
+ border: 1px solid var(--border) !important;
538
+ margin-bottom: 2rem !important;
539
+ }
540
+
541
+ /* Input Components */
542
+ .input-text textarea, .input-text input {
543
+ background: var(--surface) !important;
544
+ border: 2px solid var(--border) !important;
545
+ border-radius: 12px !important;
546
+ padding: 1rem !important;
547
+ color: var(--text-primary) !important;
548
+ font-size: 0.95rem !important;
549
+ line-height: 1.5 !important;
550
+ transition: all 0.3s ease !important;
551
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
552
+ }
553
+
554
+ .input-text textarea:focus, .input-text input:focus {
555
+ border-color: var(--primary-orange) !important;
556
+ box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1) !important;
557
+ outline: none !important;
558
+ transform: translateY(-1px) !important;
559
+ }
560
+
561
+ /* Dropdown Styling */
562
+ .gr-dropdown {
563
+ background: var(--surface) !important;
564
+ border: 2px solid var(--border) !important;
565
+ border-radius: 12px !important;
566
+ color: var(--text-primary) !important;
567
+ transition: all 0.3s ease !important;
568
+ }
569
+
570
+ .gr-dropdown:focus-within {
571
+ border-color: var(--primary-orange) !important;
572
+ box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1) !important;
573
+ }
574
+
575
+ /* Button Styling */
576
+ .submit-btn {
577
+ background: var(--gradient-orange) !important;
578
+ border: none !important;
579
+ border-radius: 12px !important;
580
+ padding: 1rem 2rem !important;
581
+ color: white !important;
582
+ font-weight: 600 !important;
583
+ font-size: 1rem !important;
584
+ cursor: pointer !important;
585
+ transition: all 0.3s ease !important;
586
+ box-shadow: 0 4px 16px rgba(255, 107, 53, 0.3) !important;
587
+ text-transform: uppercase !important;
588
+ letter-spacing: 0.5px !important;
589
+ }
590
+
591
+ .submit-btn:hover {
592
+ transform: translateY(-2px) !important;
593
+ box-shadow: 0 6px 24px rgba(255, 107, 53, 0.4) !important;
594
+ background: linear-gradient(135deg, #ff8c5a 0%, #ffb366 100%) !important;
595
+ }
596
+
597
+ .submit-btn:active {
598
+ transform: translateY(0) !important;
599
+ box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3) !important;
600
+ }
601
+
602
+ /* File Upload Styling */
603
+ .file-upload {
604
+ background: var(--gradient-orange-subtle) !important;
605
+ border: 2px dashed var(--primary-orange) !important;
606
+ border-radius: 12px !important;
607
+ padding: 1.5rem !important;
608
+ text-align: center !important;
609
+ transition: all 0.3s ease !important;
610
+ }
611
+
612
+ .file-upload:hover {
613
+ background: rgba(255, 107, 53, 0.15) !important;
614
+ border-color: var(--primary-orange-dark) !important;
615
+ }
616
+
617
+ /* Output Styling */
618
+ .output-html {
619
+ background: var(--surface) !important;
620
+ border: 1px solid var(--border) !important;
621
+ border-radius: 12px !important;
622
+ padding: 1.5rem !important;
623
+ margin-top: 1rem !important;
624
+ box-shadow: 0 2px 12px var(--shadow) !important;
625
+ min-height: 100px !important;
626
+ }
627
+
628
+ .output-html div {
629
+ color: var(--text-primary) !important;
630
+ line-height: 1.6 !important;
631
+ }
632
+
633
+ /* Labels */
634
+ label {
635
+ color: var(--text-primary) !important;
636
+ font-weight: 600 !important;
637
+ font-size: 0.9rem !important;
638
+ margin-bottom: 0.5rem !important;
639
+ text-transform: uppercase !important;
640
+ letter-spacing: 0.5px !important;
641
+ }
642
+
643
+ /* Footer */
644
+ .footer {
645
+ background: var(--surface) !important;
646
+ border-top: 1px solid var(--border) !important;
647
+ padding: 1.5rem !important;
648
+ margin-top: 2rem !important;
649
+ text-align: center !important;
650
+ border-radius: 16px 16px 0 0 !important;
651
+ }
652
+
653
+ .footer a {
654
+ color: var(--primary-orange) !important;
655
+ text-decoration: none !important;
656
+ font-weight: 500 !important;
657
+ transition: color 0.3s ease !important;
658
+ }
659
+
660
+ .footer a:hover {
661
+ color: var(--primary-orange-dark) !important;
662
+ text-decoration: underline !important;
663
+ }
664
+
665
+ /* Responsive Design */
666
+ @media (max-width: 768px) {
667
+ .header-title-center a {
668
+ font-size: 2.5rem !important;
669
+ }
670
+
671
+ .task-container {
672
+ padding: 1.5rem !important;
673
+ margin: 1rem !important;
674
+ }
675
+
676
+ .header-container {
677
+ padding: 1.5rem 1rem !important;
678
+ margin: -1rem -1rem 1rem -1rem !important;
679
+ }
680
+ }
681
+
682
+ /* Enhanced NER Output Styling */
683
+ .output-html span[style*="color: blue"] { color: #3b82f6 !important; }
684
+ .output-html span[style*="color: red"] { color: #ef4444 !important; }
685
+ .output-html span[style*="color: green"] { color: #10b981 !important; }
686
+ .output-html span[style*="color: orange"] { color: var(--primary-orange) !important; }
687
+ .output-html span[style*="color: purple"] { color: #8b5cf6 !important; }
688
+ .output-html span[style*="color: cyan"] { color: #06b6d4 !important; }
689
+ .output-html span[style*="color: magenta"] { color: #ec4899 !important; }
690
+ .output-html span[style*="color: brown"] { color: #92400e !important; }
691
+ .output-html span[style*="color: yellow"] { color: #f59e0b !important; }
692
+ .output-html span[style*="color: pink"] { color: #f472b6 !important; }
693
+
694
+ /* Dark mode specific adjustments */
695
+ @media (prefers-color-scheme: dark) {
696
+ .gradio-container {
697
+ background: var(--background-dark) !important;
698
+ color: var(--text-primary-dark) !important;
699
+ }
700
+
701
+ .task-container, .output-html {
702
+ background: var(--surface-dark) !important;
703
+ border-color: var(--border-dark) !important;
704
+ }
705
+
706
+ .input-text textarea, .input-text input, .gr-dropdown {
707
+ background: var(--surface-dark) !important;
708
+ border-color: var(--border-dark) !important;
709
+ color: var(--text-primary-dark) !important;
710
+ }
711
+
712
+ label {
713
+ color: var(--text-primary-dark) !important;
714
+ }
715
+ }
716
+
717
+ /* Smooth transitions for theme switching */
718
+ * {
719
+ transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease !important;
720
+ }
721
+ """
722
+
723
+ with gr.Blocks(theme="allenai/gradio-theme", css=custom_css) as demo:
724
  with gr.Column():
725
  with gr.Row(elem_id="header", elem_classes="header-container"):
726
  gr.Markdown("<div class='header-title-center'><a href='https://eventdata.utdallas.edu/conflibert/' style='font-size: 4rem; font-weight: 900;'>ConfliBERT</a></div>")