Davichick commited on
Commit
fe55fe7
Β·
verified Β·
1 Parent(s): b4ccf11

feat: centered logo, idle/loading ring animations, hidden Gradio timer

Browse files
Files changed (1) hide show
  1. app.py +94 -3
app.py CHANGED
@@ -477,6 +477,26 @@ button.secondary:hover { background: rgba(20,184,166,0.08) !important; }
477
  .main-row {
478
  align-items: stretch !important;
479
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  """
481
 
482
  theme = gr.themes.Default(
@@ -543,11 +563,75 @@ SECTION_HEADER = (
543
  'font-family:Inter,sans-serif; margin:0 0 14px 0;'
544
  )
545
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  with gr.Blocks() as app:
547
 
548
  # ── Top header bar ──────────────────────────────────────────
549
  gr.HTML(f"""
550
- <div style="display:flex; align-items:center; padding:14px 24px 10px 24px; background:#0d1117;">
 
551
  {logo_tag}
552
  </div>
553
  <div style="width:100%; height:1px; background:rgba(255,255,255,0.08);"></div>
@@ -602,7 +686,7 @@ with gr.Blocks() as app:
602
  # ─── RIGHT COLUMN ────────────────────────────────────────
603
  with gr.Column(scale=2, elem_classes="right-col"):
604
  with gr.Group(elem_classes="right-card"):
605
- score_circle = gr.HTML(value="")
606
  with gr.Column(elem_classes="feedback-grow"):
607
  feedback_display = gr.HTML(value="")
608
 
@@ -617,10 +701,17 @@ with gr.Blocks() as app:
617
  inputs=[role_dropdown, sector_dropdown, question_display],
618
  outputs=[question_display, user_answer, score_circle, feedback_display]
619
  )
 
620
  submit_btn.click(
 
 
 
 
 
621
  fn=evaluate_and_format,
622
  inputs=[question_display, user_answer, role_dropdown, sector_dropdown, interviewer_dropdown, level_dropdown],
623
- outputs=[score_circle, feedback_display]
 
624
  )
625
 
626
  # Quick Starters
 
477
  .main-row {
478
  align-items: stretch !important;
479
  }
480
+
481
+ /* ── Hide Gradio's default timer / progress bar ────── */
482
+ .progress-text, .progress-level, .eta-bar,
483
+ .generating, .progress-bar-wrap, .progress-bar,
484
+ .wrap.generating > .progress-container,
485
+ svg.progress-circle { display: none !important; }
486
+
487
+ /* ── Right panel idle & loading animations ──────────── */
488
+ @keyframes if-spin {
489
+ 0% { transform: rotate(0deg); }
490
+ 100% { transform: rotate(360deg); }
491
+ }
492
+ @keyframes if-pulse {
493
+ 0%, 100% { opacity: 0.35; transform: scale(0.97); }
494
+ 50% { opacity: 1; transform: scale(1.03); }
495
+ }
496
+ @keyframes if-breathe {
497
+ 0%, 100% { opacity: 0.5; }
498
+ 50% { opacity: 1; }
499
+ }
500
  """
501
 
502
  theme = gr.themes.Default(
 
563
  'font-family:Inter,sans-serif; margin:0 0 14px 0;'
564
  )
565
 
566
+ # ── Right-panel state HTML ──────────────────────────────────────────
567
+ IDLE_HTML = """
568
+ <div style="display:flex;flex-direction:column;align-items:center;
569
+ justify-content:center;padding:48px 16px;">
570
+ <svg width="120" height="120" viewBox="0 0 120 120">
571
+ <circle cx="60" cy="60" r="48" fill="none" stroke="#21262d" stroke-width="5"/>
572
+ <circle cx="60" cy="60" r="48" fill="none" stroke="#14b8a6" stroke-width="5"
573
+ stroke-dasharray="50 250" stroke-linecap="round" opacity="0.25"
574
+ style="animation:if-breathe 3s ease-in-out infinite;"/>
575
+ <text x="60" y="55" text-anchor="middle" fill="#6b7280"
576
+ font-family="Inter,sans-serif" font-size="11" font-weight="600"
577
+ letter-spacing="1">YOUR</text>
578
+ <text x="60" y="72" text-anchor="middle" fill="#6b7280"
579
+ font-family="Inter,sans-serif" font-size="11" font-weight="600"
580
+ letter-spacing="1">SCORE</text>
581
+ </svg>
582
+ <p style="color:#6b7280;font-size:0.82em;margin-top:18px;text-align:center;
583
+ font-family:Inter,sans-serif;line-height:1.5;">
584
+ Submit your answer to receive<br/>AI feedback and your score
585
+ </p>
586
+ </div>
587
+ """
588
+
589
+ LOADING_HTML = """
590
+ <div style="display:flex;flex-direction:column;align-items:center;
591
+ justify-content:center;padding:48px 16px;">
592
+ <div style="position:relative;width:120px;height:120px;">
593
+ <!-- Track ring -->
594
+ <svg width="120" height="120" viewBox="0 0 120 120"
595
+ style="position:absolute;top:0;left:0;">
596
+ <circle cx="60" cy="60" r="48" fill="none" stroke="#21262d" stroke-width="5"/>
597
+ </svg>
598
+ <!-- Spinning arc -->
599
+ <svg width="120" height="120" viewBox="0 0 120 120"
600
+ style="position:absolute;top:0;left:0;
601
+ animation:if-spin 1.2s linear infinite;">
602
+ <circle cx="60" cy="60" r="48" fill="none"
603
+ stroke="url(#teal-grad)" stroke-width="5"
604
+ stroke-dasharray="80 220" stroke-linecap="round"/>
605
+ <defs>
606
+ <linearGradient id="teal-grad" x1="0%" y1="0%" x2="100%" y2="100%">
607
+ <stop offset="0%" stop-color="#0d9488"/>
608
+ <stop offset="100%" stop-color="#14b8a6"/>
609
+ </linearGradient>
610
+ </defs>
611
+ </svg>
612
+ <!-- Center dot pulse -->
613
+ <div style="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);
614
+ width:14px;height:14px;border-radius:50%;background:#14b8a6;
615
+ animation:if-pulse 1.2s ease-in-out infinite;"></div>
616
+ </div>
617
+ <p style="color:#14b8a6;font-size:0.88em;margin-top:20px;text-align:center;
618
+ font-family:Inter,sans-serif;font-weight:600;letter-spacing:0.04em;
619
+ animation:if-breathe 1.8s ease-in-out infinite;">
620
+ Analyzing your answer...
621
+ </p>
622
+ </div>
623
+ """
624
+
625
+ def show_loading():
626
+ """Instantly returns loading animation β€” shown while evaluate_and_format runs."""
627
+ return LOADING_HTML, ""
628
+
629
  with gr.Blocks() as app:
630
 
631
  # ── Top header bar ──────────────────────────────────────────
632
  gr.HTML(f"""
633
+ <div style="display:flex; align-items:center; justify-content:center;
634
+ padding:18px 24px 14px 24px; background:#0d1117;">
635
  {logo_tag}
636
  </div>
637
  <div style="width:100%; height:1px; background:rgba(255,255,255,0.08);"></div>
 
686
  # ─── RIGHT COLUMN ────────────────────────────────────────
687
  with gr.Column(scale=2, elem_classes="right-col"):
688
  with gr.Group(elem_classes="right-card"):
689
+ score_circle = gr.HTML(value=IDLE_HTML)
690
  with gr.Column(elem_classes="feedback-grow"):
691
  feedback_display = gr.HTML(value="")
692
 
 
701
  inputs=[role_dropdown, sector_dropdown, question_display],
702
  outputs=[question_display, user_answer, score_circle, feedback_display]
703
  )
704
+ # Submit: instantly show loading animation, THEN run the model
705
  submit_btn.click(
706
+ fn=show_loading,
707
+ inputs=[],
708
+ outputs=[score_circle, feedback_display],
709
+ show_progress="hidden"
710
+ ).then(
711
  fn=evaluate_and_format,
712
  inputs=[question_display, user_answer, role_dropdown, sector_dropdown, interviewer_dropdown, level_dropdown],
713
+ outputs=[score_circle, feedback_display],
714
+ show_progress="hidden"
715
  )
716
 
717
  # Quick Starters