gvlktejaswi commited on
Commit
9220b43
Β·
verified Β·
1 Parent(s): aed5108

Update page_files/Home.py

Browse files
Files changed (1) hide show
  1. page_files/Home.py +268 -62
page_files/Home.py CHANGED
@@ -25,14 +25,6 @@ if "visible_cards" not in st.session_state:
25
 
26
  VISIBLE_CARDS = st.session_state.visible_cards
27
  prop_count = len([c for c in ALL_CARDS if c[2] == "section"])
28
- # Navigation via session state β€” fires before any rendering
29
- if st.session_state.get("_go_extract"):
30
- st.session_state["_go_extract"] = False
31
- st.switch_page("page_files/Upload_Data.py")
32
- if st.session_state.get("_go_search"):
33
- st.session_state["_go_search"] = False
34
- st.switch_page("page_files/Categorized_Search.py")
35
-
36
 
37
  def get_card_icon(title: str, card_type: str) -> str:
38
  if card_type == "material":
@@ -206,15 +198,32 @@ elif _nav == "search":
206
  st.query_params.clear()
207
  st.switch_page("page_files/Categorized_Search.py")
208
 
209
-
210
-
211
- # Navigation handler - must be before any rendering
212
- if st.session_state.get("_go_extract"):
213
- st.session_state["_go_extract"] = False
214
- st.switch_page("page_files/Upload_Data.py")
215
- if st.session_state.get("_go_search"):
216
- st.session_state["_go_search"] = False
217
- st.switch_page("page_files/Categorized_Search.py")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
 
219
  # Helper
220
  def go_categorized(material=None, search=None):
@@ -529,61 +538,258 @@ st.markdown("""
529
 
530
 
531
  # Showcase section - Databricks style
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
532
 
533
  st.markdown("""
534
  <style>
535
- .st-key-btn_extract button, .st-key-btn_search button {
536
- background: #0f1f1a !important;
537
- color: #8ACAFF !important;
538
- border: 1.5px solid #1e3a30 !important;
539
- border-radius: 0 0 10px 10px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  font-family: 'DM Sans', sans-serif !important;
541
- font-weight: 600 !important;
542
- font-size: 0.88rem !important;
543
- height: 44px !important;
544
- box-shadow: none !important;
545
- margin-top: -8px !important;
546
- margin-bottom: 40px !important;
547
  }
548
- .st-key-btn_extract button:hover, .st-key-btn_search button:hover {
549
- background: #1e3a30 !important;
550
- border-color: #8ACAFF !important;
551
  color: #8ACAFF !important;
552
  }
 
 
 
 
 
 
 
 
 
 
 
553
  </style>
554
  """, unsafe_allow_html=True)
555
 
556
- _left, _card1, _card2 = st.columns([0.85, 1, 1])
557
 
558
- with _left:
559
- st.markdown("""
560
- <div style="padding-top:32px;">
561
- <div style="font-size:.68rem;font-weight:700;letter-spacing:1.8px;text-transform:uppercase;color:#8ACAFF;margin-bottom:14px;font-family:'DM Sans',sans-serif;">Platform Features</div>
562
- <div style="font-size:2rem;font-weight:800;color:#0f1f1a;letter-spacing:-1px;line-height:1.15;margin-bottom:16px;font-family:'DM Sans',sans-serif;">Accelerate Your Composites Research</div>
563
- <p style="color:#5a6b65;font-size:.93rem;line-height:1.7;font-family:'DM Sans',sans-serif;">Access a centralized, open-source database for experimental composite material properties. Polymer, fiber, and composite datasets, all in one place.</p>
564
- </div>
565
  """, unsafe_allow_html=True)
566
 
567
- with _card1:
568
- st.image(str(_ROOT / "extract_card_img.png"), use_container_width=True)
569
- st.markdown("""
570
- <div style="background:#0f1f1a;padding:16px 20px 8px;border:1.5px solid #1e3a30;border-top:none;border-bottom:none;">
571
- <div style="font-size:1.05rem;font-weight:700;color:#fff;font-family:'DM Sans',sans-serif;">Extract Data</div>
572
- <p style="font-size:.82rem;color:#7a9e8f;margin:6px 0 0;font-family:'DM Sans',sans-serif;">Upload experimental datasets and extract structured material property data into the AIM database.</p>
573
- </div>
574
- """, unsafe_allow_html=True)
575
- if st.button("Open Extract Data β†’", key="btn_extract", use_container_width=True):
576
- st.session_state["_go_extract"] = True
577
- st.rerun()
578
-
579
- with _card2:
580
- st.image(str(_ROOT / "search_card_img.png"), use_container_width=True)
581
- st.markdown("""
582
- <div style="background:#0f1f1a;padding:16px 20px 8px;border:1.5px solid #1e3a30;border-top:none;border-bottom:none;">
583
- <div style="font-size:1.05rem;font-weight:700;color:#fff;font-family:'DM Sans',sans-serif;">Search</div>
584
- <p style="font-size:.82rem;color:#7a9e8f;margin:6px 0 0;font-family:'DM Sans',sans-serif;">Browse and filter polymer, fiber, and composite material properties across the full database.</p>
585
- </div>
586
- """, unsafe_allow_html=True)
587
- if st.button("Open Search β†’", key="btn_search", use_container_width=True):
588
- st.session_state["_go_search"] = True
589
- st.rerun()
 
 
25
 
26
  VISIBLE_CARDS = st.session_state.visible_cards
27
  prop_count = len([c for c in ALL_CARDS if c[2] == "section"])
 
 
 
 
 
 
 
 
28
 
29
  def get_card_icon(title: str, card_type: str) -> str:
30
  if card_type == "material":
 
198
  st.query_params.clear()
199
  st.switch_page("page_files/Categorized_Search.py")
200
 
201
+ # PostMessage listener for iframe card clicks
202
+ components.html("""
203
+ <script>
204
+ window.addEventListener('message', function(e) {
205
+ if (e.data && e.data.type === 'streamlit:setComponentValue') {
206
+ // Write to a hidden input Streamlit can read via query params
207
+ const val = e.data.value;
208
+ window.parent.location.href = window.parent.location.href.split('?')[0] + '?card=' + val;
209
+ }
210
+ });
211
+ </script>
212
+ """, height=0)
213
+
214
+ # Check query param for card navigation
215
+ import urllib.parse
216
+ try:
217
+ _qp = st.query_params
218
+ if "card" in _qp:
219
+ _card_val = _qp["card"]
220
+ st.query_params.clear()
221
+ if _card_val == "upload":
222
+ st.switch_page("page_files/Upload_Data.py")
223
+ elif _card_val == "search":
224
+ st.switch_page("page_files/Categorized_Search.py")
225
+ except Exception:
226
+ pass
227
 
228
  # Helper
229
  def go_categorized(material=None, search=None):
 
538
 
539
 
540
  # Showcase section - Databricks style
541
+ def _build_showcase_html(extract_b64, search_b64):
542
+ left = (
543
+ "<div class=\"showcase-left\">"
544
+ "<div class=\"showcase-label\">Platform Features</div>"
545
+ "<div class=\"showcase-heading\">Accelerate Your Composites Research</div>"
546
+ "<p class=\"showcase-sub\">Access a centralized, open-source database for experimental "
547
+ "composite material properties. Polymer, fiber, and composite datasets, all in one place.</p>"
548
+ "</div>"
549
+ )
550
+ extract_card = (
551
+ "<div class=\"s-card\" onclick=\"window.parent.location.href='?nav=upload'\">"
552
+ "<img class=\"s-card-img\" src=\"" + extract_b64 + "\" alt=\"Extract Data\"/>"
553
+ "<div class=\"s-card-body\">"
554
+ "<div class=\"s-card-title\">Extract Data</div>"
555
+ "<p class=\"s-card-desc\">Upload experimental datasets and extract structured material property data into the AIM database.</p>"
556
+ "<span class=\"s-card-link\">Open platform &#x2192;</span>"
557
+ "</div></div>"
558
+ )
559
+ search_card = (
560
+ "<div class=\"s-card\" onclick=\"window.parent.location.href='?nav=search'\">"
561
+ "<img class=\"s-card-img\" src=\"" + search_b64 + "\" alt=\"Search\"/>"
562
+ "<div class=\"s-card-body\">"
563
+ "<div class=\"s-card-title\">Search</div>"
564
+ "<p class=\"s-card-desc\">Browse and filter polymer, fiber, and composite material properties across the full database.</p>"
565
+ "<span class=\"s-card-link\">Open search &#x2192;</span>"
566
+ "</div></div>"
567
+ )
568
+ css = (
569
+ "<style>"
570
+ "*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}"
571
+ "body{font-family:'DM Sans',sans-serif;background:#fff;}"
572
+ ".showcase-wrap{display:flex;align-items:flex-start;gap:48px;padding:64px 60px;background:#fff;}"
573
+ ".showcase-left{flex:0 0 280px;padding-top:16px;}"
574
+ ".showcase-label{font-size:.68rem;font-weight:700;letter-spacing:1.8px;text-transform:uppercase;color:#8ACAFF;margin-bottom:14px;}"
575
+ ".showcase-heading{font-size:2rem;font-weight:800;color:#0f1f1a;letter-spacing:-1px;line-height:1.15;margin-bottom:16px;}"
576
+ ".showcase-sub{color:#5a6b65;font-size:.93rem;line-height:1.7;}"
577
+ ".showcase-cards{flex:1;display:flex;gap:20px;}"
578
+ ".s-card{flex:1;border-radius:16px;overflow:hidden;background:#0f1f1a;border:1.5px solid #1e3a30;"
579
+ "box-shadow:0 4px 20px rgba(0,0,0,.10);display:flex;flex-direction:column;"
580
+ "cursor:pointer;transition:box-shadow .2s,border-color .2s,transform .2s;}"
581
+ ".s-card:hover{box-shadow:0 8px 32px rgba(138,202,255,.18);border-color:#8ACAFF;transform:translateY(-3px);}"
582
+ ".s-card-img{width:100%;height:220px;object-fit:contain;object-position:top center;"
583
+ "display:block;background:#fff;border-bottom:1px solid #1e3a30;}"
584
+ ".s-card-body{padding:20px 22px 24px;flex:1;display:flex;flex-direction:column;}"
585
+ ".s-card-title{font-size:1.1rem;font-weight:700;color:#fff;margin-bottom:8px;}"
586
+ ".s-card-desc{font-size:.83rem;color:#7a9e8f;line-height:1.6;flex:1;margin-bottom:16px;}"
587
+ ".s-card-link{font-size:.83rem;font-weight:600;color:#8ACAFF;}"
588
+ "</style>"
589
+ )
590
+ return (
591
+ "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"/>"
592
+ "<link href=\"https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap\" rel=\"stylesheet\">"
593
+ + css +
594
+ "</head><body>"
595
+ "<div class=\"showcase-wrap\">"
596
+ + left +
597
+ "<div class=\"showcase-cards\">"
598
+ + extract_card + search_card +
599
+ "</div></div>"
600
+ "</body></html>"
601
+ )
602
+
603
+
604
+ # Hidden Streamlit buttons wired to the card clicks via JS
605
+ _btn_col1, _btn_col2 = st.columns(2)
606
+ with _btn_col1:
607
+ if st.button("Go to Extract Data", key="_nav_upload", help="", use_container_width=True):
608
+ st.switch_page("page_files/Upload_Data.py")
609
+ with _btn_col2:
610
+ if st.button("Go to Search", key="_nav_search", help="", use_container_width=True):
611
+ st.switch_page("page_files/Categorized_Search.py")
612
+
613
+ # Hide the nav buttons visually β€” they are only triggered by JS
614
+ st.markdown("""
615
+ <style>
616
+ .st-key-_nav_upload, .st-key-_nav_search {
617
+ position: absolute !important;
618
+ opacity: 0 !important;
619
+ pointer-events: none !important;
620
+ height: 0 !important;
621
+ overflow: hidden !important;
622
+ }
623
+ </style>
624
+ """, unsafe_allow_html=True)
625
+
626
+
627
+
628
+
629
+
630
+
631
+
632
+ # ══════════════════════════════════════════════════════════════════════════════
633
+ # 6. ABOUT + FOOTER (static HTML)
634
+ # ══════════════════════════════════════════════════════════════════════════════
635
+ components.html(f"""
636
+ <!DOCTYPE html><html lang="en"><head>
637
+ <meta charset="UTF-8"/>
638
+ <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
639
+ <style>
640
+ *, *::before, *::after {{ box-sizing: border-box; margin: 0; padding: 0; }}
641
+ body {{ font-family: 'DM Sans', sans-serif; color: #1a2e26; }}
642
+
643
+ .aim-about {{ background: #fff; padding: 60px; border-bottom: 1px solid #e8e8e4; }}
644
+ .aim-about h2 {{ font-size: 1.65rem; font-weight: 700; color: #0f1f1a; letter-spacing: -0.5px; margin-bottom: 8px; }}
645
+ .aim-about-sub {{ color: #6a7e77; font-size: 0.9rem; margin-bottom: 30px; }}
646
+ .aim-about-grid {{ display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: start; }}
647
+ .aim-about-text p {{ color: #3a4e47; font-size: 0.91rem; line-height: 1.75; margin-bottom: 14px; }}
648
+ .aim-about-img {{ border-radius: 10px; overflow: hidden; border: 1px solid #e4e8e5; }}
649
+ .aim-about-img img {{ width: 100%; display: block; }}
650
+ .aim-about-img-placeholder {{
651
+ background: #f0f5f3; border-radius: 10px; height: 280px;
652
+ display: flex; align-items: center; justify-content: center;
653
+ color: #7a9e8f; font-size: 0.85rem; border: 1.5px dashed #c8d6d0;
654
+ }}
655
+
656
+ .aim-footer {{ background: #fff; border-top: 1px solid #e8e8e4; padding: 50px 60px 28px; }}
657
+ .aim-footer-brand {{ display: flex; align-items: center; gap: 8px; font-weight: 700; color: #0f1f1a; font-size: 0.95rem; margin-bottom: 10px; }}
658
+ .aim-footer-desc {{ font-size: 0.82rem; color: #7a8e87; line-height: 1.6; }}
659
+ </style>
660
+ </head><body>
661
+
662
+ <section class="aim-about">
663
+ <h2>About the Platform</h2>
664
+ <p class="aim-about-sub">Artificially Intelligent Manufacturing Paradigm (AIM) for Composites</p>
665
+ <div class="aim-about-grid">
666
+ <div class="aim-about-text">
667
+ <p>The AIM Database tool serves as a powerful, centralized hub designed to streamline
668
+ collaboration and information exchange within the composite materials research community.
669
+ The platform enables researchers to contribute to a shared knowledge base by uploading
670
+ experimental datasets through secure terminals.</p>
671
+ <p>Users can submit specific measurements regarding mechanical properties, thermal behavior,
672
+ and rheology, alongside their published journal papers , ensuring that both raw data and
673
+ peer-reviewed findings are integrated into one cohesive system.</p>
674
+ <p>All contributed information is securely aggregated within a central cloud architecture,
675
+ allowing for efficient storage, organization, and retrieval across polymer, fiber, and
676
+ composite categories.</p>
677
+ </div>
678
+ <div>{about_img_html}</div>
679
+ </div>
680
+ </section>
681
+
682
+
683
+
684
+ </body></html>
685
+ """, height=550, scrolling=False)
686
 
687
  st.markdown("""
688
  <style>
689
+
690
+ /* Footer nav wrapper */
691
+ div[data-testid="stHorizontalBlock"]:has(.footer-nav-head) {
692
+ background: #fff !important;
693
+ border-bottom: 1px solid #e8e8e4 !important;
694
+ padding: 0 60px 28px !important;
695
+ margin-top: -16px !important;
696
+
697
+ }
698
+ .aim-footer-brand {
699
+ display: flex;
700
+ align-items: center;
701
+ gap: 8px;
702
+ font-weight: 700;
703
+ color: #0f1f1a;
704
+ font-size: 0.95rem;
705
+ margin-bottom: 10px;
706
+ font-family: 'DM Sans', sans-serif;
707
+ }
708
+ .aim-footer-desc {
709
+ font-size: 0.82rem;
710
+ color: #7a8e87;
711
+ line-height: 1.6;
712
+ font-family: 'DM Sans', sans-serif;
713
+ }
714
+ .footer-nav-head {
715
+ font-size: 0.68rem;
716
+ font-weight: 700;
717
+ letter-spacing: 1.4px;
718
+ text-transform: uppercase;
719
+ color: #0f1f1a;
720
+ margin-bottom: 14px;
721
+ font-family: 'DM Sans', sans-serif;
722
+ }
723
+ .st-emotion-cache-1ofqig9 {
724
+ background: transparent !important;
725
+ border: none !important;
726
+ padding: 0 !important;
727
+ }
728
+ .st-emotion-cache-1qeq59m {
729
+ background: transparent !important;
730
+ border: none !important;
731
+ text-decoration: none !important;
732
+ padding: 0 0 9px 0 !important;
733
+ display: block !important;
734
+ }
735
+ .st-emotion-cache-1qeq59m:hover {
736
+ background: transparent !important;
737
+ border: none !important;
738
+ }
739
+ .st-emotion-cache-1qeq59m p {
740
+ color: #6a7e77 !important;
741
  font-family: 'DM Sans', sans-serif !important;
742
+ font-size: 0.83rem !important;
743
+ font-weight: 400 !important;
744
+ margin: 0 !important;
 
 
 
745
  }
746
+ .st-emotion-cache-1qeq59m:hover p {
 
 
747
  color: #8ACAFF !important;
748
  }
749
+
750
+ /* copyright bar */
751
+ .aim-footer-bottom {
752
+ background: #fff;
753
+ border-top: 1px solid #e8e8e4;
754
+ padding: 22px 60px;
755
+ font-size: 0.76rem;
756
+ color: #a0b0aa;
757
+ font-family: 'DM Sans', sans-serif;
758
+ }
759
+
760
  </style>
761
  """, unsafe_allow_html=True)
762
 
763
+ brand_col, db_col, sup_col, _ = st.columns([4, 2, 2, 2], vertical_alignment="top", width="stretch")
764
 
765
+ with brand_col:
766
+ st.markdown(f"""
767
+ <div class="aim-footer-brand">{logo_html} AIM Composites</div>
768
+ <p class="aim-footer-desc">Advancing composites research through open data and collaborative tools.
769
+ A joint initiative of Clemson University and University of Delaware.</p>
 
 
770
  """, unsafe_allow_html=True)
771
 
772
+ with sup_col:
773
+ st.markdown('<p class="footer-nav-head">DATABASE</p>', unsafe_allow_html=True)
774
+ st.page_link(
775
+ "page_files/Categorized_Search.py",
776
+ label="Browse Materials",
777
+ )
778
+ st.page_link(
779
+ "page_files/Categorized_Search.py",
780
+ label="Categorized Search",
781
+ )
782
+ st.page_link(
783
+ "page_files/Upload_Data.py",
784
+ label="Upload Data",
785
+ )
786
+
787
+ with _:
788
+ st.markdown('<p class="footer-nav-head">SUPPORT</p>', unsafe_allow_html=True)
789
+ st.page_link(
790
+ "page_files/Contact_Team.py",
791
+ label="Contact Team",
792
+ )
793
+
794
+
795
+