From e4f0376af3e48875936d65e17f970479d98a6eca Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 11 Oct 2024 03:31:52 +0100 Subject: [PATCH] add weekly rank change and change the design a bit --- .../src/components/ranking/player-ranking.tsx | 20 +++++++++++++++---- .../src/components/ranking/ranking-data.tsx | 13 ++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/projects/website/src/components/ranking/player-ranking.tsx b/projects/website/src/components/ranking/player-ranking.tsx index 150adb4..50b032e 100644 --- a/projects/website/src/components/ranking/player-ranking.tsx +++ b/projects/website/src/components/ranking/player-ranking.tsx @@ -7,6 +7,7 @@ import Link from "next/link"; import useDatabase from "@/hooks/use-database"; import { useLiveQuery } from "dexie-react-hooks"; import { Avatar, AvatarImage } from "@/components/ui/avatar"; +import { clsx } from "clsx"; type PlayerRankingProps = { player: ScoreSaberPlayerToken; @@ -17,6 +18,9 @@ export function PlayerRanking({ player, isCountry }: PlayerRankingProps) { const database = useDatabase(); const settings = useLiveQuery(() => database.getSettings()); + const history = player.histories.split(",").map(Number); + const weeklyRankChange = history[history?.length - 6] - player.rank; + return ( <> @@ -41,10 +45,18 @@ export function PlayerRanking({ player, isCountry }: PlayerRankingProps) {

- {formatPp(player.pp)}pp - {formatNumberWithCommas(player.scoreStats.totalPlayCount)} - {formatNumberWithCommas(player.scoreStats.rankedPlayCount)} - {player.scoreStats.averageRankedAccuracy.toFixed(2) + "%"} + {formatPp(player.pp)}pp + {formatNumberWithCommas(player.scoreStats.totalPlayCount)} + {formatNumberWithCommas(player.scoreStats.rankedPlayCount)} + {player.scoreStats.averageRankedAccuracy.toFixed(2) + "%"} + = 0 ? weeklyRankChange != 0 && "text-green-500" : "text-red-500" + )} + > + {weeklyRankChange} + ); } diff --git a/projects/website/src/components/ranking/ranking-data.tsx b/projects/website/src/components/ranking/ranking-data.tsx index fb5deff..0718bef 100644 --- a/projects/website/src/components/ranking/ranking-data.tsx +++ b/projects/website/src/components/ranking/ranking-data.tsx @@ -84,14 +84,15 @@ export default function RankingData({ initialPage, country, initialPageData }: R Rank - Profile - Performance Points - Total Plays - Total Ranked Plays - Avg Ranked Accuracy + Player + Performance Points + Total Plays + Total Ranked Plays + Avg Ranked Accuracy + Weekly Change - + {players.map(player => (