Skip to content

refactor: migrate leaderboard div-based grid to semantic table (#180)#226

Open
rishab11250 wants to merge 2 commits into
codepvg:mainfrom
rishab11250:feature/semantic-table-issue180
Open

refactor: migrate leaderboard div-based grid to semantic table (#180)#226
rishab11250 wants to merge 2 commits into
codepvg:mainfrom
rishab11250:feature/semantic-table-issue180

Conversation

@rishab11250

Copy link
Copy Markdown
Contributor

Description

Migrate the leaderboard <div>-based CSS Grid layout to a semantic HTML <table> element for proper accessibility. Previously, ARIA role workarounds (PR #184) were added to the div grid as a stopgap — this change provides native table semantics instead.

Linked Issue

Fixes #180

Changes Made

  • leaderboard.html: <div class="leaderboard"><table class="leaderboard">, <div class="leaderboard-header"><thead class="leaderboard-header"><tr> with <th scope="col"> cells, <div id="leaderboard-body"><tbody id="leaderboard-body">, skeleton rows → <tr> + <td> (9 cells per row, including hidden checkbox cell)
  • render.js: renderLeaderboardRow() creates <tr>/<td> instead of <div>; empty states use <tr><td colspan="9"> for valid table structure
  • main.css: Grid display: grid / grid-template-columns replaced with display: table / table-layout: fixed / explicit th:nth-child() column widths; sticky positioning on <th>; cell alignment updated for table context; compare-mode checkbox uses table-cell instead of flex; mobile breakpoint hides the <table> itself; skeleton rows use td padding + nth-child width selectors

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally

  • Tested on mobile viewport (if applicable)

  • No console errors introduced

  • npx prettier --check . passes

  • node --check passes on render.js

  • Skeleton loading → data transition confirmed

  • Compare mode checkbox show/hide confirmed

  • Mobile card layout preserved (table hidden at 940px breakpoint)

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally by running npx prettier --write . before submitting
  • I am submitting my PR from a dedicated feature/* branch, not the main branch
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

Screenshots / Screen Recording

N/A — visual appearance is identical to the previous grid layout (same column widths, colors, spacing, hover states, sticky header, skeleton shimmer, mobile card view). No visual regression expected.

…vg#180)

Replace the CSS Grid-based leaderboard layout with a proper HTML
table + thead/tbody structure for accessibility. Add
th scope="col" and td elements with ARIA-native semantics
instead of ARIA role workarounds from PR codepvg#184.

Changes:
- leaderboard.html: div.grid -> table + thead + tbody with th/td
- render.js: createElement('tr')/('td') instead of 'div'
- main.css: grid selectors -> table-layout: fixed with explicit
  column widths, sticky thead, mobile/compare-mode adjustments
- Empty states use tr td colspan=N for valid table structure
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

Formatting and Branching

  • Please confirm you have formatted your code locally using npx prettier --write ., or you can simply comment /format on this PR to have our bot do it for you!
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

@jagdish-15 jagdish-15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Hey, did you test this locally after the migration?

There seem to be a few visual regressions compared to the current leaderboard. The Score column is no longer aligned correctly, there appears to be a lot more padding in those cells than before, and some of the header styling/colours seem to have been lost.

Could you take another look

- Reduce per-cell padding from 1.25rem to 0.3rem, use first/last-child
  for outer edge spacing (fixes excessive cell padding)
- Move header border-bottom from tr (can't render in separate collapse)
  to th elements (fixes missing header border)
- Remove display:flex from score-header th, use text-align:center
  (fixes Score column width in table-layout:fixed)
- Override justify-content:flex-end to center in .score-cell .mobile-score
  (fixes Score data cell alignment)
@rishab11250

Copy link
Copy Markdown
Contributor Author
image

@jagdish-15

Copy link
Copy Markdown
Collaborator

Looking at the screenshot you attached, there are still a couple of visual differences compared to the current leaderboard on production (codepvg.onrender.com).

The header colours seem to be missing, and the Score header is wrapping onto two lines with the tooltip icon appearing below the text.

Could you take another look at those before we merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Frontend/Accessibility] Migrate Leaderboard Grid to Semantic <table> Element

2 participants