georad commited on
Commit
c674483
·
verified ·
1 Parent(s): 6341465

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -60
app.py CHANGED
@@ -1,14 +1,13 @@
1
  import streamlit as st
2
 
3
  # At the top of your existing file with your imports
4
-
5
  def add_sticky_header_css():
6
  st.markdown("""
7
  <style>
8
  /* Make Streamlit's toolbar sticky */
9
  [data-testid="stToolbar"] {
10
  position: fixed;
11
- top: 0;
12
  right: 0;
13
  z-index: 1000;
14
  width: 100%;
@@ -21,7 +20,7 @@ def add_sticky_header_css():
21
  bottom: 0;
22
  right: 0;
23
  z-index: 1000;
24
- background-color: white;
25
  padding: 5px;
26
  border-top: 1px solid #f0f0f0;
27
  width: 100%;
@@ -40,61 +39,6 @@ add_sticky_header_css()
40
 
41
  # Rest of your existing app continues...
42
 
43
- # Inspect the header element, go to the "Computed" tab in styles, and find its height.
44
- #HEADER_HEIGHT = "60px" # EXAMPLE: Adjust this (e.g., "56px", "4rem")
45
- #HEADER_SELECTOR = 'header[data-testid="stHeader"]'
46
-
47
- # ---- SELECTOR FOR THE MAIN CONTENT AREA THAT NEEDS PADDING ----
48
- # Target the first direct div child of the stAppViewContainer which often holds the main scrollable content
49
- #MAIN_CONTENT_SELECTOR = 'section[data-testid="stMain"]'
50
- #MAIN_CONTENT_SELECTOR = 'section[data-testid="stMain"] > div:nth-child(1)'
51
- #MAIN_CONTENT_SELECTOR = 'section[data-testid="stMainBlockContainer"]'
52
- #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"]'
53
- #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"] > div:nth-child(1)'
54
- # Alternative if the above doesn't work or if your content is further nested:
55
- #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"] .main-content-wrapper-class'
56
- # Or, very commonly, Streamlit wraps main content in a div with class "block-container":
57
- #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"] .block-container'
58
- #MAIN_CONTENT_SELECTOR = '.main .block-container' # A more general selector for block-container
59
- '''
60
- custom_css = f"""
61
- <style>
62
- /* Making the Streamlit header sticky */
63
- {HEADER_SELECTOR} {{
64
- position: -webkit-sticky !important; /* For Safari */
65
- position: sticky !important;
66
- top: 0 !important;
67
- z-index: 9999 !important; /* Very high z-index */
68
- background-color: #90EE90 !important; /* Or your app's header background color */
69
- /* Add a subtle shadow to make it feel more distinct when content scrolls under */
70
- /* box-shadow: 0 2px 4px -1px rgba(0,0,0,0.1); */
71
- /*.reportview-container .main .block-container{{ */
72
- /* padding-top: 0rem; */
73
- /* }} */
74
- }}
75
-
76
- /* Adding padding to the main content area to prevent overlap with the sticky header */
77
- {MAIN_CONTENT_SELECTOR} {{
78
- padding-top: 10px !important; /* {HEADER_HEIGHT} !important; */
79
- /* background-color: yellow !important; */
80
- /* border-style: solid !important; */
81
- /* border-color: red !important; */
82
- }}
83
-
84
- /* Optional: If your app is set to wide mode and the header isn't spanning full width */
85
- /* This might be needed if the sticky positioning affects its width calculation. */
86
- /*
87
- #{HEADER_SELECTOR} {{
88
- # width: 100% !important;
89
- #}}
90
- #*/
91
- </style>
92
- """
93
- '''
94
-
95
- # Inject CSS as early as possible in your app
96
- #st.markdown(custom_css, unsafe_allow_html=True)
97
-
98
  # --- PAGE SETUP ---
99
  type_text_page = st.Page(
100
  page="pages/type_text.py",
@@ -102,7 +46,6 @@ type_text_page = st.Page(
102
  icon=":material/keyboard:",
103
  default=True,)
104
 
105
-
106
  # --- Your Streamlit App ---
107
  #st.logo(image="images/menu_book_60dp_75FBFD.png")
108
  st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
@@ -113,7 +56,6 @@ st.sidebar.write("(work in progress)")
113
  st.sidebar.text("Demo by JA-RAD")
114
 
115
 
116
-
117
  # --- NAVIGATION SETUP ---
118
  pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
119
  ##pg = st.navigation({"Chapter_Index": [start_page], "Demo": [type_text_page, upload_file_page], "About": [about_page]}) # WITH SECTIONS
 
1
  import streamlit as st
2
 
3
  # At the top of your existing file with your imports
 
4
  def add_sticky_header_css():
5
  st.markdown("""
6
  <style>
7
  /* Make Streamlit's toolbar sticky */
8
  [data-testid="stToolbar"] {
9
  position: fixed;
10
+ bottom: 0;
11
  right: 0;
12
  z-index: 1000;
13
  width: 100%;
 
20
  bottom: 0;
21
  right: 0;
22
  z-index: 1000;
23
+ background-color: #90EE90;
24
  padding: 5px;
25
  border-top: 1px solid #f0f0f0;
26
  width: 100%;
 
39
 
40
  # Rest of your existing app continues...
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  # --- PAGE SETUP ---
43
  type_text_page = st.Page(
44
  page="pages/type_text.py",
 
46
  icon=":material/keyboard:",
47
  default=True,)
48
 
 
49
  # --- Your Streamlit App ---
50
  #st.logo(image="images/menu_book_60dp_75FBFD.png")
51
  st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
 
56
  st.sidebar.text("Demo by JA-RAD")
57
 
58
 
 
59
  # --- NAVIGATION SETUP ---
60
  pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
61
  ##pg = st.navigation({"Chapter_Index": [start_page], "Demo": [type_text_page, upload_file_page], "About": [about_page]}) # WITH SECTIONS