Spaces:
Running
Running
Sync from GitHub via hub-sync
Browse files
app.py
CHANGED
|
@@ -334,22 +334,31 @@ details { margin-top: 8px; }
|
|
| 334 |
details summary { cursor: pointer; color: #4b5563; font-weight: 500; }
|
| 335 |
|
| 336 |
/* ββ Theme toggle βββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 337 |
-
.theme-toggle-
|
| 338 |
-
|
|
|
|
|
|
|
| 339 |
}
|
| 340 |
-
|
| 341 |
-
background:
|
| 342 |
-
|
| 343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
}
|
| 345 |
-
|
| 346 |
-
background: #f3f4f6
|
|
|
|
| 347 |
}
|
| 348 |
-
body.dark-mode
|
| 349 |
-
border-color: #4b5563
|
|
|
|
| 350 |
}
|
| 351 |
-
body.dark-mode
|
| 352 |
-
background: #374151;
|
| 353 |
}
|
| 354 |
|
| 355 |
/* ββ Loading spinner ββββββββββββββββββββββββββββββββββββββββββββββββ */
|
|
@@ -368,31 +377,40 @@ body.dark-mode .theme-toggle-btn:hover {
|
|
| 368 |
}
|
| 369 |
"""
|
| 370 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
with gr.Blocks(css=CSS, title="OpenCodeReview", theme=gr.themes.Soft()) as demo:
|
|
|
|
|
|
|
| 372 |
gr.HTML(
|
| 373 |
'<div style="display:flex;align-items:center">'
|
| 374 |
'<div><h1>π OpenCodeReview</h1>'
|
| 375 |
'<p style="color:var(--text-muted);margin-top:-8px">'
|
| 376 |
'AI-powered PR review with human-in-the-loop approval</p></div>'
|
| 377 |
-
'<div class="theme-toggle-wrap">'
|
| 378 |
-
'<button class="theme-toggle-btn" onclick="toggleTheme()"'
|
| 379 |
-
' title="Toggle dark mode" id="themeToggleBtn">π</button></div>'
|
| 380 |
'</div>'
|
| 381 |
-
'<script>'
|
| 382 |
-
'(function(){'
|
| 383 |
-
' const isDark = localStorage.getItem("ocr-theme") === "dark";'
|
| 384 |
-
' if (isDark) document.body.classList.add("dark-mode");'
|
| 385 |
-
' const btn = document.getElementById("themeToggleBtn");'
|
| 386 |
-
' if (btn) btn.textContent = isDark ? "βοΈ" : "π";'
|
| 387 |
-
'})();'
|
| 388 |
-
'function toggleTheme(){'
|
| 389 |
-
' const isDark = document.body.classList.toggle("dark-mode");'
|
| 390 |
-
' localStorage.setItem("ocr-theme", isDark ? "dark" : "light");'
|
| 391 |
-
' document.getElementById("themeToggleBtn").textContent = isDark ? "βοΈ" : "π";'
|
| 392 |
-
'}'
|
| 393 |
-
'</script>'
|
| 394 |
)
|
| 395 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
# ββ State ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 397 |
pr_state = gr.State()
|
| 398 |
smoke_state = gr.State()
|
|
|
|
| 334 |
details summary { cursor: pointer; color: #4b5563; font-weight: 500; }
|
| 335 |
|
| 336 |
/* ββ Theme toggle βββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 337 |
+
.theme-toggle-row {
|
| 338 |
+
justify-content: flex-end !important;
|
| 339 |
+
margin-top: -40px !important;
|
| 340 |
+
margin-bottom: 8px !important;
|
| 341 |
}
|
| 342 |
+
#theme-toggle-btn {
|
| 343 |
+
background: transparent !important;
|
| 344 |
+
border: 1px solid #d1d5db !important;
|
| 345 |
+
border-radius: 8px !important;
|
| 346 |
+
padding: 4px 10px !important;
|
| 347 |
+
font-size: 1.1em !important;
|
| 348 |
+
min-width: 44px !important;
|
| 349 |
+
transition: all 0.2s ease !important;
|
| 350 |
+
box-shadow: none !important;
|
| 351 |
}
|
| 352 |
+
#theme-toggle-btn:hover {
|
| 353 |
+
background: #f3f4f6 !important;
|
| 354 |
+
border-color: #9ca3af !important;
|
| 355 |
}
|
| 356 |
+
body.dark-mode #theme-toggle-btn {
|
| 357 |
+
border-color: #4b5563 !important;
|
| 358 |
+
color: #f3f4f6 !important;
|
| 359 |
}
|
| 360 |
+
body.dark-mode #theme-toggle-btn:hover {
|
| 361 |
+
background: #374151 !important;
|
| 362 |
}
|
| 363 |
|
| 364 |
/* ββ Loading spinner ββββββββββββββββββββββββββββββββββββββββββββββββ */
|
|
|
|
| 377 |
}
|
| 378 |
"""
|
| 379 |
|
| 380 |
+
JS_RESTORE_THEME = """
|
| 381 |
+
() => {
|
| 382 |
+
const isDark = localStorage.getItem("ocr-theme") === "dark";
|
| 383 |
+
if (isDark) document.body.classList.add("dark-mode");
|
| 384 |
+
const btn = document.querySelector("#theme-toggle-btn");
|
| 385 |
+
if (btn) btn.textContent = isDark ? "βοΈ" : "π";
|
| 386 |
+
}
|
| 387 |
+
"""
|
| 388 |
+
|
| 389 |
+
JS_TOGGLE_THEME = """
|
| 390 |
+
() => {
|
| 391 |
+
const isDark = document.body.classList.toggle("dark-mode");
|
| 392 |
+
localStorage.setItem("ocr-theme", isDark ? "dark" : "light");
|
| 393 |
+
const btn = document.querySelector("#theme-toggle-btn");
|
| 394 |
+
if (btn) btn.textContent = isDark ? "βοΈ" : "π";
|
| 395 |
+
return [];
|
| 396 |
+
}
|
| 397 |
+
"""
|
| 398 |
+
|
| 399 |
with gr.Blocks(css=CSS, title="OpenCodeReview", theme=gr.themes.Soft()) as demo:
|
| 400 |
+
demo.load(js=JS_RESTORE_THEME)
|
| 401 |
+
|
| 402 |
gr.HTML(
|
| 403 |
'<div style="display:flex;align-items:center">'
|
| 404 |
'<div><h1>π OpenCodeReview</h1>'
|
| 405 |
'<p style="color:var(--text-muted);margin-top:-8px">'
|
| 406 |
'AI-powered PR review with human-in-the-loop approval</p></div>'
|
|
|
|
|
|
|
|
|
|
| 407 |
'</div>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
)
|
| 409 |
|
| 410 |
+
with gr.Row(elem_classes="theme-toggle-row"):
|
| 411 |
+
theme_toggle = gr.Button("π", elem_id="theme-toggle-btn", size="sm", min_width=50)
|
| 412 |
+
theme_toggle.click(js=JS_TOGGLE_THEME)
|
| 413 |
+
|
| 414 |
# ββ State ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 415 |
pr_state = gr.State()
|
| 416 |
smoke_state = gr.State()
|