andrewrreed HF staff commited on
Commit
bce77cb
1 Parent(s): f066365

enforce dark mode

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -145,6 +145,17 @@ def build_plot(min_score, max_models_per_month, toggle_annotations, set_selector
145
  return fig
146
 
147
 
 
 
 
 
 
 
 
 
 
 
 
148
  with gr.Blocks(
149
  theme=gr.themes.Soft(
150
  primary_hue=gr.themes.colors.sky,
@@ -157,7 +168,8 @@ with gr.Blocks(
157
  "system-ui",
158
  "sans-serif",
159
  ],
160
- )
 
161
  ) as demo:
162
  gr.Markdown(
163
  """
 
145
  return fig
146
 
147
 
148
+ set_dark_mode = """
149
+ function refresh() {
150
+ const url = new URL(window.location);
151
+
152
+ if (url.searchParams.get('__theme') !== 'dark') {
153
+ url.searchParams.set('__theme', 'dark');
154
+ window.location.href = url.href;
155
+ }
156
+ }
157
+ """
158
+
159
  with gr.Blocks(
160
  theme=gr.themes.Soft(
161
  primary_hue=gr.themes.colors.sky,
 
168
  "system-ui",
169
  "sans-serif",
170
  ],
171
+ ),
172
+ js=set_dark_mode,
173
  ) as demo:
174
  gr.Markdown(
175
  """