QIDNLF commited on
Commit
a558fb5
ยท
verified ยท
1 Parent(s): cf55ced

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -79
app.py CHANGED
@@ -508,16 +508,16 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
508
  js_resizable = """
509
  function() {
510
  const attachResizers = () => {
511
- // ๋ชจ๋“  table ์š”์†Œ๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค.
512
- const tables = document.querySelectorAll('table');
513
  if (tables.length === 0) return;
514
 
515
  tables.forEach(table => {
516
- // ์ด๋ฏธ ํ•ธ๋“ค์ด ๋ถ™์—ˆ๋Š”์ง€ ์ฒดํฌ
517
  if (table.dataset.resizable === 'true') return;
518
 
 
519
  table.style.tableLayout = 'fixed';
520
- table.style.width = '100%';
 
521
 
522
  const headers = table.querySelectorAll('th');
523
  headers.forEach(th => {
@@ -530,32 +530,40 @@ function() {
530
 
531
  let startX, startWidth;
532
 
533
- resizer.addEventListener('mousedown', function(e) {
534
  startX = e.pageX;
535
  startWidth = th.offsetWidth;
536
  document.addEventListener('mousemove', onMouseMove);
537
  document.addEventListener('mouseup', onMouseUp);
538
- resizer.style.backgroundColor = '#1a73e8';
 
 
539
  e.preventDefault();
540
- });
541
 
542
  function onMouseMove(e) {
543
- const width = startWidth + (e.pageX - startX);
 
 
 
544
  th.style.width = width + 'px';
545
  th.style.minWidth = width + 'px';
 
546
  }
547
 
548
  function onMouseUp() {
549
  document.removeEventListener('mousemove', onMouseMove);
550
  document.removeEventListener('mouseup', onMouseUp);
551
- resizer.style.backgroundColor = 'transparent';
 
552
  }
 
 
553
  });
554
  table.dataset.resizable = 'true';
555
  });
556
  };
557
 
558
- // 0.2์ดˆ ๊ฐ„๊ฒฉ์œผ๋กœ ์ตœ๋Œ€ 5์ดˆ๊ฐ„ ํ‘œ๊ฐ€ ๋‚˜ํƒ€๋‚˜๋Š”์ง€ ๊ฐ์‹œ
559
  let attempts = 0;
560
  const interval = setInterval(() => {
561
  attachResizers();
@@ -611,49 +619,20 @@ with gr.Blocks() as demo:
611
  comp_reset_btn.click(fn=reset_comp_selections, inputs=None, outputs=[comp_standard, comp_version, comp_category])
612
 
613
 
 
 
 
614
  # ==========================================
615
  # 5. Application Styling (CSS)
616
  # ==========================================
617
  css = """
 
618
  table {
619
- table-layout: auto !important;
620
- width: max-content !important;
621
- min-width: 100% !important;
622
- }
623
-
624
- th, td {
625
- min-width: 150px;
626
- }
627
-
628
- table:has(th:nth-last-child(2):first-child),
629
- table:has(th:nth-last-child(4):first-child),
630
- table:has(th:nth-last-child(5):first-child),
631
- table:has(th:nth-last-child(6):first-child) {
632
- table-layout: fixed !important;
633
  width: 100% !important;
 
634
  }
635
 
636
- table th:nth-last-child(2):first-child, table td:nth-last-child(2):first-child { width: 15% !important; min-width: 0 !important; }
637
- table th:nth-last-child(1), table td:nth-last-child(1) { width: 85% !important; min-width: 0 !important; }
638
-
639
- table th:nth-child(1):nth-last-child(4), table td:nth-child(1):nth-last-child(4) { width: 10% !important; min-width: 0 !important; }
640
- table th:nth-child(2):nth-last-child(3), table td:nth-child(2):nth-last-child(3) { width: 40% !important; min-width: 0 !important; }
641
- table th:nth-child(3):nth-last-child(2), table td:nth-child(3):nth-last-child(2) { width: 10% !important; min-width: 0 !important; }
642
- table th:nth-child(4):nth-last-child(1), table td:nth-child(4):nth-last-child(1) { width: 40% !important; min-width: 0 !important; }
643
-
644
- table th:nth-child(1):nth-last-child(5), table td:nth-child(1):nth-last-child(5) { width: 15% !important; min-width: 0 !important; }
645
- table th:nth-child(2):nth-last-child(4), table td:nth-child(2):nth-last-child(4) { width: 10% !important; min-width: 0 !important; }
646
- table th:nth-child(3):nth-last-child(3), table td:nth-child(3):nth-last-child(3) { width: 30% !important; min-width: 0 !important; }
647
- table th:nth-child(4):nth-last-child(2), table td:nth-child(4):nth-last-child(2) { width: 10% !important; min-width: 0 !important; }
648
- table th:nth-child(5):nth-last-child(1), table td:nth-child(5):nth-last-child(1) { width: 35% !important; min-width: 0 !important; }
649
-
650
- table th:nth-child(1):nth-last-child(6), table td:nth-child(1):nth-last-child(6) { width: 8% !important; min-width: 0 !important; }
651
- table th:nth-child(2):nth-last-child(5), table td:nth-child(2):nth-last-child(5) { width: 15% !important; min-width: 0 !important; }
652
- table th:nth-child(3):nth-last-child(4), table td:nth-child(3):nth-last-child(4) { width: 27% !important; min-width: 0 !important; }
653
- table th:nth-child(4):nth-last-child(3), table td:nth-child(4):nth-last-child(3) { width: 8% !important; min-width: 0 !important; }
654
- table th:nth-child(5):nth-last-child(2), table td:nth-child(5):nth-last-child(2) { width: 15% !important; min-width: 0 !important; }
655
- table th:nth-child(6):nth-last-child(1), table td:nth-child(6):nth-last-child(1) { width: 27% !important; min-width: 0 !important; }
656
-
657
  thead th {
658
  font-size: 18px !important;
659
  position: sticky;
@@ -661,20 +640,10 @@ thead th {
661
  background: white;
662
  z-index: 10;
663
  }
664
- .dataframe {
665
- max-height: none !important;
666
- overflow-y: visible !important;
667
- overflow-x: auto !important;
668
- display: block;
669
- }
670
- .dataframe > div {
671
- max-height: none !important;
672
- overflow: visible !important;
673
- }
674
- td {
675
  font-size: 18px !important;
676
- white-space: pre-wrap !important;
677
- word-break: keep-all !important;
678
  line-height: 1.6;
679
  padding: 10px;
680
  vertical-align: top !important;
@@ -684,22 +653,8 @@ td img {
684
  display: block;
685
  max-width: none !important;
686
  }
687
- /* 5๋ฒˆ ๊ตฌ์—ญ CSS์— ์ถ”๊ฐ€ */
688
- .dataframe th {
689
- position: relative !important;
690
- overflow: visible !important; /* ์ด๊ฒŒ ์—†์œผ๋ฉด ํ•ธ๋“ค์ด ์•ˆ ๋ณด์ž…๋‹ˆ๋‹ค */
691
- }
692
 
693
- /* ํ•ธ๋“ค์˜ ์œ„์น˜์™€ ๋ชจ์–‘์„ ์‹œ๊ฐ์ ์œผ๋กœ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด */
694
- .resizer {
695
- background-color: transparent; /* ํ‰์†Œ์—” ํˆฌ๋ช… */
696
- transition: background-color 0.2s;
697
- }
698
-
699
- .resizer:hover, .resizer.resizing {
700
- background-color: #1a73e8 !important; /* ๋งˆ์šฐ์Šค ์˜ฌ๋ฆฌ๋ฉด ํŒŒ๋ž€์ƒ‰ ์„ ์ด ๋œธ */
701
- width: 4px !important;
702
- }
703
  .gradio-container .dataframe,
704
  .gradio-container .dataframe div,
705
  .gradio-container thead,
@@ -707,22 +662,56 @@ td img {
707
  .gradio-container th {
708
  overflow: visible !important;
709
  }
 
 
 
 
 
 
710
 
711
- /* ํ•ธ๋“ค(Resizer) ์‹œ๊ฐํ™” - ์šฐ์„  ๋นจ๊ฐ„์ƒ‰์œผ๋กœ ์„ค์ •ํ•˜์—ฌ ํ™•์ธ */
712
  .resizer {
713
- background-color: rgba(255, 0, 0, 0.5); /* ๋ฐ˜ํˆฌ๋ช… ๋นจ๊ฐ„์ƒ‰ */
714
- width: 6px !important;
715
  height: 100%;
716
  position: absolute;
717
  right: 0;
718
  top: 0;
719
  cursor: col-resize;
720
- z-index: 9999 !important; /* ์ตœ์ƒ๋‹จ์œผ๋กœ ์˜ฌ๋ฆผ */
 
 
 
721
  }
722
 
723
- .resizer:hover {
724
- background-color: #1a73e8 !important; /* ๋งˆ์šฐ์Šค ์˜ฌ๋ฆฌ๋ฉด ํŒŒ๋ž€์ƒ‰ */
 
 
 
 
725
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
726
  """
727
 
728
  if __name__ == "__main__":
 
508
  js_resizable = """
509
  function() {
510
  const attachResizers = () => {
511
+ const tables = document.querySelectorAll('.dataframe table');
 
512
  if (tables.length === 0) return;
513
 
514
  tables.forEach(table => {
 
515
  if (table.dataset.resizable === 'true') return;
516
 
517
+ // [ํ•ต์‹ฌ] ํ‘œ๊ฐ€ ํ™”๋ฉด ๋ฐ–์œผ๋กœ ์ž์œ ๋กญ๊ฒŒ ๋Š˜์–ด๋‚  ์ˆ˜ ์žˆ๋„๋ก ์กฑ์‡„ ํ•ด์ œ
518
  table.style.tableLayout = 'fixed';
519
+ table.style.width = 'max-content';
520
+ table.style.minWidth = '100%';
521
 
522
  const headers = table.querySelectorAll('th');
523
  headers.forEach(th => {
 
530
 
531
  let startX, startWidth;
532
 
533
+ function onMouseDown(e) {
534
  startX = e.pageX;
535
  startWidth = th.offsetWidth;
536
  document.addEventListener('mousemove', onMouseMove);
537
  document.addEventListener('mouseup', onMouseUp);
538
+
539
+ resizer.style.backgroundColor = '#1a73e8'; // ๋“œ๋ž˜๊ทธ ์ค‘ ํŒŒ๋ž€์ƒ‰
540
+ document.body.style.userSelect = 'none'; // ๋“œ๋ž˜๊ทธ ์ค‘ ๊ธ€์ž ๋“œ๋ž˜๊ทธ ๋ฐฉ์ง€ (๋ถ€๋“œ๋Ÿฌ์šด ์กฐ์ž‘๊ฐ)
541
  e.preventDefault();
542
+ }
543
 
544
  function onMouseMove(e) {
545
+ // ๋„ˆ๋น„ ๊ฐ•์ œ ๊ณ„์‚ฐ (์ตœ์†Œ 50px ๋ณด์žฅ)
546
+ const width = Math.max(50, startWidth + (e.pageX - startX));
547
+
548
+ // 3์ค‘ ๊ฐ•์ œ ํ• ๋‹น์œผ๋กœ CSS๋ฅผ ์™„๋ฒฝํ•˜๊ฒŒ ๋ฎ์–ด์”Œ์›€
549
  th.style.width = width + 'px';
550
  th.style.minWidth = width + 'px';
551
+ th.style.maxWidth = width + 'px';
552
  }
553
 
554
  function onMouseUp() {
555
  document.removeEventListener('mousemove', onMouseMove);
556
  document.removeEventListener('mouseup', onMouseUp);
557
+ resizer.style.backgroundColor = 'rgba(255, 0, 0, 0.5)'; // ๋‹ค์‹œ ๋นจ๊ฐ„์ƒ‰์œผ๋กœ ๋ณต๊ท€
558
+ document.body.style.userSelect = '';
559
  }
560
+
561
+ resizer.addEventListener('mousedown', onMouseDown);
562
  });
563
  table.dataset.resizable = 'true';
564
  });
565
  };
566
 
 
567
  let attempts = 0;
568
  const interval = setInterval(() => {
569
  attachResizers();
 
619
  comp_reset_btn.click(fn=reset_comp_selections, inputs=None, outputs=[comp_standard, comp_version, comp_category])
620
 
621
 
622
+ # ==========================================
623
+ # 5. Application Styling (CSS)
624
+ # ==========================================
625
  # ==========================================
626
  # 5. Application Styling (CSS)
627
  # ==========================================
628
  css = """
629
+ /* 1. ํ…Œ์ด๋ธ” ๊ธฐ๋ณธ ์„ค์ • */
630
  table {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
  width: 100% !important;
632
+ border-collapse: collapse;
633
  }
634
 
635
+ /* 2. ์…€ ๋‚ด๋ถ€ ํ…์ŠคํŠธ ๊ทœ์น™ (JS ์กฐ์ž‘์„ ์œ„ํ•ด min-width ์กฑ์‡„ ์™„๋ฒฝ ์ œ๊ฑฐ) */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
  thead th {
637
  font-size: 18px !important;
638
  position: sticky;
 
640
  background: white;
641
  z-index: 10;
642
  }
643
+ td, th {
 
 
 
 
 
 
 
 
 
 
644
  font-size: 18px !important;
645
+ word-break: break-word !important; /* ๊ธด ํ…์ŠคํŠธ ํญ์ฃผ ๋ฐฉ์ง€ */
646
+ white-space: normal !important; /* ์—ฌ์œ  ๊ณต๊ฐ„์— ๋งž์ถฐ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ค„๋ฐ”๊ฟˆ */
647
  line-height: 1.6;
648
  padding: 10px;
649
  vertical-align: top !important;
 
653
  display: block;
654
  max-width: none !important;
655
  }
 
 
 
 
 
656
 
657
+ /* 3. Gradio 6.x ์ „์šฉ: ํ‘œ ์ˆจ๊น€ ๋ฐฉ์–ด๋ง‰ ์™„๋ฒฝ ํ•ด์ œ */
 
 
 
 
 
 
 
 
 
658
  .gradio-container .dataframe,
659
  .gradio-container .dataframe div,
660
  .gradio-container thead,
 
662
  .gradio-container th {
663
  overflow: visible !important;
664
  }
665
+ .dataframe {
666
+ max-height: none !important;
667
+ overflow-y: visible !important;
668
+ overflow-x: auto !important;
669
+ display: block;
670
+ }
671
 
672
+ /* 4. ํ•ธ๋“ค(Resizer) ๋””์ž์ธ */
673
  .resizer {
674
+ background-color: rgba(255, 0, 0, 0.5); /* ํ…Œ์ŠคํŠธ์šฉ ๋นจ๊ฐ„์„  (์ž‘๋™ ํ™•์ธ ํ›„ transparent๋กœ ๋ณ€๊ฒฝํ•˜์„ธ์š”) */
675
+ width: 8px !important;
676
  height: 100%;
677
  position: absolute;
678
  right: 0;
679
  top: 0;
680
  cursor: col-resize;
681
+ z-index: 9999 !important;
682
+ }
683
+ .resizer:hover, .resizer.resizing {
684
+ background-color: #1a73e8 !important; /* ๋งˆ์šฐ์Šค๋กœ ์žก๊ณ  ๋Œ ๋•Œ ํŒŒ๋ž€์ƒ‰ */
685
  }
686
 
687
+ /* 5. ์ดˆ๊ธฐ ๋ Œ๋”๋ง ๋น„์œจ ์œ ์ง€ (JS๊ฐ€ ์กฐ์ž‘ํ•  ์ˆ˜ ์žˆ๋„๋ก !important ์ œ๊ฑฐ) */
688
+ table:has(th:nth-last-child(2):first-child),
689
+ table:has(th:nth-last-child(4):first-child),
690
+ table:has(th:nth-last-child(5):first-child),
691
+ table:has(th:nth-last-child(6):first-child) {
692
+ table-layout: fixed;
693
  }
694
+
695
+ table th:nth-last-child(2):first-child, table td:nth-last-child(2):first-child { width: 15%; }
696
+ table th:nth-last-child(1), table td:nth-last-child(1) { width: 85%; }
697
+
698
+ table th:nth-child(1):nth-last-child(4), table td:nth-child(1):nth-last-child(4) { width: 10%; }
699
+ table th:nth-child(2):nth-last-child(3), table td:nth-child(2):nth-last-child(3) { width: 40%; }
700
+ table th:nth-child(3):nth-last-child(2), table td:nth-child(3):nth-last-child(2) { width: 10%; }
701
+ table th:nth-child(4):nth-last-child(1), table td:nth-child(4):nth-last-child(1) { width: 40%; }
702
+
703
+ table th:nth-child(1):nth-last-child(5), table td:nth-child(1):nth-last-child(5) { width: 15%; }
704
+ table th:nth-child(2):nth-last-child(4), table td:nth-child(2):nth-last-child(4) { width: 10%; }
705
+ table th:nth-child(3):nth-last-child(3), table td:nth-child(3):nth-last-child(3) { width: 30%; }
706
+ table th:nth-child(4):nth-last-child(2), table td:nth-child(4):nth-last-child(2) { width: 10%; }
707
+ table th:nth-child(5):nth-last-child(1), table td:nth-child(5):nth-last-child(1) { width: 35%; }
708
+
709
+ table th:nth-child(1):nth-last-child(6), table td:nth-child(1):nth-last-child(6) { width: 8%; }
710
+ table th:nth-child(2):nth-last-child(5), table td:nth-child(2):nth-last-child(5) { width: 15%; }
711
+ table th:nth-child(3):nth-last-child(4), table td:nth-child(3):nth-last-child(4) { width: 27%; }
712
+ table th:nth-child(4):nth-last-child(3), table td:nth-child(4):nth-last-child(3) { width: 8%; }
713
+ table th:nth-child(5):nth-last-child(2), table td:nth-child(5):nth-last-child(2) { width: 15%; }
714
+ table th:nth-child(6):nth-last-child(1), table td:nth-child(6):nth-last-child(1) { width: 27%; }
715
  """
716
 
717
  if __name__ == "__main__":