James McCool commited on
Commit
ffa571c
Β·
1 Parent(s): b858a5a

Refactor salary display logic in app.py by removing JavaScript dependency for screen width and simplifying column layout. This change enhances the user experience by ensuring consistent presentation of salary information across all devices.

Browse files
Files changed (1) hide show
  1. app.py +17 -39
app.py CHANGED
@@ -4,15 +4,9 @@ import pandas as pd
4
  import gspread
5
  import pymongo
6
  import re
7
- from streamlit_javascript import st_javascript
8
 
9
  st.set_page_config(layout="wide")
10
 
11
- screen_width = st_javascript("window.innerWidth")
12
- # Default to desktop if JS fails
13
- if screen_width is None:
14
- screen_width = 1200
15
-
16
  @st.cache_resource
17
  def init_conn():
18
  uri = st.secrets['mongo_uri']
@@ -1034,39 +1028,23 @@ with tab4:
1034
  })
1035
  summary_row = summary_row[['Salary', 'Median', 'Own%']].head(10)
1036
 
1037
- col1, col2, col3 = st.columns([2, 1, 3])
1038
- if screen_width < 700:
1039
- with col1:
1040
- if (10 - len(filled_lineup)) > 0:
1041
- st.markdown(f"""
1042
- <div style='text-align: right; vertical-align: top; margin-top: 0; padding-top: 0;''>
1043
- <b>πŸ’° Per Player:</b> ${round((50000 - total_salary) / (10 - len(filled_lineup)), 0)} &nbsp;
1044
- </div>
1045
- """,
1046
- unsafe_allow_html=True)
1047
- else:
1048
- st.markdown(f"""
1049
- <div style='text-align: right; vertical-align: top; margin-top: 0; padding-top: 0;''>
1050
- <b>πŸ’° Leftover:</b> ${round(50000 - total_salary, 0)} &nbsp;
1051
- </div>
1052
- """,
1053
- unsafe_allow_html=True)
1054
- else:
1055
- with col1:
1056
- if (10 - len(filled_lineup)) > 0:
1057
- st.markdown(f"""
1058
- <div style='text-align: left; vertical-align: top; margin-top: 0; padding-top: 0;''>
1059
- <b>πŸ’° Per Player:</b> ${round((50000 - total_salary) / (10 - len(filled_lineup)), 0)} &nbsp;
1060
- </div>
1061
- """,
1062
- unsafe_allow_html=True)
1063
- else:
1064
- st.markdown(f"""
1065
- <div style='text-align: left; vertical-align: top; margin-top: 0; padding-top: 0;''>
1066
- <b>πŸ’° Leftover:</b> ${round(50000 - total_salary, 0)} &nbsp;
1067
- </div>
1068
- """,
1069
- unsafe_allow_html=True)
1070
 
1071
  with col3:
1072
  if total_salary <= 50000:
 
4
  import gspread
5
  import pymongo
6
  import re
 
7
 
8
  st.set_page_config(layout="wide")
9
 
 
 
 
 
 
10
  @st.cache_resource
11
  def init_conn():
12
  uri = st.secrets['mongo_uri']
 
1028
  })
1029
  summary_row = summary_row[['Salary', 'Median', 'Own%']].head(10)
1030
 
1031
+ col1, col3 = st.columns([2, 3])
1032
+
1033
+ with col1:
1034
+ if (10 - len(filled_lineup)) > 0:
1035
+ st.markdown(f"""
1036
+ <div style='text-align: left; vertical-align: top; margin-top: 0; padding-top: 0;''>
1037
+ <b>πŸ’° Per Player:</b> ${round((50000 - total_salary) / (10 - len(filled_lineup)), 0)} &nbsp;
1038
+ </div>
1039
+ """,
1040
+ unsafe_allow_html=True)
1041
+ else:
1042
+ st.markdown(f"""
1043
+ <div style='text-align: left; vertical-align: top; margin-top: 0; padding-top: 0;''>
1044
+ <b>πŸ’° Leftover:</b> ${round(50000 - total_salary, 0)} &nbsp;
1045
+ </div>
1046
+ """,
1047
+ unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1048
 
1049
  with col3:
1050
  if total_salary <= 50000: