NidhiS09 commited on
Commit
4204abf
Β·
verified Β·
1 Parent(s): c890e5c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +24 -23
main.py CHANGED
@@ -461,36 +461,40 @@ CHALLENGES = [
461
 
462
 
463
  def _challenge_card_html(c: dict) -> str:
464
- """Return HTML for a single challenge card (no navigation button β€” use gr.Button instead)."""
465
  if c["active"]:
466
  return f"""
467
  <div style="border:2px solid #2563eb;border-radius:12px;padding:24px;
468
- background:#f0f7ff;height:100%;">
469
- <div style="font-size:2.2rem;margin-bottom:8px;">{c['emoji']}</div>
470
- <h3 style="margin:0 0 8px 0;color:#1e40af;font-size:1.05rem;">{c['title']}</h3>
471
- <p style="margin:0 0 12px 0;color:#374151;font-size:0.88rem;line-height:1.5;">{c['description']}</p>
472
- <div style="background:#dbeafe;border-radius:6px;padding:5px 10px;
473
- font-size:0.75rem;color:#1d4ed8;font-family:monospace;">
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;opacity:0.6;height:100%;">
481
- <div style="font-size:2.2rem;margin-bottom:8px;">{c['emoji']}</div>
482
- <h3 style="margin:0 0 8px 0;color:#6b7280;font-size:1.05rem;">{c['title']}</h3>
483
- <p style="margin:0 0 12px 0;color:#9ca3af;font-size:0.88rem;line-height:1.5;">{c['description']}</p>
484
- <div style="background:#f3f4f6;border-radius:6px;padding:5px 10px;
485
- font-size:0.75rem;color:#9ca3af;font-family:monospace;">
486
  πŸ“Š {c['metrics']}
487
  </div>
488
- <div style="margin-top:14px;">
489
- <span style="background:#e5e7eb;color:#6b7280;padding:7px 16px;
490
- border-radius:6px;font-size:0.85rem;font-weight:600;">
491
- πŸ”’ Coming Soon
492
- </span>
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. "