Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
41a4343
1
Parent(s):
c238587
Enhance UI with custom tab styling and replace tab implementation with a segmented control for better user experience.
Browse files- src/streamlit_app.py +48 -3
src/streamlit_app.py
CHANGED
|
@@ -12,6 +12,43 @@ from database import init_conn
|
|
| 12 |
|
| 13 |
gcservice_account, gcservice_account2, NHL_Data = init_conn()
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
@st.cache_resource(ttl = 600)
|
| 16 |
def init_baselines():
|
| 17 |
sh = gcservice_account.open_by_url(NHL_Data)
|
|
@@ -161,9 +198,17 @@ indv_players = gamelog_table.drop_duplicates(subset='Player')
|
|
| 161 |
total_players = indv_players.Player.values.tolist()
|
| 162 |
total_dates = gamelog_table.Date.values.tolist()
|
| 163 |
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
-
|
| 167 |
col1, col2 = st.columns([1, 9])
|
| 168 |
with col1:
|
| 169 |
if st.button("Reset Data", key='reset1'):
|
|
@@ -282,7 +327,7 @@ with tab1:
|
|
| 282 |
mime='text/csv',
|
| 283 |
)
|
| 284 |
|
| 285 |
-
|
| 286 |
col1, col2 = st.columns([1, 9])
|
| 287 |
with col1:
|
| 288 |
if st.button("Reset Data", key='reset2'):
|
|
|
|
| 12 |
|
| 13 |
gcservice_account, gcservice_account2, NHL_Data = init_conn()
|
| 14 |
|
| 15 |
+
st.markdown("""
|
| 16 |
+
<style>
|
| 17 |
+
/* Tab styling */
|
| 18 |
+
.stElementContainer [data-baseweb="button-group"] {
|
| 19 |
+
gap: 2.000rem;
|
| 20 |
+
padding: 4px;
|
| 21 |
+
}
|
| 22 |
+
.stElementContainer [kind="segmented_control"] {
|
| 23 |
+
height: 2.000rem;
|
| 24 |
+
white-space: pre-wrap;
|
| 25 |
+
background-color: #DAA520;
|
| 26 |
+
color: white;
|
| 27 |
+
border-radius: 20px;
|
| 28 |
+
gap: 1px;
|
| 29 |
+
padding: 10px 20px;
|
| 30 |
+
font-weight: bold;
|
| 31 |
+
transition: all 0.3s ease;
|
| 32 |
+
}
|
| 33 |
+
.stElementContainer [kind="segmented_controlActive"] {
|
| 34 |
+
height: 3.000rem;
|
| 35 |
+
background-color: #DAA520;
|
| 36 |
+
border: 3px solid #FFD700;
|
| 37 |
+
border-radius: 10px;
|
| 38 |
+
color: black;
|
| 39 |
+
}
|
| 40 |
+
.stElementContainer [kind="segmented_control"]:hover {
|
| 41 |
+
background-color: #FFD700;
|
| 42 |
+
cursor: pointer;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
div[data-baseweb="select"] > div {
|
| 46 |
+
background-color: #DAA520;
|
| 47 |
+
color: white;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
</style>""", unsafe_allow_html=True)
|
| 51 |
+
|
| 52 |
@st.cache_resource(ttl = 600)
|
| 53 |
def init_baselines():
|
| 54 |
sh = gcservice_account.open_by_url(NHL_Data)
|
|
|
|
| 198 |
total_players = indv_players.Player.values.tolist()
|
| 199 |
total_dates = gamelog_table.Date.values.tolist()
|
| 200 |
|
| 201 |
+
selected_tab = st.segmented_control(
|
| 202 |
+
"Select Tab",
|
| 203 |
+
options=['Gamelogs', 'Correlation Matrix'],
|
| 204 |
+
selection_mode='single',
|
| 205 |
+
default='Gamelogs',
|
| 206 |
+
width='stretch',
|
| 207 |
+
label_visibility='collapsed',
|
| 208 |
+
key='tab_selector'
|
| 209 |
+
)
|
| 210 |
|
| 211 |
+
if selected_tab == 'Gamelogs':
|
| 212 |
col1, col2 = st.columns([1, 9])
|
| 213 |
with col1:
|
| 214 |
if st.button("Reset Data", key='reset1'):
|
|
|
|
| 327 |
mime='text/csv',
|
| 328 |
)
|
| 329 |
|
| 330 |
+
elif selected_tab == 'Correlation Matrix':
|
| 331 |
col1, col2 = st.columns([1, 9])
|
| 332 |
with col1:
|
| 333 |
if st.button("Reset Data", key='reset2'):
|