DreamStream-1 commited on
Commit
f2d2a15
·
verified ·
1 Parent(s): a6f0fe8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -262,17 +262,11 @@ with gr.Blocks() as app:
262
  gr.HTML("<h1>🌟 Well-Being Companion</h1>")
263
 
264
  # Theme Dropdown
265
- themes = [
266
- "calm_seafoam",
267
- "Ranko_test"
268
- ]
269
-
270
- theme_dropdown = gr.Dropdown(choices=themes, label="Select Theme")
271
-
272
- toggle_dark = gr.Button(value="Toggle Dark", scale=1)
273
 
274
- def switch_theme(theme):
275
- """Switch CSS theme based on dropdown selection."""
276
  return f"""
277
  () => {{
278
  const themeElem = document.createElement('link');
@@ -282,9 +276,15 @@ with gr.Blocks() as app:
282
  }}
283
  """
284
 
285
- theme_dropdown.change(switch_theme, inputs=theme_dropdown, outputs=[])
 
 
 
 
 
 
286
 
287
- toggle_dark.click(lambda: None, None, None) # Just a placeholder for a dark mode operation
288
 
289
  with gr.Tab("Well-Being Chatbot"):
290
  with gr.Row():
 
262
  gr.HTML("<h1>🌟 Well-Being Companion</h1>")
263
 
264
  # Theme Dropdown
265
+ theme_dropdown = gr.Dropdown(choices=["calm_seafoam", "Ranko_test"], label="Select Theme")
266
+ theme_state = gr.State("calm_seafoam") # Default Theme
 
 
 
 
 
 
267
 
268
+ def update_theme(theme):
269
+ """Update the theme based on user selection."""
270
  return f"""
271
  () => {{
272
  const themeElem = document.createElement('link');
 
276
  }}
277
  """
278
 
279
+ theme_dropdown.change(update_theme, inputs=theme_dropdown, outputs=[])
280
+
281
+ toggle_dark = gr.Button(value="Toggle Dark", scale=1)
282
+
283
+ # Moving dark mode functionality to a Python function
284
+ def toggle_dark_mode():
285
+ return "dark" if "dark" not in app.state else ""
286
 
287
+ toggle_dark.click(toggle_dark_mode, None, theme_state)
288
 
289
  with gr.Tab("Well-Being Chatbot"):
290
  with gr.Row():