Cachoups commited on
Commit
edb7081
·
verified ·
1 Parent(s): 035782a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -23
app.py CHANGED
@@ -303,30 +303,19 @@ stored_df2 = []
303
 
304
  current_theme = {"dark": False}
305
 
306
- def toggle_dark_mode():
307
- current_theme["dark"] = not current_theme["dark"]
308
- if current_theme["dark"]:
309
- return gr.update(css="""
310
- body {
311
- background-color: #333;
312
- color: white;
313
- }
314
- .gradio-container {
315
- background-color: #444;
316
- }
317
- """)
318
- else:
319
- return gr.update(css="""
320
- body {
321
- background-color: white;
322
- color: black;
323
- }
324
- .gradio-container {
325
- background-color: #f0f0f0;
326
- }
327
- """)
328
 
329
- with gr.Blocks(theme='gradio/soft') as demo:
330
  with gr.Row():
331
  toggle_dark = gr.Button(value="Toggle Dark Mode")
332
 
 
303
 
304
  current_theme = {"dark": False}
305
 
306
+
307
+ js_func = """
308
+ function refresh() {
309
+ const url = new URL(window.location);
310
+
311
+ if (url.searchParams.get('__theme') !== 'dark') {
312
+ url.searchParams.set('__theme', 'dark');
313
+ window.location.href = url.href;
314
+ }
315
+ }
316
+ """
 
 
 
 
 
 
 
 
 
 
 
317
 
318
+ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
319
  with gr.Row():
320
  toggle_dark = gr.Button(value="Toggle Dark Mode")
321