From 9b549f8dc6014c5fe422f62f379cc3bdbfaef11e Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 19 Oct 2024 17:45:02 +0100 Subject: [PATCH] cleanup --- .../leaderboard/leaderboard-score.tsx | 9 ++---- .../src/components/score/score-modifiers.tsx | 30 +++++++++++++++++++ .../src/components/score/score-stats.tsx | 13 ++------ 3 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 projects/website/src/components/score/score-modifiers.tsx diff --git a/projects/website/src/components/leaderboard/leaderboard-score.tsx b/projects/website/src/components/leaderboard/leaderboard-score.tsx index bf121e3..067bf67 100644 --- a/projects/website/src/components/leaderboard/leaderboard-score.tsx +++ b/projects/website/src/components/leaderboard/leaderboard-score.tsx @@ -3,9 +3,9 @@ import { formatNumberWithCommas, formatPp } from "@ssr/common/utils/number-utils import ScoreSaberPlayerToken from "@ssr/common/types/token/scoresaber/score-saber-player-token"; import { PlayerInfo } from "@/components/player/player-info"; import { clsx } from "clsx"; -import { Modifier } from "@ssr/common/score/modifier"; import Tooltip from "@/components/tooltip"; import { ScoreTimeSet } from "@/components/score/score-time-set"; +import { ScoreModifiers } from "@/components/score/score-modifiers"; type Props = { /** @@ -62,15 +62,12 @@ export default function LeaderboardScore({ score, claimedPlayer }: Props) { display={

Modifiers

-

{score.modifiers.join(", ")}

+
} >

- {Object.entries(Modifier) - .filter(mod => score.modifiers.includes(mod[1] as Modifier)) - .map(mod => mod[0]) - .join(",")} +

diff --git a/projects/website/src/components/score/score-modifiers.tsx b/projects/website/src/components/score/score-modifiers.tsx new file mode 100644 index 0000000..eba45ba --- /dev/null +++ b/projects/website/src/components/score/score-modifiers.tsx @@ -0,0 +1,30 @@ +import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score"; +import { Modifier } from "@ssr/common/score/modifier"; + +type ScoreModifiersProps = { + /** + * The score to get the modifiers from + */ + score: ScoreSaberScore; + + /** + * The way to display the modifiers + */ + type: "full" | "simple"; +}; + +export function ScoreModifiers({ score, type }: ScoreModifiersProps) { + switch (type) { + case "full": + return {score.modifiers.join(", ")}; + case "simple": + return ( + + {Object.entries(Modifier) + .filter(mod => score.modifiers.includes(mod[1] as Modifier)) + .map(mod => mod[0]) + .join(",")} + + ); + } +} diff --git a/projects/website/src/components/score/score-stats.tsx b/projects/website/src/components/score/score-stats.tsx index 6eb92b7..6475b6b 100644 --- a/projects/website/src/components/score/score-stats.tsx +++ b/projects/website/src/components/score/score-stats.tsx @@ -6,6 +6,7 @@ import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score"; import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard"; import FullComboBadge from "@/components/score/badges/full-combo"; import { Modifier } from "@ssr/common/score/modifier"; +import { ScoreModifiers } from "@/components/score/score-modifiers"; const badges: ScoreBadge[] = [ { @@ -71,22 +72,14 @@ const badges: ScoreBadge[] = [ {modCount > 0 && (

Modifiers

-

{score.modifiers.join(", ")}

+
)} } >

- {acc.toFixed(2)}% - {modCount > 0 - ? ` ${ - Object.entries(Modifier) - .filter(mod => score.modifiers.includes(mod[1] as Modifier)) - .map(mod => mod[0]) - .slice(0, 1)[0] - }` - : ""} + {acc.toFixed(2)}% {modCount > 0 && }