From 2df95d140af40983653840a617cf9b8aaa076604 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 19 Oct 2024 17:29:17 +0100 Subject: [PATCH] fix tooltips --- projects/website/src/components/footer.tsx | 2 +- .../leaderboard/leaderboard-scores.tsx | 2 +- .../components/loaders/fullscreen-loader.tsx | 2 +- .../components/player/chart/player-charts.tsx | 2 +- .../src/components/player/player-header.tsx | 8 ++-- .../src/components/player/player-info.tsx | 2 +- .../src/components/player/player-scores.tsx | 2 +- .../website/src/components/ranking/mini.tsx | 2 +- .../score/score-feed/score-feed.tsx | 2 +- .../src/components/score/score-info.tsx | 4 +- .../src/components/score/score-rank-info.tsx | 2 +- .../website/src/components/ui/tooltip.tsx | 41 ++++++++++++------- 12 files changed, 43 insertions(+), 28 deletions(-) diff --git a/projects/website/src/components/footer.tsx b/projects/website/src/components/footer.tsx index 3b15016..a7afb45 100644 --- a/projects/website/src/components/footer.tsx +++ b/projects/website/src/components/footer.tsx @@ -54,7 +54,7 @@ export default function Footer() { return ( diff --git a/projects/website/src/components/leaderboard/leaderboard-scores.tsx b/projects/website/src/components/leaderboard/leaderboard-scores.tsx index 0c96bda..d172d15 100644 --- a/projects/website/src/components/leaderboard/leaderboard-scores.tsx +++ b/projects/website/src/components/leaderboard/leaderboard-scores.tsx @@ -162,7 +162,7 @@ export default function LeaderboardScores({ })} -
+
diff --git a/projects/website/src/components/loaders/fullscreen-loader.tsx b/projects/website/src/components/loaders/fullscreen-loader.tsx index e91cc0d..2fb5f3b 100644 --- a/projects/website/src/components/loaders/fullscreen-loader.tsx +++ b/projects/website/src/components/loaders/fullscreen-loader.tsx @@ -7,7 +7,7 @@ type Props = { export default function FullscreenLoader({ reason }: Props) { return ( -
+

ScoreSaber Reloaded

{reason}

diff --git a/projects/website/src/components/player/chart/player-charts.tsx b/projects/website/src/components/player/chart/player-charts.tsx index f716d71..b65227d 100644 --- a/projects/website/src/components/player/chart/player-charts.tsx +++ b/projects/website/src/components/player/chart/player-charts.tsx @@ -78,7 +78,7 @@ export default function PlayerCharts({ player }: PlayerChartsProps) { > diff --git a/projects/website/src/components/player/player-header.tsx b/projects/website/src/components/player/player-header.tsx index 9a6ea22..65ee003 100644 --- a/projects/website/src/components/player/player-header.tsx +++ b/projects/website/src/components/player/player-header.tsx @@ -110,7 +110,9 @@ const playerData = [ player, "rank", -

#{formatNumberWithCommas(player.rank)}

+

+ #{formatNumberWithCommas(player.rank)} +

)} {rankChange != 0 && renderDailyChange(rankChange,

The change in rank compared to yesterday

)} @@ -133,7 +135,7 @@ const playerData = [ player, "countryRank", -

+

#{formatNumberWithCommas(player.countryRank)}

@@ -154,7 +156,7 @@ const playerData = [ {renderChange( player, "pp", -

{formatPp(player.pp)}pp

+

{formatPp(player.pp)}pp

)} {ppChange != 0 && renderDailyChange(ppChange,

The change in pp compared to yesterday

)}
diff --git a/projects/website/src/components/player/player-info.tsx b/projects/website/src/components/player/player-info.tsx index d4ce7a6..44f7df3 100644 --- a/projects/website/src/components/player/player-info.tsx +++ b/projects/website/src/components/player/player-info.tsx @@ -33,7 +33,7 @@ export function PlayerInfo({ player, highlightedPlayer, hideCountryFlag }: Table /> {!hideCountryFlag && } - +

diff --git a/projects/website/src/components/ranking/mini.tsx b/projects/website/src/components/ranking/mini.tsx index 175236c..264ed20 100644 --- a/projects/website/src/components/ranking/mini.tsx +++ b/projects/website/src/components/ranking/mini.tsx @@ -97,7 +97,7 @@ export default function Mini({ type, player, shouldUpdate }: MiniProps) {

#{formatNumberWithCommas(rank)}

diff --git a/projects/website/src/components/score/score-feed/score-feed.tsx b/projects/website/src/components/score/score-feed/score-feed.tsx index 03abedf..6dd2f3f 100644 --- a/projects/website/src/components/score/score-feed/score-feed.tsx +++ b/projects/website/src/components/score/score-feed/score-feed.tsx @@ -47,7 +47,7 @@ export default function ScoreFeed() {

Set by{" "} - {player.name} + {player.name}

{leaderboard.songName} {leaderboard.songSubName} @@ -67,7 +67,7 @@ export default function ScoreSongInfo({ leaderboard, beatSaverMap }: Props) {

{leaderboard.songAuthorName}

{leaderboard.levelAuthorName} diff --git a/projects/website/src/components/score/score-rank-info.tsx b/projects/website/src/components/score/score-rank-info.tsx index a58542d..58b7022 100644 --- a/projects/website/src/components/score/score-rank-info.tsx +++ b/projects/website/src/components/score/score-rank-info.tsx @@ -17,7 +17,7 @@ export default function ScoreRankInfo({ score, leaderboard }: Props) {
-

+

#{formatNumberWithCommas(score.rank)}

diff --git a/projects/website/src/components/ui/tooltip.tsx b/projects/website/src/components/ui/tooltip.tsx index 3cfde27..a494702 100644 --- a/projects/website/src/components/ui/tooltip.tsx +++ b/projects/website/src/components/ui/tooltip.tsx @@ -2,29 +2,42 @@ import * as TooltipPrimitive from "@radix-ui/react-tooltip"; import * as React from "react"; - +import { useEffect, useState } from "react"; import { cn } from "@/common/utils"; +import ReactDOM from "react-dom"; const TooltipProvider = TooltipPrimitive.Provider; - const Tooltip = TooltipPrimitive.Root; - const TooltipTrigger = TooltipPrimitive.Trigger; const TooltipContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, sideOffset = 4, ...props }, ref) => ( - -)); +>(({ className, sideOffset = 4, ...props }, ref) => { + const [mounted, setMounted] = useState(false); + + // Ensure the tooltip is rendered after the component has mounted + useEffect(() => { + setMounted(true); + }, []); + + // If mounted, render the tooltip using React Portal + return mounted + ? ReactDOM.createPortal( + , + document.body // Render the tooltip outside the table and its overflow + ) + : null; +}); + TooltipContent.displayName = TooltipPrimitive.Content.displayName; export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };