to set it to 'always dark' theme

#1
by ysharma HF staff - opened
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -15,14 +15,21 @@ def log_file_to_html_string():
15
 
16
  return html_content
17
 
18
- theme = gr.themes.Default().set(
19
- body_background_fill="repeating-linear-gradient(45deg, *primary_800, *primary_800 10px, *primary_900 10px, *primary_900 20px)",
20
- body_background_fill_dark="repeating-linear-gradient(45deg, *primary_800, *primary_800 10px, *primary_900 10px, *primary_900 20px)",
21
- )
22
 
23
- with gr.Blocks(theme=theme) as demo:
24
  name = gr.Markdown("# Reddit Scraper")
25
  output = gr.HTML(log_file_to_html_string, every=1)
 
 
 
 
 
 
 
26
 
27
  if __name__ == '__main__':
28
  demo.launch(server_name="0.0.0.0", show_error=True, server_port=7860, enable_queue=True)
 
15
 
16
  return html_content
17
 
18
+ #theme = gr.themes.Default().set(
19
+ # body_background_fill="repeating-linear-gradient(45deg, *primary_800, *primary_800 10px, *primary_900 10px, *primary_900 20px)",
20
+ # body_background_fill_dark="repeating-linear-gradient(45deg, *primary_800, *primary_800 10px, *primary_900 10px, *primary_900 20px)",
21
+ # )
22
 
23
+ with gr.Blocks() as demo:
24
  name = gr.Markdown("# Reddit Scraper")
25
  output = gr.HTML(log_file_to_html_string, every=1)
26
+ demo.load(None,
27
+ _js="""
28
+ () => {
29
+ document.body.classList.toggle('dark');
30
+ document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)'
31
+ }
32
+ """,)
33
 
34
  if __name__ == '__main__':
35
  demo.launch(server_name="0.0.0.0", show_error=True, server_port=7860, enable_queue=True)