PhilipL commited on
Commit
b4537ab
·
verified ·
1 Parent(s): dac63cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -67
app.py CHANGED
@@ -180,78 +180,27 @@ def bridge_predict_frame(frame, st):
180
  # 4. Gradio 介面建構
181
  # ==========================================
182
 
183
- # --- [全面修正] 自動適應深色/淺色模式的 CSS ---
184
- adaptive_css = """
185
- /* === 針對深色模式 (Dark Mode) 的全面覆寫 === */
186
- @media (prefers-color-scheme: dark) {
187
-
188
- /* 1. 全域文字顏色 (預設轉為淺灰) */
189
- .gradio-container, .gradio-container p, .gradio-container span, .gradio-container div {
190
- color: #e2e8f0 !important;
191
- }
192
-
193
- /* 2. 標題 (H1-H6) 轉為亮白 */
194
- h1, h2, h3, h4, h5, h6 {
195
- color: #f8fafc !important;
196
- }
197
-
198
- /* 3. 輸入框與文字區 (Textbox, Textarea) - 確保深底白字 */
199
- textarea, input[type="text"], .gr-input {
200
- background-color: #1e293b !important; /* 深藍灰背景 */
201
- color: #ffffff !important; /* 純白文字 */
202
- border-color: #475569 !important; /* 邊框顏色 */
203
- }
204
-
205
- /* 4. 標籤 (Label) 與 選項 (Radio/Checkbox) */
206
- label, .block-label, span.ml-2 {
207
- color: #cbd5e1 !important; /* 稍微柔和的淺灰 */
208
- }
209
-
210
- /* 5. Markdown 內容區塊 (.prose) */
211
- .prose {
212
- color: #e2e8f0 !important;
213
- }
214
- .prose strong {
215
- color: #fbbf24 !important; /* 粗體字顯示金黃色,更明顯 */
216
- }
217
- .prose a {
218
- color: #60a5fa !important; /* 連結顯示亮藍色 */
219
- }
220
- .prose code {
221
- color: #f472b6 !important; /* 程式碼片段顯示粉色 */
222
- background-color: #334155 !important;
223
- }
224
-
225
- /* 6. 表格 (Dataframe/Table) */
226
- table, th, td {
227
- color: #e2e8f0 !important;
228
- border-color: #475569 !important;
229
- background-color: #0f172a !important; /* 表格深色背景 */
230
- }
231
-
232
- /* 7. 分頁標籤 (Tabs) */
233
- .tab-nav button.selected {
234
- color: #3b82f6 !important; /* 選中的 Tab 亮藍色 */
235
- border-bottom-color: #3b82f6 !important;
236
- }
237
- .tab-nav button {
238
- color: #94a3b8 !important; /* 未選中的 Tab 灰色 */
239
- }
240
  }
241
 
242
- /* === 針對淺色模式 (Light Mode) 的確保設定 === */
243
- @media (prefers-color-scheme: light) {
244
- .gradio-container {
245
- background-color: #ffffff !important;
246
- }
247
- .prose, p, label, span {
248
- color: #1f2937 !important; /* 深灰/黑 */
249
- }
250
  }
251
  """
252
 
253
- # 將原本的 emotion.css 與新的全面適應 CSS 合併
254
- combined_css = emotion.css + adaptive_css
255
 
256
  with gr.Blocks(title="AI 心情食堂", css=combined_css) as demo:
257
 
 
180
  # 4. Gradio 介面建構
181
  # ==========================================
182
 
183
+ # 定義強制標題黑色的 CSS
184
+ force_black_title_css = """
185
+ /* 1. 強制 Tab 分頁按鈕的文字 (如 "😊 情緒辨識 (Step 1)") 為黑色 */
186
+ .tab-nav button {
187
+ color: #000000 !important;
188
+ }
189
+ .tab-nav button.selected {
190
+ color: #000000 !important;
191
+ /* 如果選取時背景也是深色導致看不清,可以順便強制背景偏白:
192
+ background-color: #f1f5f9 !important;
193
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
195
 
196
+ /* 2. 強制內容中的標題 (如 "## 第一步:測測你的心情能量") 為黑色 */
197
+ h1, h2, h3, h4, h5, h6, .prose h1, .prose h2, .prose h3 {
198
+ color: #000000 !important;
 
 
 
 
 
199
  }
200
  """
201
 
202
+ # 將原本的 emotion.css 與這段強制黑色的 CSS 合併
203
+ combined_css = emotion.css + force_black_title_css
204
 
205
  with gr.Blocks(title="AI 心情食堂", css=combined_css) as demo:
206