vincenthugging commited on
Commit
17be659
·
1 Parent(s): 0d65580

🌙 统一采用暗色主题设计 - GitHub风格

Browse files

🎨 完整暗色主题设计:
1. **全局色彩系统**
- 主背景: #0d1117 (GitHub深色)
- 表面色: #161b22 (卡片背景)
- 次级表面: #21262d (输入框等)
- 边框色: #30363d / #21262d
- 主色调: #0969da (GitHub蓝)
- 文本色: #f0f6fc (主要) / #8b949e (次要)

2. **组件样式统一**
- 所有输入框、下拉框、音频组件使用暗色背景
- 统一12px圆角设计
- hover效果带有蓝色边框和阴影
- 按钮采用主品牌色配色方案

3. **Gradio主题定制**
- 使用 gr.themes.Base 创建自定义暗色主题
- 覆盖默认配色为GitHub暗色风格
- 自定义CSS进一步精细化样式控制

4. **视觉层次优化**
- 卡片hover效果: 上移 + 蓝色边框 + 增强阴影
- 按钮渐变hover效果: 颜色变化 + 位移 + 阴影
- 折叠面板、文本、代码块统一暗色处理

5. **护眼体验**
- 深色背景减少眼部疲劳
- 合适的对比度确保文字清晰可读
- 现代化的视觉感受

🔧 技术实现:
- CSS变量系统便于主题维护
- Gradio原生主题 + 自定义CSS双重保障
- 全面覆盖所有UI组件的样式重置

现在整个界面呈现统一的现代暗色风格,视觉体验更加一致和舒适!

Files changed (1) hide show
  1. app.py +124 -31
app.py CHANGED
@@ -402,20 +402,26 @@ def generate_dialogue_audio(
402
  # =========================
403
 
404
  def create_space_ui() -> gr.Blocks:
405
- # Apple-inspired 简洁设计样式
406
  custom_css = """
407
- /* 全局样式 - Apple风格 */
408
  .gradio-container {
409
  max-width: 1400px !important;
410
  margin: 0 auto !important;
411
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif !important;
412
- background: #f5f5f7 !important;
413
- --primary-color: #007AFF;
414
- --surface-color: #ffffff;
415
- --border-color: #d1d1d6;
416
- --text-primary: #1d1d1f;
417
- --text-secondary: #86868b;
418
- --shadow: 0 4px 16px rgba(0,0,0,0.1);
 
 
 
 
 
 
419
  --radius: 12px;
420
  }
421
  /* 主标题区域 */
@@ -442,50 +448,137 @@ def create_space_ui() -> gr.Blocks:
442
  color: var(--text-secondary);
443
  font-weight: 400;
444
  }
 
445
  .section {
446
- background: #f8fafc;
447
- padding: 1.5rem;
448
- border-radius: 15px;
449
- border: 1px solid #e2e8f0;
450
- margin-bottom: 1rem;
451
- box-shadow: 0 2px 10px rgba(0,0,0,0.05);
 
 
 
 
 
 
452
  }
 
453
  .quick-btn {
454
- background: linear-gradient(45deg, #FF6B6B, #4ECDC4) !important;
455
  border: none !important;
456
- color: white !important;
457
  font-weight: 600 !important;
458
- border-radius: 10px !important;
459
- transition: all 0.3s ease !important;
 
460
  }
461
  .quick-btn:hover {
462
- transform: translateY(-2px) !important;
463
- box-shadow: 0 5px 15px rgba(0,0,0,0.2) !important;
 
464
  }
465
  .generate-btn {
466
- background: linear-gradient(45deg, #667eea, #764ba2) !important;
467
  border: none !important;
468
- color: white !important;
469
  font-weight: 700 !important;
470
  font-size: 1.1rem !important;
471
- border-radius: 15px !important;
472
  padding: 1rem 2rem !important;
473
  width: 100% !important;
474
- transition: all 0.3s ease !important;
 
475
  }
476
  .generate-btn:hover {
477
- transform: translateY(-3px) !important;
478
- box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4) !important;
 
479
  }
480
  .speaker-section {
481
- background: linear-gradient(135deg, #667eea15, #764ba215);
482
  padding: 1.5rem;
483
- border-radius: 15px;
484
- border: 2px solid #667eea20;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  }
486
  """
487
 
488
- with gr.Blocks(css=custom_css, title="🎙️ MOSS-TTSD | Hugging Face Space", theme=gr.themes.Soft()) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  gr.HTML(
490
  """
491
  <div class="header">
 
402
  # =========================
403
 
404
  def create_space_ui() -> gr.Blocks:
405
+ # Apple-inspired 暗色主题设计
406
  custom_css = """
407
+ /* 全局样式 - Apple暗色风格 */
408
  .gradio-container {
409
  max-width: 1400px !important;
410
  margin: 0 auto !important;
411
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif !important;
412
+ background: #0d1117 !important;
413
+ --primary-color: #0969da;
414
+ --primary-hover: #1f6feb;
415
+ --surface-color: #161b22;
416
+ --surface-secondary: #21262d;
417
+ --border-color: #30363d;
418
+ --border-secondary: #21262d;
419
+ --text-primary: #f0f6fc;
420
+ --text-secondary: #8b949e;
421
+ --text-muted: #656d76;
422
+ --success-color: #238636;
423
+ --shadow: 0 4px 16px rgba(0,0,0,0.4);
424
+ --shadow-elevated: 0 8px 32px rgba(0,0,0,0.6);
425
  --radius: 12px;
426
  }
427
  /* 主标题区域 */
 
448
  color: var(--text-secondary);
449
  font-weight: 400;
450
  }
451
+ /* 卡片组件 - 暗色主题 */
452
  .section {
453
+ background: var(--surface-color);
454
+ border-radius: var(--radius);
455
+ padding: 2rem;
456
+ border: 1px solid var(--border-color);
457
+ margin: 1rem 0;
458
+ box-shadow: var(--shadow);
459
+ transition: all 0.2s ease;
460
+ }
461
+ .section:hover {
462
+ box-shadow: var(--shadow-elevated);
463
+ transform: translateY(-2px);
464
+ border-color: var(--primary-color);
465
  }
466
+ /* 按钮样式 - 暗色主题 */
467
  .quick-btn {
468
+ background: var(--primary-color) !important;
469
  border: none !important;
470
+ color: var(--text-primary) !important;
471
  font-weight: 600 !important;
472
+ border-radius: var(--radius) !important;
473
+ padding: 0.875rem 2rem !important;
474
+ transition: all 0.2s ease !important;
475
  }
476
  .quick-btn:hover {
477
+ background: var(--primary-hover) !important;
478
+ transform: translateY(-1px) !important;
479
+ box-shadow: 0 8px 24px rgba(9,105,218,0.4) !important;
480
  }
481
  .generate-btn {
482
+ background: var(--primary-color) !important;
483
  border: none !important;
484
+ color: var(--text-primary) !important;
485
  font-weight: 700 !important;
486
  font-size: 1.1rem !important;
487
+ border-radius: var(--radius) !important;
488
  padding: 1rem 2rem !important;
489
  width: 100% !important;
490
+ transition: all 0.2s ease !important;
491
+ box-shadow: var(--shadow) !important;
492
  }
493
  .generate-btn:hover {
494
+ background: var(--primary-hover) !important;
495
+ transform: translateY(-2px) !important;
496
+ box-shadow: var(--shadow-elevated) !important;
497
  }
498
  .speaker-section {
499
+ background: var(--surface-secondary);
500
  padding: 1.5rem;
501
+ border-radius: var(--radius);
502
+ border: 1px solid var(--border-color);
503
+ }
504
+
505
+ /* Gradio 组件暗色主题覆盖 */
506
+ .gradio-container .gr-textbox,
507
+ .gradio-container .gr-textarea,
508
+ .gradio-container .gr-dropdown,
509
+ .gradio-container .gr-audio,
510
+ .gradio-container .gr-slider,
511
+ .gradio-container .gr-checkbox,
512
+ .gradio-container .gr-accordion {
513
+ background: var(--surface-color) !important;
514
+ border: 1px solid var(--border-color) !important;
515
+ color: var(--text-primary) !important;
516
+ border-radius: var(--radius) !important;
517
+ }
518
+
519
+ .gradio-container .gr-textbox:focus,
520
+ .gradio-container .gr-textarea:focus,
521
+ .gradio-container .gr-dropdown:focus {
522
+ border-color: var(--primary-color) !important;
523
+ box-shadow: 0 0 0 3px rgba(9,105,218,0.2) !important;
524
+ }
525
+
526
+ /* 文本和标签暗色主题 */
527
+ .gradio-container .gr-markdown,
528
+ .gradio-container .gr-markdown *,
529
+ .gradio-container label,
530
+ .gradio-container p,
531
+ .gradio-container span {
532
+ color: var(--text-primary) !important;
533
+ }
534
+
535
+ .gradio-container .gr-markdown code {
536
+ background: var(--surface-secondary) !important;
537
+ color: var(--text-primary) !important;
538
+ border-radius: 4px !important;
539
+ padding: 2px 6px !important;
540
+ }
541
+
542
+ /* 按钮统一暗色主题 */
543
+ .gradio-container .gr-button {
544
+ background: var(--surface-color) !important;
545
+ border: 1px solid var(--border-color) !important;
546
+ color: var(--text-primary) !important;
547
+ border-radius: var(--radius) !important;
548
+ }
549
+
550
+ .gradio-container .gr-button:hover {
551
+ background: var(--surface-secondary) !important;
552
+ border-color: var(--primary-color) !important;
553
+ }
554
+
555
+ .gradio-container .gr-button.primary {
556
+ background: var(--primary-color) !important;
557
+ border: none !important;
558
+ color: var(--text-primary) !important;
559
+ }
560
+
561
+ .gradio-container .gr-button.primary:hover {
562
+ background: var(--primary-hover) !important;
563
  }
564
  """
565
 
566
+ # 创建暗色主题
567
+ dark_theme = gr.themes.Base(
568
+ primary_hue="blue",
569
+ secondary_hue="gray",
570
+ neutral_hue="gray",
571
+ ).set(
572
+ background_fill_primary="#0d1117",
573
+ background_fill_secondary="#161b22",
574
+ border_color_primary="#30363d",
575
+ border_color_secondary="#21262d",
576
+ color_accent_soft="#0969da",
577
+ text_color_primary="#f0f6fc",
578
+ text_color_secondary="#8b949e",
579
+ )
580
+
581
+ with gr.Blocks(css=custom_css, title="🎙️ MOSS-TTSD | Hugging Face Space", theme=dark_theme) as demo:
582
  gr.HTML(
583
  """
584
  <div class="header">