James McCool commited on
Commit
39f346a
·
1 Parent(s): f962e85

Refactor Streamlit app layout for improved organization and styling

Browse files

- Replaced expander components with container components in pitcher, hitter, and team tabs for better layout control.
- Updated the caching mechanism for resource initialization to remove the TTL parameter.
- Commented out the previous tab styling to maintain code clarity while preserving the option for future use.

Files changed (1) hide show
  1. src/streamlit_app.py +40 -40
src/streamlit_app.py CHANGED
@@ -16,43 +16,43 @@ def init_conn():
16
 
17
  db = init_conn()
18
 
19
- st.markdown("""
20
- <style>
21
- /* Tab styling */
22
- .stTabs [data-baseweb="tab-list"] {
23
- gap: 8px;
24
- padding: 4px;
25
- }
26
- .stTabs [data-baseweb="tab"] {
27
- height: 50px;
28
- white-space: pre-wrap;
29
- background-color: #DAA520;
30
- color: white;
31
- border-radius: 10px;
32
- gap: 1px;
33
- padding: 10px 20px;
34
- font-weight: bold;
35
- transition: all 0.3s ease;
36
- }
37
- .stTabs [aria-selected="true"] {
38
- background-color: #DAA520;
39
- border: 3px solid #FFD700;
40
- color: white;
41
- }
42
- .stTabs [data-baseweb="tab"]:hover {
43
- background-color: #FFD700;
44
- cursor: pointer;
45
- }
46
- div[data-baseweb="select"] > div {
47
- background-color: #DAA520;
48
- color: white;
49
- }
50
- div{
51
- box-sizing: content-box !important;
52
- }
53
- </style>""", unsafe_allow_html=True)
54
-
55
- @st.cache_resource(ttl = 61)
56
  def init_baselines():
57
 
58
  db_pulls = ['Bullpen_Data', 'Hitter_Agg_Merge', 'Hitter_Long_Merge', 'Hitter_Short_Merge', 'Pitcher_Agg_Merge', 'Pitcher_Long_Merge', 'Pitcher_Short_Merge',
@@ -97,7 +97,7 @@ bp_data, hitter_agg, hitter_long, hitter_short, pitcher_agg, pitcher_long, pitch
97
  pitcher_tab, hitter_tab, team_tab = st.tabs(['Pitchers', 'Hitters', 'Team'])
98
 
99
  with pitcher_tab:
100
- with st.expander('Info and Display Options'):
101
  st.info('Note: Splits options are available for all baseline tables, they do not apply to True AVG, HWSr, or the Overview tables')
102
  col1, col2, col3 = st.columns(3)
103
  with col1:
@@ -149,7 +149,7 @@ with pitcher_tab:
149
  st.dataframe(st.session_state['sp_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn_r').format(precision=2), use_container_width = True, hide_index = True)
150
 
151
  with hitter_tab:
152
- with st.expander('Info and Display Options'):
153
  st.info('Note: Splits options are available for all baseline tables')
154
  col1, col2, col3 = st.columns(3)
155
  with col1:
@@ -177,7 +177,7 @@ with hitter_tab:
177
  st.dataframe(st.session_state['hitter_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True, hide_index = True)
178
 
179
  with team_tab:
180
- with st.expander('Info and Display Options'):
181
  col1, col2, col3 = st.columns(3)
182
  with col1:
183
  site_var_team= st.selectbox('Site', ['DraftKings', 'FanDuel'], key = 'site_var_team')
 
16
 
17
  db = init_conn()
18
 
19
+ # st.markdown("""
20
+ # <style>
21
+ # /* Tab styling */
22
+ # .stTabs [data-baseweb="tab-list"] {
23
+ # gap: 8px;
24
+ # padding: 4px;
25
+ # }
26
+ # .stTabs [data-baseweb="tab"] {
27
+ # height: 50px;
28
+ # white-space: pre-wrap;
29
+ # background-color: #DAA520;
30
+ # color: white;
31
+ # border-radius: 10px;
32
+ # gap: 1px;
33
+ # padding: 10px 20px;
34
+ # font-weight: bold;
35
+ # transition: all 0.3s ease;
36
+ # }
37
+ # .stTabs [aria-selected="true"] {
38
+ # background-color: #DAA520;
39
+ # border: 3px solid #FFD700;
40
+ # color: white;
41
+ # }
42
+ # .stTabs [data-baseweb="tab"]:hover {
43
+ # background-color: #FFD700;
44
+ # cursor: pointer;
45
+ # }
46
+ # div[data-baseweb="select"] > div {
47
+ # background-color: #DAA520;
48
+ # color: white;
49
+ # }
50
+ # div{
51
+ # box-sizing: content-box !important;
52
+ # }
53
+ # </style>""", unsafe_allow_html=True)
54
+
55
+ @st.cache_resource()
56
  def init_baselines():
57
 
58
  db_pulls = ['Bullpen_Data', 'Hitter_Agg_Merge', 'Hitter_Long_Merge', 'Hitter_Short_Merge', 'Pitcher_Agg_Merge', 'Pitcher_Long_Merge', 'Pitcher_Short_Merge',
 
97
  pitcher_tab, hitter_tab, team_tab = st.tabs(['Pitchers', 'Hitters', 'Team'])
98
 
99
  with pitcher_tab:
100
+ with st.container(border = True):
101
  st.info('Note: Splits options are available for all baseline tables, they do not apply to True AVG, HWSr, or the Overview tables')
102
  col1, col2, col3 = st.columns(3)
103
  with col1:
 
149
  st.dataframe(st.session_state['sp_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn_r').format(precision=2), use_container_width = True, hide_index = True)
150
 
151
  with hitter_tab:
152
+ with st.container(border = True):
153
  st.info('Note: Splits options are available for all baseline tables')
154
  col1, col2, col3 = st.columns(3)
155
  with col1:
 
177
  st.dataframe(st.session_state['hitter_disp_frame'].style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True, hide_index = True)
178
 
179
  with team_tab:
180
+ with st.container(border = True):
181
  col1, col2, col3 = st.columns(3)
182
  with col1:
183
  site_var_team= st.selectbox('Site', ['DraftKings', 'FanDuel'], key = 'site_var_team')