sirochild commited on
Commit
c3b07e1
·
verified ·
1 Parent(s): 0571c40

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +31 -15
  2. style.css +110 -16
app.py CHANGED
@@ -317,7 +317,9 @@ def respond(message, chat_history, affection, history, scene_params):
317
 
318
  # より強力な背景更新用のHTMLを生成
319
  background_html = f'''
320
- <div class="chat-background {theme_name}"></div>
 
 
321
  <style>
322
  .chat-background {{
323
  background-image: url({THEME_URLS.get(theme_name, THEME_URLS["default"])}) !important;
@@ -362,21 +364,21 @@ with gr.Blocks(css=custom_css, theme=custom_theme) as demo:
362
  affection_state = gr.State(30)
363
  history_state = gr.State([])
364
 
365
- # 背景コンテナを先に配置
366
- background_display = gr.HTML(f'<div class="chat-background {DEFAULT_SCENE_PARAMS["theme"]}"></div>', elem_id="background_container")
 
 
 
 
367
 
368
- gr.Markdown("# 麻理チャット")
 
 
369
 
370
- # 著作権表示を追加
371
- gr.Markdown("""
372
- <div style="font-size: 0.8em; text-align: center; margin-top: 10px; opacity: 0.7;">
373
- 背景画像: <a href="https://pixabay.com" target="_blank">Pixabay</a> |
374
- アイコン: <a href="https://pixabay.com" target="_blank">Pixabay</a>
375
- </div>
376
- """)
377
  with gr.Row():
378
  with gr.Column(scale=2):
379
- with gr.Column(elem_id="chat_container"):
 
380
  # Gradio 5.x対応のChatbot設定
381
  try:
382
  # Gradio 5.x
@@ -399,10 +401,24 @@ with gr.Blocks(css=custom_css, theme=custom_theme) as demo:
399
  elem_id="chat_area",
400
  show_label=False
401
  )
402
- msg_input = gr.Textbox(label="あなたのメッセージ", placeholder="「水族館はどう?」と聞いた後、「いいね、行こう!」のように返してみてください", scale=5, show_label=False)
 
 
 
 
403
  with gr.Column(scale=1):
404
- stage_display = gr.Textbox(label="現在の関係ステージ", interactive=False, value=get_relationship_stage(30))
405
- affection_gauge = gr.Slider(minimum=0, maximum=100, label="麻理の好感度", value=30, interactive=False)
 
 
 
 
 
 
 
 
 
 
406
  msg_input.submit(
407
  respond,
408
  [msg_input, chatbot, affection_state, history_state, scene_state],
 
317
 
318
  # より強力な背景更新用のHTMLを生成
319
  background_html = f'''
320
+ <div class="background-container">
321
+ <div class="chat-background {theme_name}"></div>
322
+ </div>
323
  <style>
324
  .chat-background {{
325
  background-image: url({THEME_URLS.get(theme_name, THEME_URLS["default"])}) !important;
 
364
  affection_state = gr.State(30)
365
  history_state = gr.State([])
366
 
367
+ # 背景コンテナを先に配置(固定位置で全画面に)
368
+ background_display = gr.HTML(f'''
369
+ <div class="background-container">
370
+ <div class="chat-background {DEFAULT_SCENE_PARAMS["theme"]}"></div>
371
+ </div>
372
+ ''', elem_id="background_container")
373
 
374
+ # ヘッダー部分(背景と分離)
375
+ with gr.Box(elem_classes="header-box"):
376
+ gr.Markdown("# 麻理チャット")
377
 
 
 
 
 
 
 
 
378
  with gr.Row():
379
  with gr.Column(scale=2):
380
+ # チャットコンテナ(背景と分離)
381
+ with gr.Box(elem_id="chat_container", elem_classes="chat-box"):
382
  # Gradio 5.x対応のChatbot設定
383
  try:
384
  # Gradio 5.x
 
401
  elem_id="chat_area",
402
  show_label=False
403
  )
404
+ # 入力欄(背景と分離)
405
+ with gr.Box(elem_classes="input-box"):
406
+ msg_input = gr.Textbox(label="あなたのメッセージ", placeholder="「水族館はどう?」と聞いた後、「いいね、行こう!」のように返してみてください", show_label=False)
407
+
408
+ # ステータス部分(右側、背景と分離)
409
  with gr.Column(scale=1):
410
+ with gr.Box(elem_classes="status-box"):
411
+ stage_display = gr.Textbox(label="現在の関係ステージ", interactive=False, value=get_relationship_stage(30))
412
+ affection_gauge = gr.Slider(minimum=0, maximum=100, label="麻理の好感度", value=30, interactive=False)
413
+
414
+ # フッター部分(背景と分離)
415
+ with gr.Box(elem_classes="footer-box"):
416
+ gr.Markdown("""
417
+ <div style="font-size: 0.8em; text-align: center; opacity: 0.7;">
418
+ 背景画像: <a href="https://pixabay.com" target="_blank">Pixabay</a> |
419
+ アイコン: <a href="https://pixabay.com" target="_blank">Pixabay</a>
420
+ </div>
421
+ """)
422
  msg_input.submit(
423
  respond,
424
  [msg_input, chatbot, affection_state, history_state, scene_state],
style.css CHANGED
@@ -1,33 +1,127 @@
1
  /* ========================
2
- 全体背景用のベースクラス
3
  ======================== */
4
- .chat-background {
5
- position: absolute !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  top: 0 !important;
7
  left: 0 !important;
8
  width: 100% !important;
9
  height: 100% !important;
10
- z-index: 0 !important; /* UIの後ろに配置するが、-1だと見えない場合があるので0に */
11
- background-size: cover !important;
12
- background-position: center !important;
13
- opacity: 0.5 !important; /* 少し透けるように、値を上げて見やすく */
14
  pointer-events: none !important;
15
  }
16
 
17
- /* チャットコンテナの背景を透明に */
18
- #chat_container {
19
- position: relative !important;
20
- background: transparent !important;
21
- }
22
-
23
- /* 背景コンテナのスタイル */
24
- #background_container {
25
  position: absolute !important;
26
  top: 0 !important;
27
  left: 0 !important;
28
  width: 100% !important;
29
  height: 100% !important;
30
- z-index: -1 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
  /* ========================
 
1
  /* ========================
2
+ 全体レイアウト
3
  ======================== */
4
+ body {
5
+ margin: 0;
6
+ padding: 0;
7
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
8
+ }
9
+
10
+ /* メインコンテナ */
11
+ .gradio-container {
12
+ max-width: 1200px !important;
13
+ margin: 0 auto !important;
14
+ }
15
+
16
+ /* ========================
17
+ 背景画像設定
18
+ ======================== */
19
+ /* 背景画像コンテナ */
20
+ .background-container {
21
+ position: fixed !important;
22
  top: 0 !important;
23
  left: 0 !important;
24
  width: 100% !important;
25
  height: 100% !important;
26
+ z-index: -100 !important; /* UIの後ろに配置 */
 
 
 
27
  pointer-events: none !important;
28
  }
29
 
30
+ /* 背景画像 */
31
+ .chat-background {
 
 
 
 
 
 
32
  position: absolute !important;
33
  top: 0 !important;
34
  left: 0 !important;
35
  width: 100% !important;
36
  height: 100% !important;
37
+ background-size: cover !important;
38
+ background-position: center !important;
39
+ opacity: 0.15 !important; /* 薄く表示 */
40
+ filter: blur(1px) !important; /* 少しぼかす */
41
+ }
42
+
43
+ /* ========================
44
+ コンポーネント共通スタイル
45
+ ======================== */
46
+ /* ボックス共通スタイル */
47
+ .header-box, .chat-box, .input-box, .status-box, .footer-box {
48
+ background-color: rgba(255, 255, 255, 0.85) !important;
49
+ border-radius: 12px !important;
50
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
51
+ padding: 15px !important;
52
+ margin-bottom: 15px !important;
53
+ backdrop-filter: blur(5px) !important;
54
+ -webkit-backdrop-filter: blur(5px) !important;
55
+ border: 1px solid rgba(255, 255, 255, 0.3) !important;
56
+ }
57
+
58
+ /* ========================
59
+ ヘッダー
60
+ ======================== */
61
+ .header-box {
62
+ text-align: center !important;
63
+ }
64
+
65
+ .header-box h1 {
66
+ margin: 0 !important;
67
+ padding: 10px !important;
68
+ color: #333 !important;
69
+ }
70
+
71
+ /* ========================
72
+ チャットUI
73
+ ======================== */
74
+ /* チャットコンテナ */
75
+ .chat-box {
76
+ padding: 15px !important;
77
+ margin-bottom: 15px !important;
78
+ }
79
+
80
+ /* チャットエリア */
81
+ #chat_area {
82
+ min-height: 400px !important;
83
+ max-height: 500px !important;
84
+ overflow-y: auto !important;
85
+ padding: 10px !important;
86
+ background-color: transparent !important;
87
+ }
88
+
89
+ /* チャットメッセージ */
90
+ .message {
91
+ background-color: rgba(255, 255, 255, 0.7) !important;
92
+ border-radius: 8px !important;
93
+ padding: 10px !important;
94
+ margin-bottom: 8px !important;
95
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
96
+ }
97
+
98
+ /* ========================
99
+ 入力欄
100
+ ======================== */
101
+ .input-box {
102
+ padding: 10px !important;
103
+ }
104
+
105
+ .input-box textarea {
106
+ border-radius: 8px !important;
107
+ border: 1px solid rgba(0, 0, 0, 0.1) !important;
108
+ padding: 10px !important;
109
+ }
110
+
111
+ /* ========================
112
+ ステータス表示
113
+ ======================== */
114
+ .status-box {
115
+ padding: 15px !important;
116
+ }
117
+
118
+ /* ========================
119
+ フッター
120
+ ======================== */
121
+ .footer-box {
122
+ text-align: center !important;
123
+ padding: 10px !important;
124
+ margin-top: 20px !important;
125
  }
126
 
127
  /* ========================