Sdm0 commited on
Commit
f6e2ebc
Β·
verified Β·
1 Parent(s): 93c354e

Sync from GitHub via hub-sync

Browse files
Files changed (1) hide show
  1. app.py +46 -28
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-wrap {
338
- display: flex; align-items: center; gap: 8px; margin-left: auto;
 
 
339
  }
340
- .theme-toggle-btn {
341
- background: none; border: 1px solid #d1d5db; border-radius: 8px;
342
- padding: 6px 12px; cursor: pointer; font-size: 1.1em;
343
- transition: all 0.2s ease;
 
 
 
 
 
344
  }
345
- .theme-toggle-btn:hover {
346
- background: #f3f4f6; border-color: #9ca3af;
 
347
  }
348
- body.dark-mode .theme-toggle-btn {
349
- border-color: #4b5563; color: #f3f4f6;
 
350
  }
351
- body.dark-mode .theme-toggle-btn:hover {
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()