Spaces:
Running
Running
James McCool
commited on
Commit
·
f77a585
1
Parent(s):
74d3eb1
Implement responsive column layout in app.py based on screen width to enhance user experience on mobile devices. Default to desktop layout if JavaScript fails to retrieve screen width.
Browse files
app.py
CHANGED
@@ -4,9 +4,15 @@ import pandas as pd
|
|
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,7 +1034,12 @@ with tab4:
|
|
1028 |
})
|
1029 |
summary_row = summary_row[['Salary', 'Median', 'Own%']].head(10)
|
1030 |
|
1031 |
-
|
|
|
|
|
|
|
|
|
|
|
1032 |
with col1:
|
1033 |
if (10 - len(filled_lineup)) > 0:
|
1034 |
st.markdown(f"""
|
|
|
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 |
})
|
1035 |
summary_row = summary_row[['Salary', 'Median', 'Own%']].head(10)
|
1036 |
|
1037 |
+
if screen_width < 700:
|
1038 |
+
# Mobile: Only two columns
|
1039 |
+
col1, col3 = st.columns([2, 3])
|
1040 |
+
col2 = None
|
1041 |
+
else:
|
1042 |
+
col1, col2, col3 = st.columns([2, 1, 3])
|
1043 |
with col1:
|
1044 |
if (10 - len(filled_lineup)) > 0:
|
1045 |
st.markdown(f"""
|