m7n commited on
Commit
3673672
·
1 Parent(s): 1431c60

Add JavaScript function to enforce light theme by refreshing the page

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -579,6 +579,21 @@ theme = gr.themes.Monochrome(
579
  )
580
 
581
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
582
  # Gradio interface setup
583
  with gr.Blocks(theme=theme, css="""
584
  .gradio-container a {
@@ -594,7 +609,7 @@ with gr.Blocks(theme=theme, css="""
594
  color: #b23310 !important;
595
  border-bottom: 3px solid #b23310; /* Wider underline, only on hover */
596
  }
597
- """) as demo:
598
  gr.Markdown("""
599
  <div style="max-width: 100%; margin: 0 auto;">
600
  <br>
 
579
  )
580
 
581
 
582
+ # JS to enforce light theme by refreshing the page
583
+ js_light = """
584
+ function refresh() {
585
+ const url = new URL(window.location);
586
+
587
+ if (url.searchParams.get('__theme') !== 'light') {
588
+ url.searchParams.set('__theme', 'light');
589
+ window.location.href = url.href;
590
+ }
591
+ }
592
+ """
593
+
594
+
595
+
596
+
597
  # Gradio interface setup
598
  with gr.Blocks(theme=theme, css="""
599
  .gradio-container a {
 
609
  color: #b23310 !important;
610
  border-bottom: 3px solid #b23310; /* Wider underline, only on hover */
611
  }
612
+ """, js=js_light) as demo:
613
  gr.Markdown("""
614
  <div style="max-width: 100%; margin: 0 auto;">
615
  <br>