georad commited on
Commit
76ed696
·
verified ·
1 Parent(s): 4f827fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -30
app.py CHANGED
@@ -1,45 +1,46 @@
1
  import streamlit as st
2
 
3
  # --- Page Configuration ---
4
- # This sets the title and icon that appear in the default header
5
  st.set_page_config(
6
- page_title="SBS V2.0 mapper", # This title will appear in the sticky header
7
- # Use the logo image here if you want it in the header (optional)
8
- # page_icon="images/menu_book_60dp_75FBFD.png",
9
- layout="wide" # Optional: Use wide layout
10
  )
11
 
12
- # --- Custom CSS to Fix Parent Overflow and Make Header Sticky ---
13
  st.markdown("""
14
  <style>
15
  /* Target the main app container and ensure its overflow is visible */
16
- /* This is crucial for sticky positioning of elements inside it relative to the viewport */
17
  [data-testid="stApp"] {
18
  overflow: visible !important; /* Force overflow to be visible */
19
  }
20
 
21
- /* Target the default Streamlit header element */
22
- /* This is typically the <header> tag containing the title, menu, and status */
23
- header {
24
- position: sticky !important; /* Force sticky positioning */
25
- top: 0px !important; /* Force sticking to the top edge */
26
- z-index: 999 !important; /* Force a high z-index */
27
- background-color: rgb(255, 255, 255) !important; /* Force background color (white or match Streamlit's default) */
28
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Add shadow */
29
- height: auto !important; /* Force height to adjust */
30
- /* overflow: visible !important; /* This might also be needed on the header itself */
31
  }
32
 
33
- /* Add padding to the main content area to prevent it from starting behind the sticky header */
34
- /* This targets the main container div where your app content and pages are rendered */
35
- /* Adjust this value based on the header's actual height after inspecting the deployed app */
36
  [data-testid="stAppViewContainer"] {
37
- padding-top: 60px; /* Estimate header height (~60px). Adjust if needed. */
38
  }
39
 
40
  /* Adjust padding for the sidebar content as well */
 
41
  [data-testid="stSidebar"] {
42
- padding-top: 60px; /* Use the same padding value as the main content */
 
43
  }
44
 
45
  /* Ensure the main content block within the container also has correct top padding */
@@ -47,14 +48,14 @@ st.markdown("""
47
  padding-top: 1rem; /* Keep or adjust default Streamlit content padding */
48
  }
49
 
 
50
  </style>
51
  """, unsafe_allow_html=True)
52
 
53
- # --- App Content (will scroll below the sticky header) ---
54
 
55
  # The st.logo call here will place the logo in the sidebar or main body,
56
- # not in the sticky default header. If you want a logo in the header,
57
- # use the page_icon parameter in st.set_page_config above.
58
  st.logo(image="images/menu_book_60dp_75FBFD.png")
59
 
60
 
@@ -62,11 +63,10 @@ st.sidebar.header("SBS V2.0 mapper")
62
  st.sidebar.write("(work in progress)")
63
  st.sidebar.text("Demo by JA-RAD")
64
 
65
- # Note: st.title and st.subheader here will appear *below* the sticky header,
66
- # as they are part of the main app content flow. The title in the sticky header
67
- # comes from st.set_page_config.
68
- st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
69
- st.subheader("Select specific Chapter for quicker results")
70
 
71
 
72
  # --- NAVIGATION SETUP ---
 
1
  import streamlit as st
2
 
3
  # --- Page Configuration ---
4
+ # This still configures the topmost header bar (which won't be sticky)
5
  st.set_page_config(
6
+ page_title="SBS V2.0 mapper", # This title appears in the topmost bar
7
+ # page_icon="images/menu_book_60dp_75FBFD.png", # Icon for the topmost bar
8
+ #layout="wide" # Optional: Use wide layout
 
9
  )
10
 
11
+ # --- Custom CSS to Fix Parent Overflow and Make the Toolbar/Status Bar Sticky ---
12
  st.markdown("""
13
  <style>
14
  /* Target the main app container and ensure its overflow is visible */
15
+ /* This is crucial for sticky positioning relative to the viewport */
16
  [data-testid="stApp"] {
17
  overflow: visible !important; /* Force overflow to be visible */
18
  }
19
 
20
+ /* Target the container element that holds the Toolbar (stToolbar) and Status Widget (stStatusWidget) */
21
+ /* Based on the likely Streamlit DOM structure, this is typically the second direct child div within stAppViewContainer */
22
+ [data-testid="stAppViewContainer"] > div:nth-child(2) {
23
+ position: sticky !important; /* Make this specific bar sticky */
24
+ top: 0px !important; /* Stick to the top edge of the viewport */
25
+ z-index: 999 !important; /* Ensure it's always on top */
26
+ background-color: rgb(255, 255, 255) !important; /* Background for the sticky bar */
27
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Add shadow */
28
+ /* height: auto !important; */ /* Usually not needed here */
29
+ /* overflow: visible !important; */ /* Usually not needed here */
30
  }
31
 
32
+ /* Add padding to the main content area to prevent it from starting behind the sticky Toolbar/Status bar */
33
+ /* Adjust this value to be slightly more than the height of the Toolbar/Status bar (the sticky element) */
34
+ /* You will likely need to inspect the deployed app to find the exact height of this bar */
35
  [data-testid="stAppViewContainer"] {
36
+ padding-top: 50px; /* Estimate height of the second bar (~50px). Adjust after inspection. */
37
  }
38
 
39
  /* Adjust padding for the sidebar content as well */
40
+ /* This needs to account for the height of both the topmost bar AND the sticky second bar */
41
  [data-testid="stSidebar"] {
42
+ /* Estimate height of topmost bar (~40px) + height of sticky bar (~50px) + default sidebar padding (~1rem) */
43
+ padding-top: calc(40px + 50px + 1rem); /* Adjust pixel values after inspection */
44
  }
45
 
46
  /* Ensure the main content block within the container also has correct top padding */
 
48
  padding-top: 1rem; /* Keep or adjust default Streamlit content padding */
49
  }
50
 
51
+
52
  </style>
53
  """, unsafe_allow_html=True)
54
 
55
+ # --- App Content (will scroll below the sticky SECOND bar) ---
56
 
57
  # The st.logo call here will place the logo in the sidebar or main body,
58
+ # not in either of the top bars.
 
59
  st.logo(image="images/menu_book_60dp_75FBFD.png")
60
 
61
 
 
63
  st.sidebar.write("(work in progress)")
64
  st.sidebar.text("Demo by JA-RAD")
65
 
66
+ # Note: st.title and st.subheader here will appear *below* the sticky second bar,
67
+ # as they are part of the main app content flow.
68
+ st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning") # This title scrolls
69
+ st.subheader("Select specific Chapter for quicker results") # This subheader scrolls
 
70
 
71
 
72
  # --- NAVIGATION SETUP ---