NidhiS09 commited on
Commit
fd2bf81
·
verified ·
1 Parent(s): 8366892

Update challenges/home.py

Browse files
Files changed (1) hide show
  1. challenges/home.py +25 -8
challenges/home.py CHANGED
@@ -33,11 +33,12 @@ CHALLENGES = [
33
  ]
34
 
35
 
36
- def _challenge_card_html(c: dict) -> str:
37
  if c["active"]:
38
  return f"""
39
  <div style="border:2px solid #2563eb;border-radius:12px;padding:24px;
40
- background:#f0f7ff;display:flex;flex-direction:column;height:260px;box-sizing:border-box;">
 
41
  <div style="font-size:2rem;margin-bottom:8px;">{c['emoji']}</div>
42
  <h3 style="margin:0 0 6px 0;color:#1e40af;font-size:1rem;font-weight:700;">{c['title']}</h3>
43
  <p style="margin:0 0 10px 0;color:#374151;font-size:0.82rem;line-height:1.45;flex:1;">{c['description']}</p>
@@ -54,7 +55,8 @@ def _challenge_card_html(c: dict) -> str:
54
  else:
55
  return f"""
56
  <div style="border:2px solid #e5e7eb;border-radius:12px;padding:24px;
57
- background:#f9fafb;display:flex;flex-direction:column;height:260px;box-sizing:border-box;opacity:0.55;">
 
58
  <div style="font-size:2rem;margin-bottom:8px;">{c['emoji']}</div>
59
  <h3 style="margin:0 0 6px 0;color:#6b7280;font-size:1rem;font-weight:700;">{c['title']}</h3>
60
  <p style="margin:0 0 10px 0;color:#9ca3af;font-size:0.82rem;line-height:1.45;flex:1;">{c['description']}</p>
@@ -70,6 +72,23 @@ def _challenge_card_html(c: dict) -> str:
70
  </div>"""
71
 
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  def build_home(demo: gr.Blocks) -> None:
74
  with gr.Row():
75
  with gr.Column(scale=5):
@@ -87,13 +106,11 @@ def build_home(demo: gr.Blocks) -> None:
87
  gr.Markdown(
88
  "Choose a challenge to view its leaderboard, submit predictions, and track your results."
89
  )
90
- with gr.Row(equal_height=True):
91
- for c in CHALLENGES:
92
- with gr.Column(scale=1):
93
- gr.HTML(_challenge_card_html(c))
94
 
95
  gr.Markdown(
96
  "---\n*More challenges coming soon. "
97
  "All challenges use HuggingFace OAuth — log in once to access everything.*"
98
  )
99
- demo.load(get_user_greeting, outputs=[home_greeting])
 
33
  ]
34
 
35
 
36
+ def _single_card_html(c: dict) -> str:
37
  if c["active"]:
38
  return f"""
39
  <div style="border:2px solid #2563eb;border-radius:12px;padding:24px;
40
+ background:#f0f7ff;display:flex;flex-direction:column;
41
+ height:100%;box-sizing:border-box;">
42
  <div style="font-size:2rem;margin-bottom:8px;">{c['emoji']}</div>
43
  <h3 style="margin:0 0 6px 0;color:#1e40af;font-size:1rem;font-weight:700;">{c['title']}</h3>
44
  <p style="margin:0 0 10px 0;color:#374151;font-size:0.82rem;line-height:1.45;flex:1;">{c['description']}</p>
 
55
  else:
56
  return f"""
57
  <div style="border:2px solid #e5e7eb;border-radius:12px;padding:24px;
58
+ background:#f9fafb;display:flex;flex-direction:column;
59
+ height:100%;box-sizing:border-box;opacity:0.55;">
60
  <div style="font-size:2rem;margin-bottom:8px;">{c['emoji']}</div>
61
  <h3 style="margin:0 0 6px 0;color:#6b7280;font-size:1rem;font-weight:700;">{c['title']}</h3>
62
  <p style="margin:0 0 10px 0;color:#9ca3af;font-size:0.82rem;line-height:1.45;flex:1;">{c['description']}</p>
 
72
  </div>"""
73
 
74
 
75
+ def _all_cards_html(challenges: list) -> str:
76
+ cards = "".join(_single_card_html(c) for c in challenges)
77
+ return f"""
78
+ <div style="
79
+ display: grid;
80
+ grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
81
+ gap: 20px;
82
+ width: 100%;
83
+ box-sizing: border-box;
84
+ padding: 4px 0;
85
+ align-items: stretch;
86
+ ">
87
+ {cards}
88
+ </div>
89
+ """
90
+
91
+
92
  def build_home(demo: gr.Blocks) -> None:
93
  with gr.Row():
94
  with gr.Column(scale=5):
 
106
  gr.Markdown(
107
  "Choose a challenge to view its leaderboard, submit predictions, and track your results."
108
  )
109
+
110
+ gr.HTML(_all_cards_html(CHALLENGES))
 
 
111
 
112
  gr.Markdown(
113
  "---\n*More challenges coming soon. "
114
  "All challenges use HuggingFace OAuth — log in once to access everything.*"
115
  )
116
+ demo.load(get_user_greeting, outputs=[home_greeting])