|
import streamlit as st |
|
|
|
|
|
def add_sticky_header_css(): |
|
st.markdown(""" |
|
<style> |
|
/* Make Streamlit's stMainMenu button aqua */ |
|
[data-testid="stMainMenu"] { |
|
background-color: #00FFFF; |
|
} |
|
|
|
/* Make Streamlit's status widget sticky */ |
|
[data-testid="stStatusWidget"] { |
|
position: fixed; |
|
bottom: 0; |
|
right: 0; |
|
z-index: 1000; |
|
background-color: yellow; /* #90EE90 */ |
|
padding: 5px; |
|
border-top: 1px solid #f0f0f0; |
|
width: 100%; |
|
} |
|
|
|
/* Add padding to main content to prevent overlap with fixed header */ |
|
.main .block-container { |
|
padding-top: 5rem; |
|
padding-bottom: 3rem; |
|
} |
|
</style> |
|
""", unsafe_allow_html=True) |
|
|
|
def scroll_to_bottom(): |
|
|
|
js_code = """ |
|
<script> |
|
// Function to scroll to bottom |
|
function scrollToBottom() { |
|
// This targets Streamlit's specific structure |
|
const mainContainer = window.parent.document.querySelector('.stApp'); |
|
if (mainContainer) { |
|
mainContainer.scrollTo({ |
|
top: mainContainer.scrollHeight, |
|
behavior: 'smooth' |
|
}); |
|
} |
|
} |
|
|
|
// Use MutationObserver to detect when content is added |
|
const observer = new MutationObserver((mutations) => { |
|
scrollToBottom(); |
|
}); |
|
|
|
// Start observing the document body for changes |
|
const streamlitDoc = window.parent.document; |
|
observer.observe(streamlitDoc.body, { |
|
childList: true, |
|
subtree: true |
|
}); |
|
|
|
// Initial scroll and disconnect after some time |
|
scrollToBottom(); |
|
setTimeout(() => { |
|
observer.disconnect(); |
|
// One final scroll |
|
scrollToBottom(); |
|
}, 1000); |
|
</script> |
|
""" |
|
|
|
|
|
st.markdown(js_code, unsafe_allow_html=True) |
|
|
|
|
|
|
|
add_sticky_header_css() |
|
|
|
|
|
|
|
|
|
type_text_page = st.Page( |
|
page="pages/type_text.py", |
|
title="DEMO (work in progress)", |
|
icon=":material/keyboard:", |
|
default=True,) |
|
|
|
|
|
st.logo(image="images/menu_book_60dp_75FBFD.png") |
|
st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning") |
|
st.subheader("Select specific Chapter for quicker results") |
|
st.sidebar.header("SBS V2.0 mapper") |
|
st.sidebar.write("(work in progress)") |
|
st.sidebar.text("Demo by JA-RAD") |
|
|
|
|
|
|
|
pg = st.navigation(pages=[type_text_page]) |
|
|
|
pg.run() |
|
|