bgamazay commited on
Commit
b309e2b
Β·
verified Β·
1 Parent(s): 0c78a30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -30
app.py CHANGED
@@ -128,23 +128,8 @@ def unarchive(df_idx):
128
 
129
  st.set_page_config(page_title="French Flashcards", page_icon="πŸ‡«πŸ‡·", layout="centered")
130
 
131
- # UPDATED CSS FOR FULL-WIDTH BUTTONS
132
  st.markdown("""
133
  <style>
134
- /* Force the button container to fill width */
135
- .stButton {
136
- width: 100%;
137
- }
138
- /* Force the actual button to fill the container */
139
- .stButton > button {
140
- width: 100% !important;
141
- border-radius: 12px;
142
- height: 3.5em;
143
- font-size: 18px;
144
- margin-top: 8px; /* Add spacing between stacked buttons */
145
- margin-bottom: 8px;
146
- }
147
-
148
  /* Card Styling */
149
  .card-container {
150
  padding: 40px;
@@ -173,9 +158,10 @@ if st.session_state['page'] == 'home':
173
  st.title("πŸ‡«πŸ‡· French Practice")
174
  st.write(f"Total Cards: {len(st.session_state['df'])}")
175
 
176
- st.button("Start Session", on_click=start_session, type="primary")
177
- st.button("Add Card", on_click=lambda: set_page('add'))
178
- st.button("View Archive", on_click=lambda: set_page('archive'))
 
179
 
180
  elif st.session_state['page'] == 'add':
181
  st.title("Add New Card")
@@ -183,15 +169,15 @@ elif st.session_state['page'] == 'add':
183
  fr = st.text_input("French Word/Phrase")
184
  ctx = st.text_area("Context / Sentence")
185
  en = st.text_input("English Translation")
186
- submitted = st.form_submit_button("Save Card")
187
  if submitted and fr and en:
188
  add_card(fr, ctx, en)
189
 
190
- st.button("Back", on_click=lambda: set_page('home'))
191
 
192
  elif st.session_state['page'] == 'archive':
193
  st.title("Archive")
194
- st.button("Back", on_click=lambda: set_page('home'))
195
 
196
  df = st.session_state['df']
197
  if not df.empty:
@@ -202,7 +188,7 @@ elif st.session_state['page'] == 'archive':
202
  else:
203
  for idx, row in archived.iterrows():
204
  st.markdown(f"**{row['french']}** β€” *{row['english']}*")
205
- st.button("Unarchive", key=f"unarc_{idx}", on_click=unarchive, args=(idx,))
206
  st.divider()
207
  else:
208
  st.write("No cards yet.")
@@ -234,17 +220,16 @@ elif st.session_state['page'] == 'play':
234
  </div>
235
  """, unsafe_allow_html=True)
236
 
237
- # --- FIXED: Removed Columns so buttons stack and fill width ---
238
-
239
  def cycle_side():
240
  st.session_state['side_cycle_count'] += 1
241
- st.button("Flip / Next Side", on_click=cycle_side, type="primary")
242
-
243
- st.button("Next Card", on_click=next_card)
244
-
245
  st.divider()
246
- st.button("Archive this Card", on_click=archive_current_card)
247
- st.button("Quit Session", on_click=lambda: set_page('home'))
248
 
249
  else:
250
  set_page('home')
 
128
 
129
  st.set_page_config(page_title="French Flashcards", page_icon="πŸ‡«πŸ‡·", layout="centered")
130
 
 
131
  st.markdown("""
132
  <style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  /* Card Styling */
134
  .card-container {
135
  padding: 40px;
 
158
  st.title("πŸ‡«πŸ‡· French Practice")
159
  st.write(f"Total Cards: {len(st.session_state['df'])}")
160
 
161
+ # NATIVE FULL WIDTH BUTTONS
162
+ st.button("Start Session", on_click=start_session, type="primary", use_container_width=True)
163
+ st.button("Add Card", on_click=lambda: set_page('add'), use_container_width=True)
164
+ st.button("View Archive", on_click=lambda: set_page('archive'), use_container_width=True)
165
 
166
  elif st.session_state['page'] == 'add':
167
  st.title("Add New Card")
 
169
  fr = st.text_input("French Word/Phrase")
170
  ctx = st.text_area("Context / Sentence")
171
  en = st.text_input("English Translation")
172
+ submitted = st.form_submit_button("Save Card", use_container_width=True)
173
  if submitted and fr and en:
174
  add_card(fr, ctx, en)
175
 
176
+ st.button("Back", on_click=lambda: set_page('home'), use_container_width=True)
177
 
178
  elif st.session_state['page'] == 'archive':
179
  st.title("Archive")
180
+ st.button("Back", on_click=lambda: set_page('home'), use_container_width=True)
181
 
182
  df = st.session_state['df']
183
  if not df.empty:
 
188
  else:
189
  for idx, row in archived.iterrows():
190
  st.markdown(f"**{row['french']}** β€” *{row['english']}*")
191
+ st.button("Unarchive", key=f"unarc_{idx}", on_click=unarchive, args=(idx,), use_container_width=True)
192
  st.divider()
193
  else:
194
  st.write("No cards yet.")
 
220
  </div>
221
  """, unsafe_allow_html=True)
222
 
223
+ # ACTIONS
 
224
  def cycle_side():
225
  st.session_state['side_cycle_count'] += 1
226
+
227
+ st.button("Flip / Next Side", on_click=cycle_side, type="primary", use_container_width=True)
228
+ st.button("Next Card", on_click=next_card, use_container_width=True)
229
+
230
  st.divider()
231
+ st.button("Archive this Card", on_click=archive_current_card, use_container_width=True)
232
+ st.button("Quit Session", on_click=lambda: set_page('home'), use_container_width=True)
233
 
234
  else:
235
  set_page('home')