Skip to content

Conversation

@Ammaar-Alam
Copy link
Member

Summary

  • surface each title’s unlock criteria in both the leaderboard and profile modal
  • display the criteria via a tooltip that appears when hovering the equipped title badge

Implementation Notes

  • reuse existing title fetch data and render the description inside a .title-tooltip
  • position the tooltip using the element’s viewport bounds so it appears just below the badge
  • add lightweight CSS utilities to handle visibility, layering, and overflow for the new tooltip

Copilot AI review requested due to automatic review settings November 2, 2025 20:30
@Ammaar-Alam Ammaar-Alam merged commit 9763cf1 into master Nov 2, 2025
2 checks passed
@Ammaar-Alam Ammaar-Alam deleted the feature/title-hover branch November 2, 2025 20:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds tooltip functionality to display title descriptions when users hover over equipped titles in both the Leaderboard and ProfileModal components. The implementation uses fixed positioning with JavaScript to dynamically calculate tooltip placement.

  • Tooltip support added for title badges on hover
  • Manual tooltip positioning implemented via onMouseEnter handlers
  • CSS styling added for tooltips with consistent theming across components

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
client/src/components/ProfileModal.jsx Refactored title display logic to show tooltips with descriptions when hovering over equipped titles
client/src/components/ProfileModal.css Added CSS styles for title tooltips with fixed positioning and hover effects
client/src/components/Leaderboard.jsx Added tooltip functionality to leaderboard title badges
client/src/components/Leaderboard.css Added shared tooltip styles and overflow-x visibility for tooltips

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +762 to +782
(() => {
const equippedTitle = userTitles.find(t => String(t.id) === String(displayUser.selected_title_id));
return (
<span
className="displayed-title-name title-with-tooltip"
onMouseEnter={(e) => {
const tooltip = e.currentTarget.querySelector('.title-tooltip');
if (tooltip) {
const rect = e.currentTarget.getBoundingClientRect();
tooltip.style.top = `${rect.bottom + 8}px`;
tooltip.style.left = `${rect.left}px`;
}
}}
>
{equippedTitle.name}
{equippedTitle.description && (
<span className="title-tooltip">{equippedTitle.description}</span>
)}
</span>
);
})()
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

This tooltip positioning logic is duplicated three times across ProfileModal.jsx and Leaderboard.jsx. Consider extracting it into a reusable component or custom hook (e.g., TitleWithTooltip) to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines +767 to +774
onMouseEnter={(e) => {
const tooltip = e.currentTarget.querySelector('.title-tooltip');
if (tooltip) {
const rect = e.currentTarget.getBoundingClientRect();
tooltip.style.top = `${rect.bottom + 8}px`;
tooltip.style.left = `${rect.left}px`;
}
}}
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The tooltip positioning logic runs on every mouse enter event. When the tooltip is hidden (visibility: hidden in CSS), getBoundingClientRect() still triggers a layout recalculation. Consider debouncing or using CSS-only positioning if possible to avoid unnecessary layout calculations on hover.

Copilot uses AI. Check for mistakes.
width: 100%;
flex-grow: 1;
overflow-y: auto;
overflow-x: visible;
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

Setting overflow-x to visible while overflow-y is auto (line 61) can cause unexpected behavior in some browsers, as they may force both overflow properties to the same value. Consider using a wrapper element for the tooltip or alternative positioning strategies to avoid potential cross-browser issues.

Copilot uses AI. Check for mistakes.
line-height: 1.4;
white-space: normal;
word-wrap: break-word;
transform: translateY(8px);
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The tooltip in Leaderboard.css uses transform: translateY(8px) (line 205) while ProfileModal.css tooltips don't use this transform property, despite both positioning tooltips 8px below the element. This inconsistency means tooltips appear slightly different between components. Consider standardizing the approach.

Suggested change
transform: translateY(8px);

Copilot uses AI. Check for mistakes.
Ammaar-Alam added a commit that referenced this pull request Nov 7, 2025
adding setup instructions in readme
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.

2 participants