fix(explore): keep leaderboard rank cell aligned across emoji and numeric ranks (closes #320)#490
Conversation
…eric ranks (closes PRODHOSH#320)
Welcome to OSSfolio, @SakethSumanBathini! 🎉Thank you for opening this pull request and contributing to the open-source community! 🚀 To ensure a smooth review process, please make sure you have:
We will review your PR as soon as possible. Happy coding! 💻✨ |
📝 WalkthroughWalkthroughThe explore leaderboard keeps its existing avatar fallback logic and updates rank indicator styling to use an inline-flex centered layout with explicit line height. ChangesLeaderboard UI
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes the vertical alignment of the leaderboard rank cell (#320). Worth flagging up front that the issue's
details didn't match the code, so this targets a different file than the one named — I've explained the
reasoning on the issue as well.
src/components/LeaderboardTable.tsxdoesn't exist; the leaderboard issrc/app/explore/page.tsx(the"Leaderboard" nav link points at
/explore).alignItems: "center", so the change the issue describes wasalready in place.
What does cause an offset on some rows: the rank cell renders 🥇🥈🥉 for ranks 1-3 and plain digits for
the rest. Emoji resolve to a colour-emoji font whose vertical metrics differ from the body font, so the
rank span's line box isn't the same height on the top-3 rows as on the others. The score span directly
below already guards against this with
lineHeight: 1; the rank span didn't.Related Issue
Closes #320
Type of Change
Changes Made
src/app/explore/page.tsx— the rank cell now centres its glyph in a deterministic box:display: inline-flexwithalignItems/justifyContent: centerandlineHeight: 1, so the renderedcharacter sits in the same place whichever font supplies it.
textAlign: "center"was dropped in thesame edit because it has no effect on a flex container;
justifyContentreplaces it.// Replace line 171 with this:comment and re-indented theconst avatarline, which had been committed at column 0. Small, but it's inside the block this PRtouches.
AI Usage
Used Claude. On side effects: switching the rank span to
inline-flexmeans its children are flex items,which is why
textAlignwas replaced rather than kept.minWidth: 32pxandflexShrink: 0are unchanged,so the column width and the row layout are the same as before.
Screenshots (if UI change)
Rank cell, avatar, name, and score all sit on a consistent centre line. Note the mock ships two fixtures,
so both visible ranks are medal emoji — the digit-rank case isn't exercised by the default fixtures.
Checklist
mainconsole.logleft insrc/schema.sqland a new migration file are includedDESIGN.mdand followed the design system (colors, spacing, typography, components)Summary by CodeRabbit