gvlktejaswi commited on
Commit
3d71ac3
·
verified ·
1 Parent(s): 19d3ef8

Update page_files/Home.py

Browse files
Files changed (1) hide show
  1. page_files/Home.py +49 -31
page_files/Home.py CHANGED
@@ -79,24 +79,17 @@ st.markdown("""
79
  st.markdown("""
80
  <style>
81
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap');
82
-
83
  /* Hide default Streamlit chrome */
84
  .block-container { padding: 0 !important; max-width: 100% !important; background: #fff !important;}
85
  [data-testid="stToolbar"],
86
  [data-testid="stDecoration"],
87
  [data-testid="stHeader"] { display: none !important; }
88
-
89
-
90
-
91
-
92
-
93
  /* ── Search row ── */
94
  /* Only target the search bar's horizontal block, not all columns */
95
  .st-emotion-cache-y1l7l5 .st-emotion-cache-1permvm {
96
  gap: 0 !important;
97
  align-items: stretch !important;
98
  }
99
-
100
  .st-emotion-cache-16s2yzk button {
101
  background: #f2f6f4 !important;
102
  border: 1.5px solid #d0d8d4 !important;
@@ -111,7 +104,6 @@ st.markdown("""
111
  white-space: nowrap !important;
112
  box-shadow: none !important;
113
  }
114
-
115
  .st-emotion-cache-4dubyl [data-baseweb="input"] {
116
  background: #000 !important;
117
  height: 46px !important;
@@ -133,9 +125,7 @@ st.markdown("""
133
  box-shadow: none !important;
134
  padding-left: 18px !important;
135
  }
136
-
137
  .st-emotion-cache-4dubyl > div {
138
-
139
  height: 46px !important;
140
  }
141
  .st-emotion-cache-4dubyl input::placeholder {
@@ -155,7 +145,6 @@ st.markdown("""
155
  padding: 0 28px !important;
156
  box-shadow: none !important;
157
  }
158
-
159
  .st-key-view_all_btn button {
160
  background: transparent !important;
161
  border: none !important;
@@ -183,7 +172,6 @@ st.markdown("""
183
  margin-bottom: 14px;
184
  font-family: 'DM Sans', sans-serif;
185
  }
186
-
187
  </style>
188
  """, unsafe_allow_html=True)
189
 
@@ -198,7 +186,32 @@ elif _nav == "search":
198
  st.query_params.clear()
199
  st.switch_page("page_files/Categorized_Search.py")
200
 
201
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
  # Helper
204
  def go_categorized(material=None, search=None):
@@ -235,7 +248,6 @@ components.html(f"""
235
  <style>
236
  *, *::before, *::after {{ box-sizing: border-box; margin: 0; padding: 0; }}
237
  body {{ font-family: 'DM Sans', sans-serif; background: #f7f7f5; color: #1a2e26; overflow-x: hidden; }}
238
-
239
  /* ANIMATION SECTION */
240
  .anim-section {{
241
  background: #000;
@@ -251,7 +263,6 @@ body {{ font-family: 'DM Sans', sans-serif; background: #f7f7f5; color: #1a2e26;
251
  display: flex; align-items: center;
252
  justify-content: space-between; padding: 0 40px;
253
  }}
254
-
255
  /* MAG GLASS */
256
  .mag-wrap {{ position: relative; width: 100px; display: flex; flex-direction: column; align-items: center; }}
257
  .mag-label {{ font-size: 0.65rem; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: #4a7a6a; margin-bottom: 10px; }}
@@ -262,7 +273,6 @@ body {{ font-family: 'DM Sans', sans-serif; background: #f7f7f5; color: #1a2e26;
262
  .mag-scan {{ opacity: 0; transition: opacity 0.3s ease 0.8s; }}
263
  .mag-wrap.active .mag-scan {{ opacity: 1; animation: scanMove 1.2s ease-in-out infinite 0.8s; }}
264
  @keyframes scanMove {{ 0% {{ transform:translateY(-14px);opacity:.8; }} 50% {{ transform:translateY(0);opacity:1; }} 100% {{ transform:translateY(14px);opacity:.8; }} }}
265
-
266
  /* BUBBLES */
267
  .bubble {{ position:absolute; border-radius:50%; background:radial-gradient(circle at 35% 35%,rgba(255,255,255,.6),rgba(80,160,255,.25)); border:1px solid rgba(100,180,255,.4); opacity:0; pointer-events:none; backdrop-filter:blur(2px); }}
268
  .b1 {{ width:18px;height:18px;left:108px;bottom:155px; }}
@@ -283,7 +293,6 @@ body {{ font-family: 'DM Sans', sans-serif; background: #f7f7f5; color: #1a2e26;
283
  @keyframes floatBubble4 {{ 0% {{ opacity:0;transform:translate(0,0) scale(.3); }} 20% {{ opacity:1;transform:translate(-8px,-35px) scale(1); }} 65% {{ opacity:.8;transform:translate(105px,-80px) scale(.8); }} 88% {{ opacity:.3;transform:translate(255px,-50px) scale(.4); }} 100% {{ opacity:0;transform:translate(320px,-20px) scale(.1); }} }}
284
  @keyframes floatBubble5 {{ 0% {{ opacity:0;transform:translate(0,0) scale(.4); }} 15% {{ opacity:1;transform:translate(3px,-22px) scale(1); }} 58% {{ opacity:.9;transform:translate(115px,-60px) scale(.88); }} 83% {{ opacity:.45;transform:translate(270px,-35px) scale(.55); }} 100% {{ opacity:0;transform:translate(335px,-12px) scale(.2); }} }}
285
  @keyframes floatBubble6 {{ 0% {{ opacity:0;transform:translate(0,0) scale(.25); }} 20% {{ opacity:1;transform:translate(-3px,-40px) scale(1); }} 62% {{ opacity:.7;transform:translate(100px,-85px) scale(.75); }} 85% {{ opacity:.25;transform:translate(250px,-55px) scale(.35); }} 100% {{ opacity:0;transform:translate(318px,-22px) scale(.1); }} }}
286
-
287
  /* DATABASE */
288
  .db-wrap {{ position:relative;width:130px;display:flex;flex-direction:column;align-items:center; }}
289
  .db-label {{ font-size:.65rem;font-weight:600;letter-spacing:1.5px;text-transform:uppercase;color:#4a7a6a;margin-bottom:10px; }}
@@ -292,7 +301,6 @@ body {{ font-family: 'DM Sans', sans-serif; background: #f7f7f5; color: #1a2e26;
292
  .anim-stage.active .cyl-right {{ opacity:1;transition-delay:2.2s; }}
293
  .anim-stage.active .cyl-front {{ opacity:1;transition-delay:2.4s;animation:frontPulse 2.4s ease-in-out infinite 2.8s; }}
294
  @keyframes frontPulse {{ 0%,100% {{ filter:brightness(1); }} 50% {{ filter:brightness(1.2); }} }}
295
-
296
  /* CAPTION */
297
  .anim-caption {{ margin-top:48px;display:flex;gap:40px;align-items:center; }}
298
  .anim-step {{ display:flex;align-items:center;gap:10px;opacity:0;transform:translateY(10px);transition:opacity .5s ease,transform .5s ease; }}
@@ -302,7 +310,6 @@ body {{ font-family: 'DM Sans', sans-serif; background: #f7f7f5; color: #1a2e26;
302
  .step-text {{ font-size:.78rem;color:#5a8a7a;font-weight:500; }}
303
  </style>
304
  </head><body>
305
-
306
  <section class="anim-section">
307
  <h2 class="anim-title">From Experiment to Database</h2>
308
  <div class="anim-stage" id="animStage">
@@ -394,7 +401,6 @@ body {{ font-family: 'DM Sans', sans-serif; background: #f7f7f5; color: #1a2e26;
394
  <div class="anim-step"><span class="step-text">Stored in AIM</span></div>
395
  </div>
396
  </section>
397
-
398
  <script>
399
  const stage = document.getElementById('animStage');
400
  const magWrap = document.getElementById('magWrap');
@@ -523,7 +529,7 @@ def _build_showcase_html(extract_b64, search_b64):
523
  "</div>"
524
  )
525
  extract_card = (
526
- "<div class=\"s-card\" onclick=\"window.parent.postMessage({queryString:'?nav=upload'},'https://huggingface.co')\">"
527
  "<img class=\"s-card-img\" src=\"" + extract_b64 + "\" alt=\"Extract Data\"/>"
528
  "<div class=\"s-card-body\">"
529
  "<div class=\"s-card-title\">Extract Data</div>"
@@ -532,7 +538,7 @@ def _build_showcase_html(extract_b64, search_b64):
532
  "</div></div>"
533
  )
534
  search_card = (
535
- "<div class=\"s-card\" onclick=\"window.parent.postMessage({queryString:'?nav=search'},'https://huggingface.co')\">"
536
  "<img class=\"s-card-img\" src=\"" + search_b64 + "\" alt=\"Search\"/>"
537
  "<div class=\"s-card-body\">"
538
  "<div class=\"s-card-title\">Search</div>"
@@ -576,7 +582,27 @@ def _build_showcase_html(extract_b64, search_b64):
576
  )
577
 
578
 
 
 
 
 
 
 
 
 
579
 
 
 
 
 
 
 
 
 
 
 
 
 
580
 
581
 
582
 
@@ -594,7 +620,6 @@ components.html(f"""
594
  <style>
595
  *, *::before, *::after {{ box-sizing: border-box; margin: 0; padding: 0; }}
596
  body {{ font-family: 'DM Sans', sans-serif; color: #1a2e26; }}
597
-
598
  .aim-about {{ background: #fff; padding: 60px; border-bottom: 1px solid #e8e8e4; }}
599
  .aim-about h2 {{ font-size: 1.65rem; font-weight: 700; color: #0f1f1a; letter-spacing: -0.5px; margin-bottom: 8px; }}
600
  .aim-about-sub {{ color: #6a7e77; font-size: 0.9rem; margin-bottom: 30px; }}
@@ -607,13 +632,11 @@ body {{ font-family: 'DM Sans', sans-serif; color: #1a2e26; }}
607
  display: flex; align-items: center; justify-content: center;
608
  color: #7a9e8f; font-size: 0.85rem; border: 1.5px dashed #c8d6d0;
609
  }}
610
-
611
  .aim-footer {{ background: #fff; border-top: 1px solid #e8e8e4; padding: 50px 60px 28px; }}
612
  .aim-footer-brand {{ display: flex; align-items: center; gap: 8px; font-weight: 700; color: #0f1f1a; font-size: 0.95rem; margin-bottom: 10px; }}
613
  .aim-footer-desc {{ font-size: 0.82rem; color: #7a8e87; line-height: 1.6; }}
614
  </style>
615
  </head><body>
616
-
617
  <section class="aim-about">
618
  <h2>About the Platform</h2>
619
  <p class="aim-about-sub">Artificially Intelligent Manufacturing Paradigm (AIM) for Composites</p>
@@ -633,9 +656,6 @@ body {{ font-family: 'DM Sans', sans-serif; color: #1a2e26; }}
633
  <div>{about_img_html}</div>
634
  </div>
635
  </section>
636
-
637
-
638
-
639
  </body></html>
640
  """, height=550, scrolling=False)
641
 
@@ -701,7 +721,6 @@ div[data-testid="stHorizontalBlock"]:has(.footer-nav-head) {
701
  .st-emotion-cache-1qeq59m:hover p {
702
  color: #8ACAFF !important;
703
  }
704
-
705
  /* copyright bar */
706
  .aim-footer-bottom {
707
  background: #fff;
@@ -711,7 +730,6 @@ div[data-testid="stHorizontalBlock"]:has(.footer-nav-head) {
711
  color: #a0b0aa;
712
  font-family: 'DM Sans', sans-serif;
713
  }
714
-
715
  </style>
716
  """, unsafe_allow_html=True)
717
 
@@ -744,4 +762,4 @@ with _:
744
  st.page_link(
745
  "page_files/Contact_Team.py",
746
  label="Contact Team",
747
- )
 
79
  st.markdown("""
80
  <style>
81
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap');
 
82
  /* Hide default Streamlit chrome */
83
  .block-container { padding: 0 !important; max-width: 100% !important; background: #fff !important;}
84
  [data-testid="stToolbar"],
85
  [data-testid="stDecoration"],
86
  [data-testid="stHeader"] { display: none !important; }
 
 
 
 
 
87
  /* ── Search row ── */
88
  /* Only target the search bar's horizontal block, not all columns */
89
  .st-emotion-cache-y1l7l5 .st-emotion-cache-1permvm {
90
  gap: 0 !important;
91
  align-items: stretch !important;
92
  }
 
93
  .st-emotion-cache-16s2yzk button {
94
  background: #f2f6f4 !important;
95
  border: 1.5px solid #d0d8d4 !important;
 
104
  white-space: nowrap !important;
105
  box-shadow: none !important;
106
  }
 
107
  .st-emotion-cache-4dubyl [data-baseweb="input"] {
108
  background: #000 !important;
109
  height: 46px !important;
 
125
  box-shadow: none !important;
126
  padding-left: 18px !important;
127
  }
 
128
  .st-emotion-cache-4dubyl > div {
 
129
  height: 46px !important;
130
  }
131
  .st-emotion-cache-4dubyl input::placeholder {
 
145
  padding: 0 28px !important;
146
  box-shadow: none !important;
147
  }
 
148
  .st-key-view_all_btn button {
149
  background: transparent !important;
150
  border: none !important;
 
172
  margin-bottom: 14px;
173
  font-family: 'DM Sans', sans-serif;
174
  }
 
175
  </style>
176
  """, unsafe_allow_html=True)
177
 
 
186
  st.query_params.clear()
187
  st.switch_page("page_files/Categorized_Search.py")
188
 
189
+ # PostMessage listener for iframe card clicks
190
+ components.html("""
191
+ <script>
192
+ window.addEventListener('message', function(e) {
193
+ if (e.data && e.data.type === 'streamlit:setComponentValue') {
194
+ // Write to a hidden input Streamlit can read via query params
195
+ const val = e.data.value;
196
+ window.parent.location.href = window.parent.location.href.split('?')[0] + '?card=' + val;
197
+ }
198
+ });
199
+ </script>
200
+ """, height=0)
201
+
202
+ # Check query param for card navigation
203
+ import urllib.parse
204
+ try:
205
+ _qp = st.query_params
206
+ if "card" in _qp:
207
+ _card_val = _qp["card"]
208
+ st.query_params.clear()
209
+ if _card_val == "upload":
210
+ st.switch_page("page_files/Upload_Data.py")
211
+ elif _card_val == "search":
212
+ st.switch_page("page_files/Categorized_Search.py")
213
+ except Exception:
214
+ pass
215
 
216
  # Helper
217
  def go_categorized(material=None, search=None):
 
248
  <style>
249
  *, *::before, *::after {{ box-sizing: border-box; margin: 0; padding: 0; }}
250
  body {{ font-family: 'DM Sans', sans-serif; background: #f7f7f5; color: #1a2e26; overflow-x: hidden; }}
 
251
  /* ANIMATION SECTION */
252
  .anim-section {{
253
  background: #000;
 
263
  display: flex; align-items: center;
264
  justify-content: space-between; padding: 0 40px;
265
  }}
 
266
  /* MAG GLASS */
267
  .mag-wrap {{ position: relative; width: 100px; display: flex; flex-direction: column; align-items: center; }}
268
  .mag-label {{ font-size: 0.65rem; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: #4a7a6a; margin-bottom: 10px; }}
 
273
  .mag-scan {{ opacity: 0; transition: opacity 0.3s ease 0.8s; }}
274
  .mag-wrap.active .mag-scan {{ opacity: 1; animation: scanMove 1.2s ease-in-out infinite 0.8s; }}
275
  @keyframes scanMove {{ 0% {{ transform:translateY(-14px);opacity:.8; }} 50% {{ transform:translateY(0);opacity:1; }} 100% {{ transform:translateY(14px);opacity:.8; }} }}
 
276
  /* BUBBLES */
277
  .bubble {{ position:absolute; border-radius:50%; background:radial-gradient(circle at 35% 35%,rgba(255,255,255,.6),rgba(80,160,255,.25)); border:1px solid rgba(100,180,255,.4); opacity:0; pointer-events:none; backdrop-filter:blur(2px); }}
278
  .b1 {{ width:18px;height:18px;left:108px;bottom:155px; }}
 
293
  @keyframes floatBubble4 {{ 0% {{ opacity:0;transform:translate(0,0) scale(.3); }} 20% {{ opacity:1;transform:translate(-8px,-35px) scale(1); }} 65% {{ opacity:.8;transform:translate(105px,-80px) scale(.8); }} 88% {{ opacity:.3;transform:translate(255px,-50px) scale(.4); }} 100% {{ opacity:0;transform:translate(320px,-20px) scale(.1); }} }}
294
  @keyframes floatBubble5 {{ 0% {{ opacity:0;transform:translate(0,0) scale(.4); }} 15% {{ opacity:1;transform:translate(3px,-22px) scale(1); }} 58% {{ opacity:.9;transform:translate(115px,-60px) scale(.88); }} 83% {{ opacity:.45;transform:translate(270px,-35px) scale(.55); }} 100% {{ opacity:0;transform:translate(335px,-12px) scale(.2); }} }}
295
  @keyframes floatBubble6 {{ 0% {{ opacity:0;transform:translate(0,0) scale(.25); }} 20% {{ opacity:1;transform:translate(-3px,-40px) scale(1); }} 62% {{ opacity:.7;transform:translate(100px,-85px) scale(.75); }} 85% {{ opacity:.25;transform:translate(250px,-55px) scale(.35); }} 100% {{ opacity:0;transform:translate(318px,-22px) scale(.1); }} }}
 
296
  /* DATABASE */
297
  .db-wrap {{ position:relative;width:130px;display:flex;flex-direction:column;align-items:center; }}
298
  .db-label {{ font-size:.65rem;font-weight:600;letter-spacing:1.5px;text-transform:uppercase;color:#4a7a6a;margin-bottom:10px; }}
 
301
  .anim-stage.active .cyl-right {{ opacity:1;transition-delay:2.2s; }}
302
  .anim-stage.active .cyl-front {{ opacity:1;transition-delay:2.4s;animation:frontPulse 2.4s ease-in-out infinite 2.8s; }}
303
  @keyframes frontPulse {{ 0%,100% {{ filter:brightness(1); }} 50% {{ filter:brightness(1.2); }} }}
 
304
  /* CAPTION */
305
  .anim-caption {{ margin-top:48px;display:flex;gap:40px;align-items:center; }}
306
  .anim-step {{ display:flex;align-items:center;gap:10px;opacity:0;transform:translateY(10px);transition:opacity .5s ease,transform .5s ease; }}
 
310
  .step-text {{ font-size:.78rem;color:#5a8a7a;font-weight:500; }}
311
  </style>
312
  </head><body>
 
313
  <section class="anim-section">
314
  <h2 class="anim-title">From Experiment to Database</h2>
315
  <div class="anim-stage" id="animStage">
 
401
  <div class="anim-step"><span class="step-text">Stored in AIM</span></div>
402
  </div>
403
  </section>
 
404
  <script>
405
  const stage = document.getElementById('animStage');
406
  const magWrap = document.getElementById('magWrap');
 
529
  "</div>"
530
  )
531
  extract_card = (
532
+ "<div class=\"s-card\" onclick=\"window.parent.location.href='?nav=upload'\">"
533
  "<img class=\"s-card-img\" src=\"" + extract_b64 + "\" alt=\"Extract Data\"/>"
534
  "<div class=\"s-card-body\">"
535
  "<div class=\"s-card-title\">Extract Data</div>"
 
538
  "</div></div>"
539
  )
540
  search_card = (
541
+ "<div class=\"s-card\" onclick=\"window.parent.location.href='?nav=search'\">"
542
  "<img class=\"s-card-img\" src=\"" + search_b64 + "\" alt=\"Search\"/>"
543
  "<div class=\"s-card-body\">"
544
  "<div class=\"s-card-title\">Search</div>"
 
582
  )
583
 
584
 
585
+ # Hidden Streamlit buttons wired to the card clicks via JS
586
+ _btn_col1, _btn_col2 = st.columns(2)
587
+ with _btn_col1:
588
+ if st.button("Go to Extract Data", key="_nav_upload", help="", use_container_width=True):
589
+ st.switch_page("page_files/Upload_Data.py")
590
+ with _btn_col2:
591
+ if st.button("Go to Search", key="_nav_search", help="", use_container_width=True):
592
+ st.switch_page("page_files/Categorized_Search.py")
593
 
594
+ # Hide the nav buttons visually — they are only triggered by JS
595
+ st.markdown("""
596
+ <style>
597
+ .st-key-_nav_upload, .st-key-_nav_search {
598
+ position: absolute !important;
599
+ opacity: 0 !important;
600
+ pointer-events: none !important;
601
+ height: 0 !important;
602
+ overflow: hidden !important;
603
+ }
604
+ </style>
605
+ """, unsafe_allow_html=True)
606
 
607
 
608
 
 
620
  <style>
621
  *, *::before, *::after {{ box-sizing: border-box; margin: 0; padding: 0; }}
622
  body {{ font-family: 'DM Sans', sans-serif; color: #1a2e26; }}
 
623
  .aim-about {{ background: #fff; padding: 60px; border-bottom: 1px solid #e8e8e4; }}
624
  .aim-about h2 {{ font-size: 1.65rem; font-weight: 700; color: #0f1f1a; letter-spacing: -0.5px; margin-bottom: 8px; }}
625
  .aim-about-sub {{ color: #6a7e77; font-size: 0.9rem; margin-bottom: 30px; }}
 
632
  display: flex; align-items: center; justify-content: center;
633
  color: #7a9e8f; font-size: 0.85rem; border: 1.5px dashed #c8d6d0;
634
  }}
 
635
  .aim-footer {{ background: #fff; border-top: 1px solid #e8e8e4; padding: 50px 60px 28px; }}
636
  .aim-footer-brand {{ display: flex; align-items: center; gap: 8px; font-weight: 700; color: #0f1f1a; font-size: 0.95rem; margin-bottom: 10px; }}
637
  .aim-footer-desc {{ font-size: 0.82rem; color: #7a8e87; line-height: 1.6; }}
638
  </style>
639
  </head><body>
 
640
  <section class="aim-about">
641
  <h2>About the Platform</h2>
642
  <p class="aim-about-sub">Artificially Intelligent Manufacturing Paradigm (AIM) for Composites</p>
 
656
  <div>{about_img_html}</div>
657
  </div>
658
  </section>
 
 
 
659
  </body></html>
660
  """, height=550, scrolling=False)
661
 
 
721
  .st-emotion-cache-1qeq59m:hover p {
722
  color: #8ACAFF !important;
723
  }
 
724
  /* copyright bar */
725
  .aim-footer-bottom {
726
  background: #fff;
 
730
  color: #a0b0aa;
731
  font-family: 'DM Sans', sans-serif;
732
  }
 
733
  </style>
734
  """, unsafe_allow_html=True)
735
 
 
762
  st.page_link(
763
  "page_files/Contact_Team.py",
764
  label="Contact Team",
765
+ )