georad commited on
Commit
a2e01d2
·
verified ·
1 Parent(s): 3a2e61d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -33
app.py CHANGED
@@ -1,66 +1,63 @@
1
  import streamlit as st
2
- # No need to import time if not simulating task here
3
 
4
  # --- Page Configuration ---
5
  # This sets the title and icon that appear in the default header
6
  st.set_page_config(
7
- page_title="SBS V2.0 mapper", # This title will appear in the fixed header
8
- page_icon=":material/keyboard:", # This icon can also appear in the header
 
9
  layout="wide" # Optional: Use wide layout
10
  )
11
 
12
- # --- Custom CSS for Fixed Default Header ---
13
  st.markdown("""
14
  <style>
15
- /* Make the default Streamlit header fixed at the top */
16
  header {
17
- position: fixed; /* Use fixed positioning for viewport-relative stickiness */
18
- top: 0; /* Position from the top edge */
19
- left: 0; /* Position from the left edge */
20
- width: 100%; /* Span the full width of the viewport */
21
- z-index: 100; /* Ensure the header is above other content */
22
- background-color: rgb(240, 242, 246); /* Match Streamlit's default header background color */
23
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Optional: Add a subtle shadow */
24
- /* You might need to adjust padding if the default header height changes */
25
  }
26
 
27
- /* Add padding to the main content area to prevent it from being hidden behind the fixed header */
28
- /* This targets the main container div below the header and sidebar */
29
- /* You might need to inspect the Streamlit app's HTML structure in your browser
30
- (using developer tools) to find the precise data-testid or class for this div
31
- if "stAppViewContainer" or "stVerticalBlock" doesn't work reliably,
32
- but stAppViewContainer is a common target. */
33
  [data-testid="stAppViewContainer"] {
34
- padding-top: 70px; /* Adjust this value to be slightly more than your header's height */
35
  }
36
 
37
- /* Also add padding to the sidebar content */
38
  [data-testid="stSidebar"] {
39
- padding-top: 70px; /* Use the same padding value as the main content */
40
  }
41
 
42
- /* If the layout is 'wide', adjust the padding on the main container */
43
- /* This helps keep content aligned if the header has internal padding/margins */
44
  .main .block-container {
45
- padding-top: 1rem; /* Or match default streamlit content padding */
46
  }
47
 
48
-
49
  </style>
50
  """, unsafe_allow_html=True)
51
 
52
- # --- App Content (will scroll below the fixed header) ---
53
 
54
- # The logo placed here will likely appear in the sidebar or main body,
55
- # not in the fixed default header. Use st.set_page_config for the header icon.
 
56
  st.logo(image="images/menu_book_60dp_75FBFD.png")
57
 
 
58
  st.sidebar.header("SBS V2.0 mapper")
59
  st.sidebar.write("(work in progress)")
60
  st.sidebar.text("Demo by JA-RAD")
61
 
62
- # Note: st.title and st.subheader here will appear *below* the fixed header,
63
- # as they are part of the main app content flow.
 
64
  st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
65
  st.subheader("Select specific Chapter for quicker results")
66
 
@@ -70,7 +67,7 @@ st.subheader("Select specific Chapter for quicker results")
70
  type_text_page = st.Page(
71
  page="pages/type_text.py",
72
  title="DEMO (work in progress)",
73
- icon=":material/keyboard:",
74
  default=True,
75
  )
76
 
@@ -78,5 +75,6 @@ pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
78
  pg.run()
79
 
80
  # Add some extra content to make the page scrollable for testing
81
- for i in range(100): # Increased lines to ensure sufficient scrolling
 
82
  st.write(f"This is scrollable content line {i}")
 
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 for Sticky Default Header ---
13
  st.markdown("""
14
  <style>
15
+ /* Make the default Streamlit header sticky */
16
  header {
17
+ position: sticky; /* Use sticky positioning */
18
+ top: 0px; /* Stick to the top edge */
19
+ z-index: 999; /* Ensure the header is always on top */
20
+ background-color: rgb(255, 255, 255); /* Use white background or match Streamlit's default header color */
21
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Add shadow for better visibility */
22
+ /* Adjust padding/height if needed, but default usually works well with sticky */
 
 
23
  }
24
 
25
+ /* Add padding to the main content area to prevent it from starting behind the sticky header */
26
+ /* This targets the main container div where your app content and pages are rendered */
27
+ /* The exact value might need slight adjustment based on the header's actual height */
 
 
 
28
  [data-testid="stAppViewContainer"] {
29
+ padding-top: 60px; /* Estimate header height (~60px). Adjust if needed. */
30
  }
31
 
32
+ /* Adjust padding for the sidebar content as well */
33
  [data-testid="stSidebar"] {
34
+ padding-top: 60px; /* Use the same padding value as the main content */
35
  }
36
 
37
+ /* Ensure the main content block within the container also has correct top padding */
38
+ /* This might be necessary for correct spacing below the header */
39
  .main .block-container {
40
+ padding-top: 1rem; /* Keep or adjust default Streamlit content padding */
41
  }
42
 
 
43
  </style>
44
  """, unsafe_allow_html=True)
45
 
46
+ # --- App Content (will scroll below the sticky header) ---
47
 
48
+ # The st.logo call here will place the logo in the sidebar or main body,
49
+ # not in the sticky default header. If you want a logo in the header,
50
+ # use the page_icon parameter in st.set_page_config above.
51
  st.logo(image="images/menu_book_60dp_75FBFD.png")
52
 
53
+
54
  st.sidebar.header("SBS V2.0 mapper")
55
  st.sidebar.write("(work in progress)")
56
  st.sidebar.text("Demo by JA-RAD")
57
 
58
+ # Note: st.title and st.subheader here will appear *below* the sticky header,
59
+ # as they are part of the main app content flow. The title in the sticky header
60
+ # comes from st.set_page_config.
61
  st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
62
  st.subheader("Select specific Chapter for quicker results")
63
 
 
67
  type_text_page = st.Page(
68
  page="pages/type_text.py",
69
  title="DEMO (work in progress)",
70
+ icon=":material/keyboard:", # This icon can appear in the tab/bookmark
71
  default=True,
72
  )
73
 
 
75
  pg.run()
76
 
77
  # Add some extra content to make the page scrollable for testing
78
+ # Remove this loop in your final application if you have enough content already
79
+ for i in range(100):
80
  st.write(f"This is scrollable content line {i}")