Update page_files/Home.py

#1
Files changed (1) hide show
  1. page_files/Home.py +100 -222
page_files/Home.py CHANGED
@@ -2,10 +2,8 @@ import streamlit as st
2
  import streamlit.components.v1 as components
3
  from pathlib import Path
4
  import base64
5
- from streamlit_card import card
6
  from data_loader import get_all_sections
7
  import random
8
- from data_loader import get_all_sections
9
  import re
10
 
11
 
@@ -54,13 +52,8 @@ def img_to_b64(path):
54
  return ""
55
 
56
 
57
- _HERE = Path(__file__).parent # page_files/
58
- _ROOT = _HERE.parent # project root
59
-
60
- home_img = img_to_b64(str(_ROOT / "Home.png"))
61
- logo_img = img_to_b64(str(_ROOT / "logo.png"))
62
- extract_card_img = img_to_b64(str(_ROOT / "extract_card_img.png"))
63
- search_card_img = img_to_b64(str(_ROOT / "search_card_img.png"))
64
 
65
  st.markdown("""
66
  <style>
@@ -173,7 +166,6 @@ st.markdown("""
173
  text-decoration: underline !important;
174
  background: transparent !important;
175
  }
176
- /* Showcase nav buttons */
177
  .footer-nav-head {
178
  font-size: 0.68rem;
179
  font-weight: 700;
@@ -423,46 +415,10 @@ st.markdown("""
423
  max-width: 500px; margin: 0 auto 28px;
424
  }
425
  </style>
426
- <div class="aim-hero-text">
427
- <h1>Accelerate Your Composites Research</h1>
428
- <p>Access a centralized, open-source database for experimental composite material properties.
429
- Polymer, fiber, and composite datasets , all in one place.</p>
430
- </div>
431
  """, unsafe_allow_html=True)
432
 
433
 
434
 
435
- # ══════════════════════════════════════════════════════════════════════════════
436
- # 4. STATS (static HTML)
437
- # ══════════════════════════════════════════════════════════════════════════════
438
- st.markdown(f"""
439
- <style>
440
- .aim-stats {{
441
- background: #f7f7f5; border-bottom: 1px solid #e4e8e5;
442
- display: flex; justify-content: center;
443
- }}
444
- .aim-stat {{
445
- text-align: center; padding: 34px 56px;
446
- border-right: 1px solid #e4e8e5;
447
- }}
448
- .aim-stat:last-child {{ border-right: none; }}
449
- .aim-stat-num {{
450
- font-family: 'DM Sans', sans-serif;
451
- font-size: 2.1rem; font-weight: 800;
452
- color: #8ACAFF; line-height: 1; margin-bottom: 6px;
453
- }}
454
- .aim-stat-label {{
455
- font-size: 0.68rem; font-weight: 600;
456
- letter-spacing: 1.4px; color: #7a8e87; text-transform: uppercase;
457
- }}
458
- </style>
459
- <div class="aim-stats">
460
- <div class="aim-stat"><div class="aim-stat-num">3</div><div class="aim-stat-label">Material Classes</div></div>
461
- <div class="aim-stat"><div class="aim-stat-num">{prop_count}</div><div class="aim-stat-label">Properties Tracked</div></div>
462
- <div class="aim-stat"><div class="aim-stat-num">8</div><div class="aim-stat-label">Research Teams</div></div>
463
- <div class="aim-stat"><div class="aim-stat-num">2</div><div class="aim-stat-label">Universities</div></div>
464
- </div>
465
- """, unsafe_allow_html=True)
466
 
467
 
468
  # ══════════════════════════════════════════════════════════════════════════════
@@ -470,220 +426,139 @@ st.markdown(f"""
470
  # ══════════════════════════════════════════════════════════════════════════════
471
  st.markdown("""
472
  <style>
473
- /* Card buttons - scoped to cards horizontal block only */
474
  .st-emotion-cache-r3ry0f button {
475
  background: #fff !important;
476
- border: 1.5px solid #e4e8e5 !important;
477
- border-radius: 12px !important;
478
- padding: 24px 20px !important;
479
- height: 160px !important;
480
  width: 100% !important;
481
  text-align: left !important;
482
  white-space: pre-wrap !important;
483
  line-height: 1.5 !important;
484
- box-shadow: none !important;
485
- transition: box-shadow 0.2s, border-color 0.2s !important;
486
  }
487
-
488
  .st-emotion-cache-r3ry0f button:hover {
489
- border-color: #BAE1FC !important;
490
- box-shadow: 0 0 0 3px rgba(186,225,252,0.25), 0 6px 22px rgba(0,0,0,0.07) !important;
491
  background: #fff !important;
 
492
  }
 
 
493
  .st-emotion-cache-r3ry0f button p:first-child {
494
- font-size: 1.1rem !important;
495
- background: #f2f4f3 !important;
496
- border-radius: 8px !important;
497
- padding: 6px 8px !important;
 
498
  display: inline-block !important;
499
- margin-bottom: 12px !important;
500
  line-height: 1 !important;
 
501
  }
 
 
502
  .st-emotion-cache-r3ry0f button p:nth-child(2) {
503
  font-family: 'DM Sans', sans-serif !important;
504
- font-size: 0.97rem !important;
505
  font-weight: 700 !important;
506
  color: #0f1f1a !important;
507
- margin-bottom: 6px !important;
 
508
  }
 
 
509
  .st-emotion-cache-r3ry0f button p:last-child {
510
  font-family: 'DM Sans', sans-serif !important;
511
- font-size: 0.7rem !important;
512
  font-weight: 700 !important;
513
- letter-spacing: 1.2px !important;
514
  color: #8ACAFF !important;
515
  text-transform: uppercase !important;
516
  }
517
- .cards-section-wrap h2 {
518
- font-family: 'DM Sans', sans-serif !important;
519
- font-size: 1.4rem !important;
520
- font-weight: 700 !important;
521
- color: #0f1f1a !important;
522
- margin-bottom: 6px !important;
523
- }
524
- .cards-section-wrap p {
525
- color: #5a6b65 !important;
526
- font-size: 0.9rem !important;
527
- line-height: 1.6 !important;
528
- margin-bottom: 16px !important;
529
- }
530
  </style>
531
  """, unsafe_allow_html=True)
532
 
533
 
 
534
 
535
- # Showcase section - Databricks style
536
- # Cards rendered in components.html so image+text+click all live inside one card
537
- _extract_img = extract_card_img
538
- _search_img = search_card_img
539
- extract_page_link = st.page_link("page_files/Upload_Data.py")
540
- search_page_link = st.page_link("page_files/Categorized_Search.py")
541
 
542
- components.html(f"""
543
- <!DOCTYPE html><html lang="en"><head>
544
- <meta charset="UTF-8"/>
545
- <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
546
- <style>
547
- *, *::before, *::after {{ box-sizing: border-box; margin: 0; padding: 0; }}
548
- body {{ font-family: 'DM Sans', sans-serif; background: #fff; }}
549
 
550
- .showcase-wrap {{
551
- display: flex;
552
- align-items: flex-start;
553
- gap: 48px;
554
- padding: 64px 60px 64px;
555
- background: #fff;
556
- }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
 
558
- /* LEFT TEXT */
559
- .showcase-left {{
560
- flex: 0 0 320px;
561
- padding-top: 16px;
562
- }}
563
- .showcase-label {{
564
- font-size: 0.68rem;
565
- font-weight: 700;
566
- letter-spacing: 1.8px;
567
- text-transform: uppercase;
568
- color: #8ACAFF;
569
- margin-bottom: 14px;
570
- }}
571
- .showcase-heading {{
572
- font-size: clamp(1.8rem, 3vw, 2.4rem);
573
- font-weight: 800;
574
- color: #0f1f1a;
575
- letter-spacing: -1px;
576
- line-height: 1.15;
577
- margin-bottom: 16px;
578
- }}
579
- .showcase-sub {{
580
- color: #5a6b65;
581
- font-size: 0.93rem;
582
- line-height: 1.7;
583
- }}
584
 
585
- /* RIGHT CARDS */
586
- .showcase-cards {{
587
- flex: 1;
588
- display: flex;
589
- gap: 20px;
590
- }}
591
- .s-card {{
592
- flex: 1;
593
- border-radius: 16px;
594
- overflow: hidden;
595
- background: #0f1f1a;
596
- border: 1.5px solid #1e3a30;
597
- box-shadow: 0 4px 20px rgba(0,0,0,0.10);
598
- text-decoration: none;
599
- display: flex;
600
- flex-direction: column;
601
- transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
602
- cursor: pointer;
603
- }}
604
- .s-card:hover {{
605
- box-shadow: 0 8px 32px rgba(138,202,255,0.18);
606
- border-color: #8ACAFF;
607
- transform: translateY(-3px);
608
- }}
609
- .s-card-img {{
610
- width: 100%;
611
- height: 200px;
612
- object-fit: cover;
613
- object-position: top left;
614
- display: block;
615
- border-bottom: 1px solid #1e3a30;
616
- }}
617
- .s-card-body {{
618
- padding: 22px 22px 26px;
619
- flex: 1;
620
- display: flex;
621
- flex-direction: column;
622
- }}
623
- .s-card-title {{
624
- font-size: 1.15rem;
625
- font-weight: 700;
626
- color: #fff;
627
- margin-bottom: 8px;
628
- letter-spacing: -0.3px;
629
- }}
630
- .s-card-desc {{
631
- font-size: 0.85rem;
632
- color: #7a9e8f;
633
- line-height: 1.6;
634
- flex: 1;
635
- margin-bottom: 18px;
636
  }}
637
- .s-card-link {{
638
- font-size: 0.85rem;
639
- font-weight: 600;
640
- color: #8ACAFF;
641
- text-decoration: none;
642
- display: inline-flex;
643
- align-items: center;
644
- gap: 6px;
645
  }}
646
- .s-card-link::after {{
647
- content: "\2192";
 
648
  }}
649
  </style>
650
- </head><body>
651
-
652
- <div class="showcase-wrap">
653
- <div class="showcase-left">
654
- <div class="showcase-label">Platform Features</div>
655
- <div class="showcase-heading">Accelerate Your Composites Research</div>
656
- <p class="showcase-sub">Access a centralized, open-source database for experimental composite
657
- material properties. Polymer, fiber, and composite datasets, all in one place.</p>
658
- </div>
659
-
660
- <div class="showcase-cards">
661
- <a class="s-card" href="{extract_page_link}" target="_self">
662
- <img class="s-card-img" src="{_extract_img}" alt="Extract Data"/>
663
- <div class="s-card-body">
664
- <div class="s-card-title">Extract Data</div>
665
- <p class="s-card-desc">Upload experimental datasets and extract structured material property data into the AIM database.</p>
666
- <span class="s-card-link">Open platform</span>
667
- </div>
668
- </a>
669
-
670
- <a class="s-card" href="{search_page_link}" target="_self">
671
- <img class="s-card-img" src="{_search_img}" alt="Search"/>
672
- <div class="s-card-body">
673
- <div class="s-card-title">Search</div>
674
- <p class="s-card-desc">Browse and filter polymer, fiber, and composite material properties across the full database.</p>
675
- <span class="s-card-link">Open search</span>
676
- </div>
677
- </a>
678
- </div>
679
  </div>
680
-
681
- </body></html>
682
- """, height=420, scrolling=False)
683
-
684
-
685
-
686
-
687
 
688
  # ══════════════════════════════════════════════════════════════════════════════
689
  # 6. ABOUT + FOOTER (static HTML)
@@ -845,4 +720,7 @@ with _:
845
  st.page_link(
846
  "page_files/Contact_Team.py",
847
  label="Contact Team",
848
- )
 
 
 
 
2
  import streamlit.components.v1 as components
3
  from pathlib import Path
4
  import base64
 
5
  from data_loader import get_all_sections
6
  import random
 
7
  import re
8
 
9
 
 
52
  return ""
53
 
54
 
55
+ home_img = img_to_b64("images/Home.png")
56
+ logo_img = img_to_b64("logo.png")
 
 
 
 
 
57
 
58
  st.markdown("""
59
  <style>
 
166
  text-decoration: underline !important;
167
  background: transparent !important;
168
  }
 
169
  .footer-nav-head {
170
  font-size: 0.68rem;
171
  font-weight: 700;
 
415
  max-width: 500px; margin: 0 auto 28px;
416
  }
417
  </style>
 
 
 
 
 
418
  """, unsafe_allow_html=True)
419
 
420
 
421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
 
423
 
424
  # ══════════════════════════════════════════════════════════════════════════════
 
426
  # ══════════════════════════════════════════════════════════════════════════════
427
  st.markdown("""
428
  <style>
429
+ /* Card buttons */
430
  .st-emotion-cache-r3ry0f button {
431
  background: #fff !important;
432
+ border: 1.5px solid #e8eceb !important;
433
+ border-radius: 16px !important;
434
+ padding: 28px 24px !important;
435
+ height: 180px !important;
436
  width: 100% !important;
437
  text-align: left !important;
438
  white-space: pre-wrap !important;
439
  line-height: 1.5 !important;
440
+ box-shadow: 0 1px 4px rgba(0,0,0,0.04) !important;
441
+ transition: box-shadow 0.22s ease, border-color 0.22s ease, transform 0.18s ease !important;
442
  }
443
+
444
  .st-emotion-cache-r3ry0f button:hover {
445
+ border-color: #8ACAFF !important;
446
+ box-shadow: 0 0 0 3px rgba(138,202,255,0.18), 0 8px 28px rgba(0,0,0,0.09) !important;
447
  background: #fff !important;
448
+ transform: translateY(-2px) !important;
449
  }
450
+
451
+ /* Icon badge */
452
  .st-emotion-cache-r3ry0f button p:first-child {
453
+ font-size: 1.25rem !important;
454
+ background: linear-gradient(135deg, #f0f7ff 0%, #e8f4ff 100%) !important;
455
+ border: 1px solid #d4eaff !important;
456
+ border-radius: 10px !important;
457
+ padding: 8px 10px !important;
458
  display: inline-block !important;
459
+ margin-bottom: 16px !important;
460
  line-height: 1 !important;
461
+ box-shadow: 0 1px 3px rgba(138,202,255,0.15) !important;
462
  }
463
+
464
+ /* Title */
465
  .st-emotion-cache-r3ry0f button p:nth-child(2) {
466
  font-family: 'DM Sans', sans-serif !important;
467
+ font-size: 1.05rem !important;
468
  font-weight: 700 !important;
469
  color: #0f1f1a !important;
470
+ margin-bottom: 8px !important;
471
+ letter-spacing: -0.2px !important;
472
  }
473
+
474
+ /* Tag label */
475
  .st-emotion-cache-r3ry0f button p:last-child {
476
  font-family: 'DM Sans', sans-serif !important;
477
+ font-size: 0.65rem !important;
478
  font-weight: 700 !important;
479
+ letter-spacing: 1.5px !important;
480
  color: #8ACAFF !important;
481
  text-transform: uppercase !important;
482
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
483
  </style>
484
  """, unsafe_allow_html=True)
485
 
486
 
487
+ st.markdown("<div style='padding: 64px 0 0 0;'></div>", unsafe_allow_html=True)
488
 
489
+ # st.markdown("""
490
+ # <div class="cards-section-wrap">
491
+ # <h2>Quick Links</h2>
492
+ # <p>Open the pages you need most.</p>
493
+ # </div>
494
+ # """, unsafe_allow_html=True)
495
 
496
+ quick_cards = [
497
+ ("Search", "Data Page", "page_files/Categorized_Search.py", "search", "πŸ”Ž"),
498
+ ("Extract Data", "Platform", "page_files/Upload_Data.py", "about", "πŸ“‹"),
499
+ ]
 
 
 
500
 
501
+ col1, col2 = st.columns([5, 4], gap="large")
502
+ with col1:
503
+
504
+ st.markdown("""
505
+ <div style="padding: 48px 40px 24px 0px;">
506
+ <h1 style="font-family:'DM Sans',sans-serif; font-size:clamp(2rem,4.5vw,3.2rem); font-weight:800; color:#0f1f1a; line-height:1.1; letter-spacing:-1.5px; margin-bottom:18px;">
507
+ Accelerate Your Composites Research
508
+ </h1>
509
+ <p style="color:#5a6b65; font-size:1rem; line-height:1.65; margin:0;">
510
+ Access a centralized, open-source database for experimental composite material properties.
511
+ Polymer, fiber, and composite datasets β€” all in one place.
512
+ </p>
513
+ </div>
514
+ """, unsafe_allow_html=True)
515
+ with col2:
516
+ st.markdown("<div style='padding-top: 48px;'></div>", unsafe_allow_html=True)
517
+ cols = st.columns(2, gap="large")
518
+ for col, (title, tag, target_page, key_suffix, badge) in zip(cols, quick_cards):
519
+ with col:
520
+ if st.button(
521
+ f"{badge}\n\n{title}\n\n{tag}",
522
+ key=f"quick_{key_suffix}_page",
523
+ use_container_width=True,
524
+ ):
525
+ st.switch_page(target_page)
526
+
527
+ st.markdown("<div style='background:#fff; padding: 24px 0; border-bottom: 1px solid #e8e8e4;'></div>", unsafe_allow_html=True)
528
 
529
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
 
531
+ # ══════════════════════════════════════════════════════════════════════════════
532
+ # 4. STATS (static HTML)
533
+ # ══════════════════════════════════════════════════════════════════════════════
534
+ st.markdown(f"""
535
+ <style>
536
+ .aim-stats {{
537
+ background: #f7f7f5; border-bottom: 1px solid #e4e8e5;
538
+ display: flex; justify-content: center;
539
+ }}
540
+ .aim-stat {{
541
+ text-align: center; padding: 34px 56px;
542
+ border-right: 1px solid #e4e8e5;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
543
  }}
544
+ .aim-stat:last-child {{ border-right: none; }}
545
+ .aim-stat-num {{
546
+ font-family: 'DM Sans', sans-serif;
547
+ font-size: 2.1rem; font-weight: 800;
548
+ color: #8ACAFF; line-height: 1; margin-bottom: 6px;
 
 
 
549
  }}
550
+ .aim-stat-label {{
551
+ font-size: 0.68rem; font-weight: 600;
552
+ letter-spacing: 1.4px; color: #7a8e87; text-transform: uppercase;
553
  }}
554
  </style>
555
+ <div class="aim-stats">
556
+ <div class="aim-stat"><div class="aim-stat-num">3</div><div class="aim-stat-label">Material Classes</div></div>
557
+ <div class="aim-stat"><div class="aim-stat-num">{prop_count}</div><div class="aim-stat-label">Properties Tracked</div></div>
558
+ <div class="aim-stat"><div class="aim-stat-num">8</div><div class="aim-stat-label">Research Teams</div></div>
559
+ <div class="aim-stat"><div class="aim-stat-num">2</div><div class="aim-stat-label">Universities</div></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
  </div>
561
+ """, unsafe_allow_html=True)
 
 
 
 
 
 
562
 
563
  # ══════════════════════════════════════════════════════════════════════════════
564
  # 6. ABOUT + FOOTER (static HTML)
 
720
  st.page_link(
721
  "page_files/Contact_Team.py",
722
  label="Contact Team",
723
+ )
724
+
725
+
726
+