Update page_files/Home.py
Browse files- page_files/Home.py +10 -66
page_files/Home.py
CHANGED
|
@@ -198,32 +198,7 @@ elif _nav == "search":
|
|
| 198 |
st.query_params.clear()
|
| 199 |
st.switch_page("page_files/Categorized_Search.py")
|
| 200 |
|
| 201 |
-
|
| 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):
|
|
@@ -547,22 +522,17 @@ def _build_showcase_html(extract_b64, search_b64):
|
|
| 547 |
"composite material properties. Polymer, fiber, and composite datasets, all in one place.</p>"
|
| 548 |
"</div>"
|
| 549 |
)
|
| 550 |
-
|
| 551 |
extract_card = (
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
"<span class=\"s-card-link\">Open platform →</span>"
|
| 560 |
-
"</div></div>"
|
| 561 |
)
|
| 562 |
search_card = (
|
| 563 |
-
"<div class=\"s-card\" onclick=\""
|
| 564 |
-
"window.parent.postMessage({queryString:'?nav=search'},'https://huggingface.co');"
|
| 565 |
-
"\">"
|
| 566 |
"<img class=\"s-card-img\" src=\"" + search_b64 + "\" alt=\"Search\"/>"
|
| 567 |
"<div class=\"s-card-body\">"
|
| 568 |
"<div class=\"s-card-title\">Search</div>"
|
|
@@ -581,7 +551,6 @@ def _build_showcase_html(extract_b64, search_b64):
|
|
| 581 |
".showcase-sub{color:#5a6b65;font-size:.93rem;line-height:1.7;}"
|
| 582 |
".showcase-cards{flex:1;display:flex;gap:20px;}"
|
| 583 |
".s-card{flex:1;border-radius:16px;overflow:hidden;background:#0f1f1a;border:1.5px solid #1e3a30;"
|
| 584 |
-
"text-decoration:none;display:flex;flex-direction:column;"
|
| 585 |
"box-shadow:0 4px 20px rgba(0,0,0,.10);display:flex;flex-direction:column;"
|
| 586 |
"cursor:pointer;transition:box-shadow .2s,border-color .2s,transform .2s;}"
|
| 587 |
".s-card:hover{box-shadow:0 8px 32px rgba(138,202,255,.18);border-color:#8ACAFF;transform:translateY(-3px);}"
|
|
@@ -607,29 +576,7 @@ def _build_showcase_html(extract_b64, search_b64):
|
|
| 607 |
)
|
| 608 |
|
| 609 |
|
| 610 |
-
# Hidden Streamlit buttons wired to the card clicks via JS
|
| 611 |
-
components.html(_build_showcase_html(extract_card_img, search_card_img), height=480, scrolling=False)
|
| 612 |
|
| 613 |
-
_btn_col1, _btn_col2 = st.columns(2)
|
| 614 |
-
with _btn_col1:
|
| 615 |
-
if st.button("Go to Extract Data", key="_nav_upload", help="", use_container_width=True):
|
| 616 |
-
st.switch_page("page_files/Upload_Data.py")
|
| 617 |
-
with _btn_col2:
|
| 618 |
-
if st.button("Go to Search", key="_nav_search", help="", use_container_width=True):
|
| 619 |
-
st.switch_page("page_files/Categorized_Search.py")
|
| 620 |
-
|
| 621 |
-
# Hide the nav buttons visually — they are only triggered by JS
|
| 622 |
-
st.markdown("""
|
| 623 |
-
<style>
|
| 624 |
-
.st-key-_nav_upload, .st-key-_nav_search {
|
| 625 |
-
position: absolute !important;
|
| 626 |
-
opacity: 0 !important;
|
| 627 |
-
pointer-events: none !important;
|
| 628 |
-
height: 0 !important;
|
| 629 |
-
overflow: hidden !important;
|
| 630 |
-
}
|
| 631 |
-
</style>
|
| 632 |
-
""", unsafe_allow_html=True)
|
| 633 |
|
| 634 |
|
| 635 |
|
|
@@ -797,7 +744,4 @@ with _:
|
|
| 797 |
st.page_link(
|
| 798 |
"page_files/Contact_Team.py",
|
| 799 |
label="Contact Team",
|
| 800 |
-
)
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
|
|
|
|
| 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):
|
|
|
|
| 522 |
"composite material properties. Polymer, fiber, and composite datasets, all in one place.</p>"
|
| 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>"
|
| 530 |
+
"<p class=\"s-card-desc\">Upload experimental datasets and extract structured material property data into the AIM database.</p>"
|
| 531 |
+
"<span class=\"s-card-link\">Open platform →</span>"
|
| 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>"
|
|
|
|
| 551 |
".showcase-sub{color:#5a6b65;font-size:.93rem;line-height:1.7;}"
|
| 552 |
".showcase-cards{flex:1;display:flex;gap:20px;}"
|
| 553 |
".s-card{flex:1;border-radius:16px;overflow:hidden;background:#0f1f1a;border:1.5px solid #1e3a30;"
|
|
|
|
| 554 |
"box-shadow:0 4px 20px rgba(0,0,0,.10);display:flex;flex-direction:column;"
|
| 555 |
"cursor:pointer;transition:box-shadow .2s,border-color .2s,transform .2s;}"
|
| 556 |
".s-card:hover{box-shadow:0 8px 32px rgba(138,202,255,.18);border-color:#8ACAFF;transform:translateY(-3px);}"
|
|
|
|
| 576 |
)
|
| 577 |
|
| 578 |
|
|
|
|
|
|
|
| 579 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
|
| 581 |
|
| 582 |
|
|
|
|
| 744 |
st.page_link(
|
| 745 |
"page_files/Contact_Team.py",
|
| 746 |
label="Contact Team",
|
| 747 |
+
)
|
|
|
|
|
|
|
|
|