DawnC commited on
Commit
6d18288
1 Parent(s): b928cc8

Update breed_recommendation.py

Browse files
Files changed (1) hide show
  1. breed_recommendation.py +42 -31
breed_recommendation.py CHANGED
@@ -11,32 +11,33 @@ from search_history import create_history_tab, create_history_component
11
  def create_custom_button_style():
12
  return """
13
  <style>
14
- #find-match-btn {
15
- background: linear-gradient(90deg, #ff5f6d 0%, #ffc371 100%);
16
- border: none;
17
- border-radius: 30px;
18
- padding: 12px 24px;
19
- color: white;
20
- font-weight: bold;
21
- cursor: pointer;
22
- transition: all 0.3s ease;
23
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
24
- width: 100%;
25
- margin: 20px 0;
26
- font-size: 1.1em;
27
- position: relative;
28
- overflow: hidden;
29
  }
30
- #find-match-btn:hover {
31
- background: linear-gradient(90deg, #ff4f5d 0%, #ffb361 100%);
32
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
33
- transform: translateY(-2px);
34
- letter-spacing: 0.5px; /* 文字間距略微增加 */
35
  }
36
- #find-match-btn:active {
37
- transform: translateY(1px);
38
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
 
39
  }
 
40
  #search-status {
41
  text-align: center;
42
  padding: 15px;
@@ -46,6 +47,12 @@ def create_custom_button_style():
46
  border-radius: 8px;
47
  background: rgba(255, 95, 109, 0.1);
48
  }
 
 
 
 
 
 
49
  </style>
50
  """
51
 
@@ -203,17 +210,17 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
203
  )
204
  gr.HTML(create_custom_button_style())
205
 
 
 
 
 
 
206
  search_status = gr.HTML(
207
  '<div id="search-status">🔍 Sniffing out your perfect furry companion...</div>',
208
  visible=False,
209
  elem_id="search-status-container"
210
  )
211
 
212
- get_recommendations_btn = gr.Button(
213
- "Find My Perfect Match! 🔍",
214
- elem_id="find-match-btn" # 添加自定義ID
215
- )
216
-
217
  recommendation_output = gr.HTML(
218
  label="Breed Recommendations",
219
  visible=True, # 確保可見性
@@ -273,7 +280,7 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
273
 
274
  return [
275
  format_recommendation_html(recommendations, is_description_search=False),
276
- gr.update(visible=True)
277
  ]
278
 
279
  except Exception as e:
@@ -285,10 +292,14 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
285
  def update_status_and_process(*args):
286
  return [
287
  "", # 清空現有結果
288
- gr.HTML.update(visible=True) # 顯示載入狀態
289
  ]
290
-
291
  get_recommendations_btn.click(
 
 
 
 
292
  fn=on_find_match_click,
293
  inputs=[
294
  living_space,
 
11
  def create_custom_button_style():
12
  return """
13
  <style>
14
+ /* 確保選擇器精確匹配 */
15
+ button#find-match-btn {
16
+ background: linear-gradient(90deg, #ff5f6d 0%, #ffc371 100%) !important;
17
+ border: none !important;
18
+ border-radius: 30px !important;
19
+ padding: 12px 24px !important;
20
+ color: white !important;
21
+ font-weight: bold !important;
22
+ cursor: pointer !important;
23
+ transition: all 0.3s ease !important;
24
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
25
+ width: 100% !important;
26
+ margin: 20px 0 !important;
27
+ font-size: 1.1em !important;
 
28
  }
29
+
30
+ button#find-match-btn:hover {
31
+ background: linear-gradient(90deg, #ff4f5d 0%, #ffb361 100%) !important;
32
+ box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2) !important;
33
+ transform: translateY(-2px) !important;
34
  }
35
+
36
+ button#find-match-btn:active {
37
+ transform: translateY(1px) !important;
38
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
39
  }
40
+
41
  #search-status {
42
  text-align: center;
43
  padding: 15px;
 
47
  border-radius: 8px;
48
  background: rgba(255, 95, 109, 0.1);
49
  }
50
+
51
+ /* 強制覆蓋任何其他樣式 */
52
+ .gradio-button {
53
+ position: relative !important;
54
+ overflow: visible !important;
55
+ }
56
  </style>
57
  """
58
 
 
210
  )
211
  gr.HTML(create_custom_button_style())
212
 
213
+ get_recommendations_btn = gr.Button(
214
+ "Find My Perfect Match! 🔍",
215
+ elem_id="find-match-btn"
216
+ )
217
+
218
  search_status = gr.HTML(
219
  '<div id="search-status">🔍 Sniffing out your perfect furry companion...</div>',
220
  visible=False,
221
  elem_id="search-status-container"
222
  )
223
 
 
 
 
 
 
224
  recommendation_output = gr.HTML(
225
  label="Breed Recommendations",
226
  visible=True, # 確保可見性
 
280
 
281
  return [
282
  format_recommendation_html(recommendations, is_description_search=False),
283
+ gr.update(visible=False)
284
  ]
285
 
286
  except Exception as e:
 
292
  def update_status_and_process(*args):
293
  return [
294
  "", # 清空現有結果
295
+ gr.update(visible=True)
296
  ]
297
+
298
  get_recommendations_btn.click(
299
+ fn=update_status_and_process, # 先執行狀態更新
300
+ outputs=[recommendation_output, search_status],
301
+ queue=False # 確保狀態更新立即執行
302
+ ).then( # 然後執行主要處理邏輯
303
  fn=on_find_match_click,
304
  inputs=[
305
  living_space,