Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -461,36 +461,40 @@ CHALLENGES = [
|
|
| 461 |
|
| 462 |
|
| 463 |
def _challenge_card_html(c: dict) -> str:
|
| 464 |
-
"""
|
| 465 |
if c["active"]:
|
| 466 |
return f"""
|
| 467 |
<div style="border:2px solid #2563eb;border-radius:12px;padding:24px;
|
| 468 |
-
background:#f0f7ff;height:
|
| 469 |
-
<div style="font-size:
|
| 470 |
-
<h3 style="margin:0 0
|
| 471 |
-
<p style="margin:0 0
|
| 472 |
-
<div style="background:#dbeafe;border-radius:
|
| 473 |
-
font-size:0.
|
| 474 |
π {c['metrics']}
|
| 475 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 476 |
</div>"""
|
| 477 |
else:
|
| 478 |
return f"""
|
| 479 |
<div style="border:2px solid #e5e7eb;border-radius:12px;padding:24px;
|
| 480 |
-
background:#f9fafb;
|
| 481 |
-
<div style="font-size:
|
| 482 |
-
<h3 style="margin:0 0
|
| 483 |
-
<p style="margin:0 0
|
| 484 |
-
<div style="background:#f3f4f6;border-radius:
|
| 485 |
-
font-size:0.
|
| 486 |
π {c['metrics']}
|
| 487 |
</div>
|
| 488 |
-
<
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
</div>
|
| 494 |
</div>"""
|
| 495 |
|
| 496 |
|
|
@@ -519,11 +523,8 @@ with gr.Blocks() as demo:
|
|
| 519 |
)
|
| 520 |
with gr.Row(equal_height=True):
|
| 521 |
for c in CHALLENGES:
|
| 522 |
-
with gr.Column():
|
| 523 |
gr.HTML(_challenge_card_html(c))
|
| 524 |
-
if c["active"]:
|
| 525 |
-
btn = gr.Button(f"Enter {c['title']} β", variant="primary", size="sm")
|
| 526 |
-
btn.click(None, js=f"() => {{ window.location.href = '{c['route']}'; }}")
|
| 527 |
|
| 528 |
gr.Markdown(
|
| 529 |
"---\n*More challenges coming soon. "
|
|
|
|
| 461 |
|
| 462 |
|
| 463 |
def _challenge_card_html(c: dict) -> str:
|
| 464 |
+
"""Single self-contained card with button inside the HTML."""
|
| 465 |
if c["active"]:
|
| 466 |
return f"""
|
| 467 |
<div style="border:2px solid #2563eb;border-radius:12px;padding:24px;
|
| 468 |
+
background:#f0f7ff;display:flex;flex-direction:column;height:260px;box-sizing:border-box;">
|
| 469 |
+
<div style="font-size:2rem;margin-bottom:8px;">{c['emoji']}</div>
|
| 470 |
+
<h3 style="margin:0 0 6px 0;color:#1e40af;font-size:1rem;font-weight:700;">{c['title']}</h3>
|
| 471 |
+
<p style="margin:0 0 10px 0;color:#374151;font-size:0.82rem;line-height:1.45;flex:1;">{c['description']}</p>
|
| 472 |
+
<div style="background:#dbeafe;border-radius:5px;padding:4px 8px;
|
| 473 |
+
font-size:0.72rem;color:#1d4ed8;font-family:monospace;margin-bottom:14px;">
|
| 474 |
π {c['metrics']}
|
| 475 |
</div>
|
| 476 |
+
<button onclick="window.location.href='{c['route']}'"
|
| 477 |
+
style="background:#2563eb;color:white;border:none;padding:8px 0;width:100%;
|
| 478 |
+
border-radius:7px;font-size:0.85rem;font-weight:600;cursor:pointer;">
|
| 479 |
+
Enter Challenge β
|
| 480 |
+
</button>
|
| 481 |
</div>"""
|
| 482 |
else:
|
| 483 |
return f"""
|
| 484 |
<div style="border:2px solid #e5e7eb;border-radius:12px;padding:24px;
|
| 485 |
+
background:#f9fafb;display:flex;flex-direction:column;height:260px;box-sizing:border-box;opacity:0.55;">
|
| 486 |
+
<div style="font-size:2rem;margin-bottom:8px;">{c['emoji']}</div>
|
| 487 |
+
<h3 style="margin:0 0 6px 0;color:#6b7280;font-size:1rem;font-weight:700;">{c['title']}</h3>
|
| 488 |
+
<p style="margin:0 0 10px 0;color:#9ca3af;font-size:0.82rem;line-height:1.45;flex:1;">{c['description']}</p>
|
| 489 |
+
<div style="background:#f3f4f6;border-radius:5px;padding:4px 8px;
|
| 490 |
+
font-size:0.72rem;color:#9ca3af;font-family:monospace;margin-bottom:14px;">
|
| 491 |
π {c['metrics']}
|
| 492 |
</div>
|
| 493 |
+
<button disabled
|
| 494 |
+
style="background:#e5e7eb;color:#9ca3af;border:none;padding:8px 0;width:100%;
|
| 495 |
+
border-radius:7px;font-size:0.85rem;font-weight:600;cursor:not-allowed;">
|
| 496 |
+
π Coming Soon
|
| 497 |
+
</button>
|
|
|
|
| 498 |
</div>"""
|
| 499 |
|
| 500 |
|
|
|
|
| 523 |
)
|
| 524 |
with gr.Row(equal_height=True):
|
| 525 |
for c in CHALLENGES:
|
| 526 |
+
with gr.Column(scale=1):
|
| 527 |
gr.HTML(_challenge_card_html(c))
|
|
|
|
|
|
|
|
|
|
| 528 |
|
| 529 |
gr.Markdown(
|
| 530 |
"---\n*More challenges coming soon. "
|