Update app.py
Browse files
app.py
CHANGED
@@ -1,85 +1,84 @@
|
|
1 |
-
import streamlit as st
|
2 |
|
3 |
-
#
|
4 |
-
|
|
|
5 |
<style>
|
6 |
-
/* Target
|
7 |
-
|
8 |
-
header
|
9 |
-
position: fixed;
|
10 |
-
top: 0;
|
11 |
-
left: 0;
|
12 |
-
right: 0;
|
13 |
-
|
14 |
-
z-index:
|
15 |
-
background-color:
|
16 |
-
box-shadow: 0 1px 5px rgba(0,0,0,0.1);
|
17 |
}
|
18 |
-
|
19 |
-
/*
|
20 |
-
section
|
21 |
-
|
|
|
|
|
22 |
}
|
23 |
-
|
24 |
-
/* Ensure content doesn't get hidden under the header */
|
25 |
-
.block-container {
|
26 |
-
padding-top: 1rem;
|
27 |
-
}
|
28 |
-
|
29 |
/* Fix for Hugging Face iframe specific issues */
|
30 |
-
|
31 |
-
padding-top:
|
32 |
}
|
33 |
-
|
34 |
-
/*
|
35 |
-
|
36 |
-
|
37 |
-
top: 0;
|
38 |
-
left: 0;
|
39 |
-
right: 0;
|
40 |
-
z-index: 999999;
|
41 |
-
background-color: white;
|
42 |
-
padding: 1rem;
|
43 |
-
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
44 |
-
/* Ensures content below isn't hidden */
|
45 |
-
margin-bottom: 3rem;
|
46 |
}
|
47 |
-
|
48 |
-
/*
|
49 |
-
|
50 |
-
|
51 |
}
|
52 |
</style>
|
53 |
-
"""
|
54 |
-
|
55 |
-
#
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
# --- Your Streamlit App ---
|
82 |
-
#st.logo(image="images/menu_book_60dp_75FBFD.png")
|
83 |
st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
|
84 |
st.subheader("Select specific Chapter for quicker results")
|
85 |
st.logo(image="images/menu_book_60dp_75FBFD.png")
|
@@ -87,9 +86,6 @@ st.sidebar.header("SBS V2.0 mapper")
|
|
87 |
st.sidebar.write("(work in progress)")
|
88 |
st.sidebar.text("Demo by JA-RAD")
|
89 |
|
90 |
-
|
91 |
-
|
92 |
# --- NAVIGATION SETUP ---
|
93 |
pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
|
94 |
-
|
95 |
-
pg.run()
|
|
|
1 |
+
import streamlit as st
|
2 |
|
3 |
+
# ---- HEADER CONFIGURATION ----
|
4 |
+
# More precise CSS selectors and properties for cross-platform compatibility
|
5 |
+
custom_css = """
|
6 |
<style>
|
7 |
+
/* Target the header with multiple selectors for better compatibility */
|
8 |
+
header[data-testid="stHeader"],
|
9 |
+
.stApp > header {
|
10 |
+
position: fixed !important;
|
11 |
+
top: 0 !important;
|
12 |
+
left: 0 !important;
|
13 |
+
right: 0 !important;
|
14 |
+
width: 100% !important;
|
15 |
+
z-index: 999999 !important;
|
16 |
+
background-color: #90EE90 !important;
|
17 |
+
box-shadow: 0 1px 5px rgba(0,0,0,0.1) !important;
|
18 |
}
|
19 |
+
|
20 |
+
/* Adjust main content to prevent overlap with fixed header */
|
21 |
+
section[data-testid="stMain"],
|
22 |
+
.main .block-container {
|
23 |
+
padding-top: 60px !important; /* Match your header height */
|
24 |
+
margin-top: 10px !important;
|
25 |
}
|
26 |
+
|
|
|
|
|
|
|
|
|
|
|
27 |
/* Fix for Hugging Face iframe specific issues */
|
28 |
+
.st-emotion-cache-lrlib {
|
29 |
+
padding-top: 60px !important;
|
30 |
}
|
31 |
+
|
32 |
+
/* For Hugging Face specific iframe handling */
|
33 |
+
iframe#streamlit-iframe {
|
34 |
+
padding-top: 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
+
|
37 |
+
/* Target Hugging Face's iframe content specifically */
|
38 |
+
body.hf-w-body .stApp {
|
39 |
+
padding-top: 60px !important;
|
40 |
}
|
41 |
</style>
|
42 |
+
"""
|
43 |
+
|
44 |
+
# Some Hugging Face deployments need JavaScript for header fixing
|
45 |
+
js_fix = """
|
46 |
+
<script>
|
47 |
+
// This script helps ensure the header stays fixed in Hugging Face's iframe environment
|
48 |
+
window.addEventListener('DOMContentLoaded', (event) => {
|
49 |
+
// Short delay to ensure DOM is fully loaded
|
50 |
+
setTimeout(() => {
|
51 |
+
const header = document.querySelector('header[data-testid="stHeader"]');
|
52 |
+
if (header) {
|
53 |
+
header.style.position = 'fixed';
|
54 |
+
header.style.top = '0';
|
55 |
+
header.style.zIndex = '999999';
|
56 |
+
header.style.width = '100%';
|
57 |
+
header.style.backgroundColor = '#90EE90';
|
58 |
+
|
59 |
+
// Add padding to main content
|
60 |
+
const mainContent = document.querySelector('section[data-testid="stMain"]');
|
61 |
+
if (mainContent) {
|
62 |
+
mainContent.style.paddingTop = '70px';
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}, 100);
|
66 |
+
});
|
67 |
+
</script>
|
68 |
+
"""
|
69 |
+
|
70 |
+
# Inject CSS and JS as early as possible in your app
|
71 |
+
st.markdown(custom_css, unsafe_allow_html=True)
|
72 |
+
st.markdown(js_fix, unsafe_allow_html=True)
|
73 |
+
|
74 |
+
# --- PAGE SETUP ---
|
75 |
+
type_text_page = st.Page(
|
76 |
+
page="pages/type_text.py",
|
77 |
+
title="DEMO (work in progress)",
|
78 |
+
icon=":material/keyboard:",
|
79 |
+
default=True,)
|
80 |
|
81 |
# --- Your Streamlit App ---
|
|
|
82 |
st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
|
83 |
st.subheader("Select specific Chapter for quicker results")
|
84 |
st.logo(image="images/menu_book_60dp_75FBFD.png")
|
|
|
86 |
st.sidebar.write("(work in progress)")
|
87 |
st.sidebar.text("Demo by JA-RAD")
|
88 |
|
|
|
|
|
89 |
# --- NAVIGATION SETUP ---
|
90 |
pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
|
91 |
+
pg.run()
|
|