lucadipalma
commited on
Commit
·
c9269a5
1
Parent(s):
142e783
force dark mode
Browse files- app.py +1 -23
- support/game_settings.py +59 -0
- support/style/css.py +8 -0
app.py
CHANGED
|
@@ -4,24 +4,13 @@ from mcp_servers.mcp_manager import start_mcp_servers
|
|
| 4 |
start_mcp_servers()
|
| 5 |
|
| 6 |
from support.log_manager import logger
|
|
|
|
| 7 |
from support.settings import SERVER_PORT
|
| 8 |
from pages import home, play, stats
|
| 9 |
from support.style.css import final_css
|
| 10 |
from support.game_settings import JS
|
| 11 |
|
| 12 |
|
| 13 |
-
# Custom header HTML
|
| 14 |
-
custom_header = """
|
| 15 |
-
<div class="custom-navbar">
|
| 16 |
-
<div class="navbar-title">🕵️ Agentic Codenames</div>
|
| 17 |
-
<div class="navbar-links">
|
| 18 |
-
<a href="#" class="nav-link active" data-tab-id="home_id">Home</a>
|
| 19 |
-
<a href="#" class="nav-link" data-tab-id="play_id">Play</a>
|
| 20 |
-
<a href="#" class="nav-link" data-tab-id="stats_id">Stats</a>
|
| 21 |
-
</div>
|
| 22 |
-
</div>
|
| 23 |
-
"""
|
| 24 |
-
|
| 25 |
# Create main application
|
| 26 |
with gr.Blocks(fill_width=True, title="Agentic Codenames", css=final_css, js=JS) as demo:
|
| 27 |
gr.HTML(custom_header)
|
|
@@ -36,17 +25,6 @@ with gr.Blocks(fill_width=True, title="Agentic Codenames", css=final_css, js=JS)
|
|
| 36 |
with gr.Tab("📊 Stats", id="stats_id_tab", elem_classes="tab_btn"):
|
| 37 |
stats.demo.render()
|
| 38 |
|
| 39 |
-
# Render home page (default/main page)
|
| 40 |
-
# home.demo.render()
|
| 41 |
-
|
| 42 |
-
# Add additional pages using route method
|
| 43 |
-
# with demo.route("Play", "/play"):
|
| 44 |
-
# gr.HTML(custom_header)
|
| 45 |
-
# play.demo.render()
|
| 46 |
-
|
| 47 |
-
# with demo.route("Stats", "/stats"):
|
| 48 |
-
# gr.HTML(custom_header)
|
| 49 |
-
# stats.demo.render()
|
| 50 |
|
| 51 |
if __name__ == "__main__":
|
| 52 |
demo.launch(
|
|
|
|
| 4 |
start_mcp_servers()
|
| 5 |
|
| 6 |
from support.log_manager import logger
|
| 7 |
+
from support.game_settings import custom_header
|
| 8 |
from support.settings import SERVER_PORT
|
| 9 |
from pages import home, play, stats
|
| 10 |
from support.style.css import final_css
|
| 11 |
from support.game_settings import JS
|
| 12 |
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Create main application
|
| 15 |
with gr.Blocks(fill_width=True, title="Agentic Codenames", css=final_css, js=JS) as demo:
|
| 16 |
gr.HTML(custom_header)
|
|
|
|
| 25 |
with gr.Tab("📊 Stats", id="stats_id_tab", elem_classes="tab_btn"):
|
| 26 |
stats.demo.render()
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
| 30 |
demo.launch(
|
support/game_settings.py
CHANGED
|
@@ -238,6 +238,52 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 238 |
|
| 239 |
JS = r"""
|
| 240 |
function initCarousel() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
// --- Carousel setup ---
|
| 242 |
function waitForElements(selectors, callback) {
|
| 243 |
const interval = setInterval(() => {
|
|
@@ -448,3 +494,16 @@ ALL_MODELS = sorted({
|
|
| 448 |
for preset in TEAM_MODEL_PRESETS.values()
|
| 449 |
for model in ([preset["boss"], preset["captain"]] + preset["players"])
|
| 450 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
JS = r"""
|
| 240 |
function initCarousel() {
|
| 241 |
+
|
| 242 |
+
function forceDarkMode() {
|
| 243 |
+
// Set dark mode on the root elements
|
| 244 |
+
const gradioContainer = document.querySelector('.gradio-container');
|
| 245 |
+
if (gradioContainer) {
|
| 246 |
+
gradioContainer.classList.add('dark');
|
| 247 |
+
gradioContainer.setAttribute('data-theme', 'dark');
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
// Set dark mode on document root
|
| 251 |
+
document.documentElement.setAttribute('data-theme', 'dark');
|
| 252 |
+
document.documentElement.style.colorScheme = 'dark';
|
| 253 |
+
|
| 254 |
+
// Set dark mode on body
|
| 255 |
+
document.body.setAttribute('data-theme', 'dark');
|
| 256 |
+
document.body.classList.add('dark');
|
| 257 |
+
|
| 258 |
+
// Force dark color scheme
|
| 259 |
+
const style = document.createElement('style');
|
| 260 |
+
style.textContent = `
|
| 261 |
+
:root {
|
| 262 |
+
color-scheme: dark !important;
|
| 263 |
+
}
|
| 264 |
+
.gradio-container {
|
| 265 |
+
color-scheme: dark !important;
|
| 266 |
+
}
|
| 267 |
+
body {
|
| 268 |
+
background-color: #0b0f19 !important;
|
| 269 |
+
color: #ffffff !important;
|
| 270 |
+
}
|
| 271 |
+
`;
|
| 272 |
+
document.head.appendChild(style);
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
// Apply dark mode immediately
|
| 276 |
+
forceDarkMode();
|
| 277 |
+
|
| 278 |
+
// Also apply after DOM is fully loaded
|
| 279 |
+
if (document.readyState === 'loading') {
|
| 280 |
+
document.addEventListener('DOMContentLoaded', forceDarkMode);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
// Re-apply dark mode when Gradio updates the DOM
|
| 284 |
+
const observer = new MutationObserver(forceDarkMode);
|
| 285 |
+
observer.observe(document.body, { childList: true, subtree: true });
|
| 286 |
+
|
| 287 |
// --- Carousel setup ---
|
| 288 |
function waitForElements(selectors, callback) {
|
| 289 |
const interval = setInterval(() => {
|
|
|
|
| 494 |
for preset in TEAM_MODEL_PRESETS.values()
|
| 495 |
for model in ([preset["boss"], preset["captain"]] + preset["players"])
|
| 496 |
})
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
# Custom header HTML
|
| 500 |
+
custom_header = """
|
| 501 |
+
<div class="custom-navbar">
|
| 502 |
+
<div class="navbar-title">🕵️ Agentic Codenames</div>
|
| 503 |
+
<div class="navbar-links">
|
| 504 |
+
<a href="#" class="nav-link active" data-tab-id="home_id">Home</a>
|
| 505 |
+
<a href="#" class="nav-link" data-tab-id="play_id">Play</a>
|
| 506 |
+
<a href="#" class="nav-link" data-tab-id="stats_id">Stats</a>
|
| 507 |
+
</div>
|
| 508 |
+
</div>
|
| 509 |
+
"""
|
support/style/css.py
CHANGED
|
@@ -444,6 +444,14 @@ stats_css = """
|
|
| 444 |
css = """
|
| 445 |
/* ==================== COMPACT HEADER ==================== */
|
| 446 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 447 |
.app.svelte-18evea3.svelte-18evea3{
|
| 448 |
padding: 0.5rem;
|
| 449 |
}
|
|
|
|
| 444 |
css = """
|
| 445 |
/* ==================== COMPACT HEADER ==================== */
|
| 446 |
|
| 447 |
+
:root {
|
| 448 |
+
color-scheme: dark !important;
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
.gradio-container {
|
| 452 |
+
color-scheme: dark !important;
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
.app.svelte-18evea3.svelte-18evea3{
|
| 456 |
padding: 0.5rem;
|
| 457 |
}
|