Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -93,7 +93,7 @@ custom_css = f"""
|
|
| 93 |
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');
|
| 94 |
|
| 95 |
:root {{
|
| 96 |
-
/* --- DEFAULT: NIGHT MODE (
|
| 97 |
--bg-gradient: radial-gradient(circle at 50% 0%, #0a0a2e 0%, #000000 100%);
|
| 98 |
--card-bg: rgba(15, 15, 35, 0.7);
|
| 99 |
--text-primary: #e0e7ff;
|
|
@@ -106,7 +106,7 @@ custom_css = f"""
|
|
| 106 |
--glow-color: rgba(212, 175, 55, 0.4);
|
| 107 |
}}
|
| 108 |
|
| 109 |
-
/* --- LIGHT MODE OVERRIDE CLASS --- */
|
| 110 |
body.light-mode {{
|
| 111 |
--bg-gradient: linear-gradient(135deg, #f0e6d2 0%, #e6dcc3 100%);
|
| 112 |
--card-bg: rgba(255, 255, 255, 0.6);
|
|
@@ -127,7 +127,7 @@ body, .gradio-container {{
|
|
| 127 |
color: var(--text-primary) !important;
|
| 128 |
cursor: {cursor_url} 16 16, auto !important;
|
| 129 |
-webkit-font-smoothing: antialiased;
|
| 130 |
-
transition: background 0.5s ease
|
| 131 |
}}
|
| 132 |
|
| 133 |
button, a, .cursor-pointer {{
|
|
@@ -229,8 +229,16 @@ button.toggle-btn:hover {{
|
|
| 229 |
border: 1px solid var(--border-color);
|
| 230 |
}}
|
| 231 |
|
| 232 |
-
/* CLEANUP */
|
| 233 |
.gradio-image, .gradio-json {{ background: transparent !important; border: none !important; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
.report-box textarea {{
|
| 235 |
background-color: rgba(0,0,0,0.2) !important;
|
| 236 |
border: 1px solid var(--border-color) !important;
|
|
@@ -329,45 +337,7 @@ claude_json_content = """{
|
|
| 329 |
|
| 330 |
# --- 4. MAIN APP ASSEMBLY ---
|
| 331 |
|
| 332 |
-
#
|
| 333 |
-
js_code = """
|
| 334 |
-
() => {
|
| 335 |
-
// 1. Toggle Logic
|
| 336 |
-
const toggleTheme = () => {
|
| 337 |
-
document.body.classList.toggle('light-mode');
|
| 338 |
-
const container = document.querySelector('.gradio-container');
|
| 339 |
-
if (container) container.classList.toggle('light-mode');
|
| 340 |
-
}
|
| 341 |
-
|
| 342 |
-
// 2. Mouse Trail Logic
|
| 343 |
-
const addTrail = () => {
|
| 344 |
-
document.addEventListener('mousemove', function(e) {
|
| 345 |
-
// Rate limit to prevent too many elements
|
| 346 |
-
if (Math.random() > 0.5) return;
|
| 347 |
-
|
| 348 |
-
const dust = document.createElement('div');
|
| 349 |
-
dust.classList.add('gold-dust');
|
| 350 |
-
dust.style.left = e.clientX + 'px';
|
| 351 |
-
dust.style.top = e.clientY + 'px';
|
| 352 |
-
document.body.appendChild(dust);
|
| 353 |
-
|
| 354 |
-
// Remove after animation
|
| 355 |
-
setTimeout(() => {
|
| 356 |
-
dust.remove();
|
| 357 |
-
}, 600);
|
| 358 |
-
});
|
| 359 |
-
}
|
| 360 |
-
|
| 361 |
-
// Initialize
|
| 362 |
-
addTrail();
|
| 363 |
-
|
| 364 |
-
// Return the toggle function for the button click
|
| 365 |
-
return toggleTheme;
|
| 366 |
-
}
|
| 367 |
-
"""
|
| 368 |
-
|
| 369 |
-
# We need to run the trail logic on load, but Gradio JS usually runs on events.
|
| 370 |
-
# We will attach the trail logic to the body load via an HTML script injection.
|
| 371 |
trail_script = """
|
| 372 |
<script>
|
| 373 |
document.addEventListener('DOMContentLoaded', () => {
|
|
@@ -394,7 +364,7 @@ with gr.Blocks(title="Rosetta Decoder") as demo:
|
|
| 394 |
with gr.Column(scale=4):
|
| 395 |
gr.HTML(header_html)
|
| 396 |
with gr.Column(scale=1):
|
| 397 |
-
# JS-based Toggle
|
| 398 |
btn_toggle = gr.Button("๐ Day / Night", elem_classes="toggle-btn")
|
| 399 |
|
| 400 |
gr.HTML(mission_html)
|
|
@@ -430,7 +400,7 @@ with gr.Blocks(title="Rosetta Decoder") as demo:
|
|
| 430 |
gr.HTML("</div>")
|
| 431 |
|
| 432 |
# Wiring
|
| 433 |
-
# The toggle button triggers
|
| 434 |
btn_toggle.click(None, None, None, js="() => { document.body.classList.toggle('light-mode'); document.querySelector('.gradio-container').classList.toggle('light-mode'); }")
|
| 435 |
|
| 436 |
btn_upload.click(fn=detect_hieroglyphs, inputs=[img_upload, slider_upload], outputs=[out_image, out_json, out_report, btn_download])
|
|
|
|
| 93 |
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');
|
| 94 |
|
| 95 |
:root {{
|
| 96 |
+
/* --- DEFAULT: NIGHT MODE (Lapis Lazuli) --- */
|
| 97 |
--bg-gradient: radial-gradient(circle at 50% 0%, #0a0a2e 0%, #000000 100%);
|
| 98 |
--card-bg: rgba(15, 15, 35, 0.7);
|
| 99 |
--text-primary: #e0e7ff;
|
|
|
|
| 106 |
--glow-color: rgba(212, 175, 55, 0.4);
|
| 107 |
}}
|
| 108 |
|
| 109 |
+
/* --- LIGHT MODE OVERRIDE CLASS (Papyrus) --- */
|
| 110 |
body.light-mode {{
|
| 111 |
--bg-gradient: linear-gradient(135deg, #f0e6d2 0%, #e6dcc3 100%);
|
| 112 |
--card-bg: rgba(255, 255, 255, 0.6);
|
|
|
|
| 127 |
color: var(--text-primary) !important;
|
| 128 |
cursor: {cursor_url} 16 16, auto !important;
|
| 129 |
-webkit-font-smoothing: antialiased;
|
| 130 |
+
transition: background 0.5s ease, color 0.5s ease;
|
| 131 |
}}
|
| 132 |
|
| 133 |
button, a, .cursor-pointer {{
|
|
|
|
| 229 |
border: 1px solid var(--border-color);
|
| 230 |
}}
|
| 231 |
|
| 232 |
+
/* --- UI CLEANUP & FIXES --- */
|
| 233 |
.gradio-image, .gradio-json {{ background: transparent !important; border: none !important; }}
|
| 234 |
+
|
| 235 |
+
/* FIX FOR DARK GREY UPLOAD BOX IN LIGHT MODE */
|
| 236 |
+
body.light-mode .gradio-image button {{
|
| 237 |
+
background-color: rgba(255, 248, 240, 0.7) !important; /* Light papyrus fill */
|
| 238 |
+
border: 2px dashed var(--border-color) !important;
|
| 239 |
+
color: var(--text-primary) !important; /* Dark text */
|
| 240 |
+
}}
|
| 241 |
+
|
| 242 |
.report-box textarea {{
|
| 243 |
background-color: rgba(0,0,0,0.2) !important;
|
| 244 |
border: 1px solid var(--border-color) !important;
|
|
|
|
| 337 |
|
| 338 |
# --- 4. MAIN APP ASSEMBLY ---
|
| 339 |
|
| 340 |
+
# Trail Script attached to body load
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
trail_script = """
|
| 342 |
<script>
|
| 343 |
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
| 364 |
with gr.Column(scale=4):
|
| 365 |
gr.HTML(header_html)
|
| 366 |
with gr.Column(scale=1):
|
| 367 |
+
# JS-based Toggle button
|
| 368 |
btn_toggle = gr.Button("๐ Day / Night", elem_classes="toggle-btn")
|
| 369 |
|
| 370 |
gr.HTML(mission_html)
|
|
|
|
| 400 |
gr.HTML("</div>")
|
| 401 |
|
| 402 |
# Wiring
|
| 403 |
+
# The toggle button triggers JS to add/remove the 'light-mode' class
|
| 404 |
btn_toggle.click(None, None, None, js="() => { document.body.classList.toggle('light-mode'); document.querySelector('.gradio-container').classList.toggle('light-mode'); }")
|
| 405 |
|
| 406 |
btn_upload.click(fn=detect_hieroglyphs, inputs=[img_upload, slider_upload], outputs=[out_image, out_json, out_report, btn_download])
|