georad commited on
Commit
866bcb2
·
verified ·
1 Parent(s): 7deb7e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -78
app.py CHANGED
@@ -1,99 +1,75 @@
1
  import streamlit as st
2
 
3
- # Fix the CSS to avoid parsing errors
4
- custom_css = """
5
- <style>
6
- div.block-container {
7
- padding-top: 1rem;
8
- }
9
-
10
- div[data-testid="stDecoratedAppViewContainer"] > div:first-child {
11
- position: sticky !important;
12
- top: 0 !important;
13
- background-color: white;
14
- z-index: 999;
15
- padding: 0px !important;
16
- }
17
-
18
- .custom-header {
19
- background-color: #90EE90;
20
- padding: 1rem;
21
- border-bottom: 1px solid #ddd;
22
- width: 100%;
23
- }
24
-
25
- header[data-testid="stHeader"] {
26
- display: none;
27
- }
28
 
29
- section[data-testid="stSidebar"] {
30
- z-index: 0;
31
- }
 
32
  </style>
33
- """
 
 
34
 
35
- # Apply the CSS with proper escaping
36
- st.markdown(custom_css, unsafe_allow_html=True)
37
 
38
- # Create a custom header at the very top (this is key)
39
- # This must be the very first Streamlit element
40
- with st.container():
41
- st.markdown('<div class="custom-header">', unsafe_allow_html=True)
42
- col1, col2 = st.columns([1, 9])
43
-
44
- with col1:
45
- # Add logo
46
- try:
47
- st.image("images/menu_book_60dp_75FBFD.png", width=60)
48
- except:
49
- st.write("📚") # Fallback emoji if image doesn't load
50
-
51
- with col2:
52
- st.markdown("""
53
- <h2 style="margin: 0; padding: 0;">Map descriptions to SBS codes with Sentence Transformer + Reasoning</h2>
54
- <p style="margin: 0; padding: 0;">Select specific Chapter for quicker results</p>
55
- """, unsafe_allow_html=True)
56
-
57
- st.markdown('</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
58
 
59
- # Add a bit of spacing
60
- st.write("")
 
 
 
 
 
61
 
62
- # Sidebar content (similar to your original code)
 
63
  st.sidebar.header("SBS V2.0 mapper")
64
  st.sidebar.write("(work in progress)")
65
  st.sidebar.text("Demo by JA-RAD")
 
 
 
66
 
67
- # Page setup
68
- type_text_page = st.Page(
69
- page="pages/type_text.py",
70
- title="DEMO (work in progress)",
71
- icon=":material/keyboard:",
72
- default=True,)
73
-
74
- # Navigation
75
- pg = st.navigation(pages=[type_text_page])
76
- pg.run()
77
-
78
- # Inject CSS and JS as early as possible in your app
79
- st.markdown(custom_css, unsafe_allow_html=True)
80
- st.markdown(js_fix, unsafe_allow_html=True)
81
-
82
- # --- PAGE SETUP ---
83
  type_text_page = st.Page(
84
  page="pages/type_text.py",
85
  title="DEMO (work in progress)",
86
  icon=":material/keyboard:",
87
  default=True,)
88
 
89
- # --- Your Streamlit App ---
90
- st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
91
- st.subheader("Select specific Chapter for quicker results")
92
- st.logo(image="images/menu_book_60dp_75FBFD.png")
93
- st.sidebar.header("SBS V2.0 mapper")
94
- st.sidebar.write("(work in progress)")
95
- st.sidebar.text("Demo by JA-RAD")
96
-
97
  # --- NAVIGATION SETUP ---
98
  pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
99
  pg.run()
 
1
  import streamlit as st
2
 
3
+ # Alternative approach: Use Streamlit's native components with minimal CSS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ # First, let's hide the default header with minimal CSS
6
+ st.markdown("""
7
+ <style>
8
+ header {display: none !important;}
9
  </style>
10
+ """, unsafe_allow_html=True)
11
+
12
+ # Now create a completely custom header using Streamlit elements
13
 
14
+ # Create a container at the top of the app
15
+ header = st.container()
16
 
17
+ # Use the container for the header
18
+ with header:
19
+ # Apply background color with markdown
20
+ st.markdown(
21
+ """
22
+ <div style="
23
+ background-color: #90EE90;
24
+ padding: 10px;
25
+ margin-bottom: 10px;
26
+ border-bottom: 1px solid #ddd;
27
+ position: fixed;
28
+ top: 0;
29
+ left: 0;
30
+ right: 0;
31
+ z-index: 9999;
32
+ width: 100%;
33
+ ">
34
+ <div style="display: flex; align-items: center;">
35
+ <div style="flex: 0 0 60px;">
36
+ <img src="https://raw.githubusercontent.com/streamlit/streamlit/master/lib/streamlit/static/favicon.png" width="50"
37
+ alt="Logo" style="vertical-align: middle;">
38
+ </div>
39
+ <div style="flex-grow: 1;">
40
+ <h2 style="margin: 0; padding: 0;">Map descriptions to SBS codes with Sentence Transformer + Reasoning</h2>
41
+ <p style="margin: 0; padding: 0;">Select specific Chapter for quicker results</p>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ """,
46
+ unsafe_allow_html=True
47
+ )
48
 
49
+ # Add spacing to prevent content from being hidden under the fixed header
50
+ st.markdown(
51
+ """
52
+ <div style="height: 100px;"></div>
53
+ """,
54
+ unsafe_allow_html=True
55
+ )
56
 
57
+ # Rest of the app
58
+ # Sidebar content
59
  st.sidebar.header("SBS V2.0 mapper")
60
  st.sidebar.write("(work in progress)")
61
  st.sidebar.text("Demo by JA-RAD")
62
+ st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
63
+ st.subheader("Select specific Chapter for quicker results")
64
+ st.logo(image="images/menu_book_60dp_75FBFD.png")
65
 
66
+ # Page setup - moved after the custom header
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  type_text_page = st.Page(
68
  page="pages/type_text.py",
69
  title="DEMO (work in progress)",
70
  icon=":material/keyboard:",
71
  default=True,)
72
 
 
 
 
 
 
 
 
 
73
  # --- NAVIGATION SETUP ---
74
  pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
75
  pg.run()