Spaces:
Running
Running
Amit
commited on
Commit
·
0f46d9e
1
Parent(s):
e02126a
Fix: Remove unsupported js param, use HTML script for dark mode
Browse files
app.py
CHANGED
|
@@ -619,33 +619,25 @@ button.primary:hover {
|
|
| 619 |
}
|
| 620 |
"""
|
| 621 |
|
| 622 |
-
# JS to force dark mode
|
| 623 |
-
JS_DARK_MODE = """
|
| 624 |
-
function refresh() {
|
| 625 |
-
document.body.classList.add('dark');
|
| 626 |
-
const url = new URL(window.location);
|
| 627 |
-
if (url.searchParams.get('__theme') !== 'dark') {
|
| 628 |
-
url.searchParams.set('__theme', 'dark');
|
| 629 |
-
window.history.pushState({}, '', url);
|
| 630 |
-
}
|
| 631 |
-
}
|
| 632 |
-
"""
|
| 633 |
-
|
| 634 |
# Build the Gradio app
|
| 635 |
demo = gr.Blocks(
|
| 636 |
title="Pip - Emotional AI Companion",
|
| 637 |
-
|
| 638 |
-
)
|
| 639 |
-
demo.theme = gr.themes.Soft(
|
| 640 |
-
primary_hue="indigo",
|
| 641 |
-
secondary_hue="teal",
|
| 642 |
-
radius_size="lg",
|
| 643 |
-
font=["Nunito", "sans-serif"]
|
| 644 |
)
|
| 645 |
|
| 646 |
with demo:
|
| 647 |
-
#
|
| 648 |
-
gr.HTML(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 649 |
|
| 650 |
# Session state
|
| 651 |
session_id = gr.State(create_session_id)
|
|
|
|
| 619 |
}
|
| 620 |
"""
|
| 621 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 622 |
# Build the Gradio app
|
| 623 |
demo = gr.Blocks(
|
| 624 |
title="Pip - Emotional AI Companion",
|
| 625 |
+
css=CUSTOM_CSS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 626 |
)
|
| 627 |
|
| 628 |
with demo:
|
| 629 |
+
# Force dark mode via script
|
| 630 |
+
gr.HTML("""
|
| 631 |
+
<script>
|
| 632 |
+
// Force dark theme
|
| 633 |
+
document.body.classList.add('dark');
|
| 634 |
+
const url = new URL(window.location);
|
| 635 |
+
if (url.searchParams.get('__theme') !== 'dark') {
|
| 636 |
+
url.searchParams.set('__theme', 'dark');
|
| 637 |
+
window.location.replace(url);
|
| 638 |
+
}
|
| 639 |
+
</script>
|
| 640 |
+
""")
|
| 641 |
|
| 642 |
# Session state
|
| 643 |
session_id = gr.State(create_session_id)
|