BenjiELCA commited on
Commit
d6aec26
1 Parent(s): b999af1

dark mode friendly

Browse files
Files changed (2) hide show
  1. app.py +5 -3
  2. modules/streamlit_utils.py +18 -2
app.py CHANGED
@@ -42,9 +42,11 @@ def main():
42
  return
43
 
44
  with prediction_result_placeholder.container():
45
- #with st.expander("Show result of prediction"):
46
- #with st.spinner('Waiting for result display...'):
47
- display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6*screen_width))
 
 
48
 
49
  if not is_mobile:
50
  with additional_options_placeholder.container():
 
42
  return
43
 
44
  with prediction_result_placeholder.container():
45
+ if is_mobile:
46
+ display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6*screen_width))
47
+ else:
48
+ with st.expander("Show result of prediction"):
49
+ display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6*screen_width))
50
 
51
  if not is_mobile:
52
  with additional_options_placeholder.container():
modules/streamlit_utils.py CHANGED
@@ -187,11 +187,27 @@ def configure_page():
187
  is_mobile = screen_width is not None and screen_width < 800
188
  return is_mobile, screen_width
189
 
 
 
190
  def display_banner(is_mobile):
 
 
 
 
 
 
 
 
191
  if is_mobile:
192
- st.image("./images/banner_mobile.png", use_column_width=True)
 
 
 
193
  else:
194
- st.image("./images/banner_desktop.png", use_column_width=True)
 
 
 
195
 
196
  def display_title(is_mobile):
197
  title = "Welcome on the BPMN AI model recognition app"
 
187
  is_mobile = screen_width is not None and screen_width < 800
188
  return is_mobile, screen_width
189
 
190
+ from streamlit_js_eval import streamlit_js_eval
191
+
192
  def display_banner(is_mobile):
193
+ # JavaScript expression to detect dark mode
194
+ dark_mode_js = """
195
+ (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)
196
+ """
197
+
198
+ # Evaluate JavaScript in Streamlit to check for dark mode
199
+ is_dark_mode = streamlit_js_eval(js_expressions=dark_mode_js, key='dark_mode')
200
+
201
  if is_mobile:
202
+ if is_dark_mode:
203
+ st.image("./images/banner_mobile_dark.png", use_column_width=True)
204
+ else:
205
+ st.image("./images/banner_mobile.png", use_column_width=True)
206
  else:
207
+ if is_dark_mode:
208
+ st.image("./images/banner_desktop_dark.png", use_column_width=True)
209
+ else:
210
+ st.image("./images/banner_desktop.png", use_column_width=True)
211
 
212
  def display_title(is_mobile):
213
  title = "Welcome on the BPMN AI model recognition app"