cwadayi commited on
Commit
9f453e4
·
verified ·
1 Parent(s): a4bf8ae

Update ui/layouts.py

Browse files
Files changed (1) hide show
  1. ui/layouts.py +17 -25
ui/layouts.py CHANGED
@@ -13,40 +13,36 @@ def create_ui(visit_count_html: str, theme: gr.Theme):
13
  """
14
 
15
  # --- Main UI Layout ---
16
- with gr.Blocks(theme=theme, title="地球物理學") as demo: # ✨ 調整 title 顯示在瀏覽器標籤頁
17
- # --- Display Visit Counter at the top (如果需要,也可以選擇移除) ---
18
- # gr.Markdown(visit_count_html)
19
-
20
- # --- ✨ 新增: 自訂頂部 Header 區塊 (模仿圖片中的藍綠色背景) ---
21
  gr.Markdown(
22
  """
23
  <style>
24
  .custom-header {
25
- background: linear-gradient(135deg, #005f73, #0a9396); /* 藍綠漸變 */
26
  color: #fff;
27
- padding: 4rem 2rem; /* 增加上下內距 */
28
  text-align: center;
29
- border-radius: 0 0 20px 20px; /* 底部圓角 */
30
- margin-bottom: 2rem; /* 與下方內容的間距 */
31
- box-shadow: 0 8px 15px rgba(0,0,0,0.1); /* 輕微陰影 */
32
  }
33
  .custom-header h1 {
34
- font-size: 3.5rem; /* 大標題字體 */
35
  font-weight: 700;
36
- margin-bottom: 0.8rem; /* 標題與副標題間距 */
37
  line-height: 1.2;
38
  }
39
  .custom-header p {
40
- font-size: 1.6rem; /* 副標題字體 */
41
  font-weight: 400;
42
  opacity: 0.9;
43
  margin-top: 0;
44
  }
45
- /* RWD for header */
46
  @media (max-width: 768px) {
47
  .custom-header {
48
  padding: 3rem 1rem;
49
- border-radius: 0; /* 手機版不設底部圓角 */
50
  }
51
  .custom-header h1 {
52
  font-size: 2.5rem;
@@ -60,17 +56,12 @@ def create_ui(visit_count_html: str, theme: gr.Theme):
60
  <h1>地球物理概論</h1>
61
  <p>一個探索我們星球內在奧秘的互動式指南</p>
62
  </div>
63
- """,
64
- # 為了讓這些 CSS 生效,將 render_as_html 設為 True
65
- # 但是 Gradio 預設的 markdown 已經是 render_as_html,所以通常不需要特別設定
66
  )
67
 
68
- # --- 新增: 模仿網站導覽列的 Tab 容器 ---
69
- # 移除 container=False,讓它有白色背景和陰影
70
- with gr.Row(variant="panel", elem_id="main-nav-tabs"): # 給予 ID 方便未來 CSS 微調
71
- # gr.Tabs 放在 Row 裡面,方便控制其寬度與位置
72
- # class_name 用於自訂 CSS 樣式,但 Gradio 主題已能控制大部分外觀
73
- with gr.Tabs(selected=0): # 預設選中第一個 Tab
74
 
75
  with gr.TabItem("🎯 課程目標"):
76
  gr.Markdown(content.course_goals_md)
@@ -82,6 +73,7 @@ def create_ui(visit_count_html: str, theme: gr.Theme):
82
  with gr.TabItem("💯 成績計算"):
83
  gr.Markdown(content.grading_policy_md)
84
 
 
85
  with gr.TabItem("🚀 互動體驗區 (程式碼實驗室)"):
86
  gr.Markdown("## 🚀 互動程式碼實驗室")
87
  gr.Markdown("歡迎來到這裡!直接修改下方的 Python 程式碼,點擊「執行」,即可在右側看到成果。這是學習程式與地球物理最直接的方式!")
@@ -107,10 +99,10 @@ def create_ui(visit_count_html: str, theme: gr.Theme):
107
  seismo_plot_output = gr.Plot(label="震波圖輸出")
108
  seismo_console_output = gr.Textbox(label="執行結果 / 錯誤訊息", lines=8, interactive=False)
109
 
 
110
  with gr.TabItem("🤖 AI 課程助教"):
111
  with gr.Group():
112
  gr.Markdown("### 🤖 AI 課程助教 (知識庫 & 即時資訊強化版)")
113
-
114
  gr.Markdown("""
115
  歡迎使用課程 AI 助教!我整合了靜態的課程知識與多種即時資訊來源,您可以隨時向我提問。
116
 
 
13
  """
14
 
15
  # --- Main UI Layout ---
16
+ with gr.Blocks(theme=theme, title="地球物理學") as demo:
17
+ # --- 自訂頂部 Header ---
 
 
 
18
  gr.Markdown(
19
  """
20
  <style>
21
  .custom-header {
22
+ background: linear-gradient(135deg, #005f73, #0a9396);
23
  color: #fff;
24
+ padding: 4rem 2rem;
25
  text-align: center;
26
+ border-radius: 0 0 20px 20px;
27
+ margin-bottom: 2rem;
28
+ box-shadow: 0 8px 15px rgba(0,0,0,0.1);
29
  }
30
  .custom-header h1 {
31
+ font-size: 3.5rem;
32
  font-weight: 700;
33
+ margin-bottom: 0.8rem;
34
  line-height: 1.2;
35
  }
36
  .custom-header p {
37
+ font-size: 1.6rem;
38
  font-weight: 400;
39
  opacity: 0.9;
40
  margin-top: 0;
41
  }
 
42
  @media (max-width: 768px) {
43
  .custom-header {
44
  padding: 3rem 1rem;
45
+ border-radius: 0;
46
  }
47
  .custom-header h1 {
48
  font-size: 2.5rem;
 
56
  <h1>地球物理概論</h1>
57
  <p>一個探索我們星球內在奧秘的互動式指南</p>
58
  </div>
59
+ """
 
 
60
  )
61
 
62
+ # --- 主導覽列 Tab 容器 ---
63
+ with gr.Row(variant="panel", elem_id="main-nav-tabs"):
64
+ with gr.Tabs(selected=0):
 
 
 
65
 
66
  with gr.TabItem("🎯 課程目標"):
67
  gr.Markdown(content.course_goals_md)
 
73
  with gr.TabItem("💯 成績計算"):
74
  gr.Markdown(content.grading_policy_md)
75
 
76
+ # --- ✨ 還原「互動體驗區」分頁 ---
77
  with gr.TabItem("🚀 互動體驗區 (程式碼實驗室)"):
78
  gr.Markdown("## 🚀 互動程式碼實驗室")
79
  gr.Markdown("歡迎來到這裡!直接修改下方的 Python 程式碼,點擊「執行」,即可在右側看到成果。這是學習程式與地球物理最直接的方式!")
 
99
  seismo_plot_output = gr.Plot(label="震波圖輸出")
100
  seismo_console_output = gr.Textbox(label="執行結果 / 錯誤訊息", lines=8, interactive=False)
101
 
102
+ # --- ✨ 還原「AI 課程助教」分頁 ---
103
  with gr.TabItem("🤖 AI 課程助教"):
104
  with gr.Group():
105
  gr.Markdown("### 🤖 AI 課程助教 (知識庫 & 即時資訊強化版)")
 
106
  gr.Markdown("""
107
  歡迎使用課程 AI 助教!我整合了靜態的課程知識與多種即時資訊來源,您可以隨時向我提問。
108