Skip to content

[Frontend] Add Loading Skeleton & Error States to Leaderboard UI #179

@rishab11250

Description

@rishab11250

Description

When a user visits the leaderboard page (frontend/leaderboard.html), the page currently renders an empty white screen while data is being fetched from the LeetCode API. If the fetch fails (network issue, API rate limit, server error), the page remains blank forever with no indication to the user that something went wrong or that they can retry.

This creates a poor user experience — visitors have no feedback about the page state and may assume the site is broken.


Proposed Solution

Phase 1 — Loading State (Skeleton UI)

  1. In frontend/leaderboard.html, add skeleton placeholder rows inside the leaderboard container (10 animated shimmer rows).
  2. In frontend/css/main.css, add .skeleton class with a CSS shimmer animation (@keyframes shimmer using background: linear-gradient + background-size + translateX).
  3. In frontend/js/render.js, show skeleton on page load and hide it when renderLeaderboard() completes.

Phase 2 — Error State

  1. In frontend/leaderboard.html, add a hidden error banner element with: an error icon, "Failed to load leaderboard" message, and a "Retry" button.
  2. In frontend/js/render.js, wrap the fetch call in try/catch. On failure, hide the skeleton and show the error banner.
  3. Wire the "Retry" button to re-trigger the initial data fetch.

Phase 3 — Empty State

  1. If the API returns an empty array, show a "No leaderboard data yet" message instead of an empty table.

Acceptance Criteria

  • Skeleton shimmer rows appear immediately on page load.
  • Skeleton disappears gracefully once data is rendered (fade-out transition).
  • Error banner with "Retry" button appears when fetch fails.
  • Retry button re-fetches data and restores the loading/rendered state.
  • Empty state message is shown when no data exists.
  • All states work on both desktop and mobile viewports.
  • Existing leaderboard functionality is unaffected.

Affected Files

  • frontend/leaderboard.html
  • frontend/css/main.css
  • frontend/js/render.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions