diff --git a/src/components/player/score/score-stats.tsx b/src/components/player/score/score-stats.tsx index ea9a66b..d8e6780 100644 --- a/src/components/player/score/score-stats.tsx +++ b/src/components/player/score/score-stats.tsx @@ -13,7 +13,7 @@ const stats = [ if (pp === 0) { return undefined; } - return ; + return `${score.pp.toFixed(2)}pp`; }, }, { @@ -21,14 +21,14 @@ const stats = [ create: (playerScore: ScoreSaberPlayerScore) => { const { score, leaderboard } = playerScore; const acc = (score.baseScore / leaderboard.maxScore) * 100; - return ; + return `${acc.toFixed(2)}%`; }, }, { name: "Score", create: (playerScore: ScoreSaberPlayerScore) => { const { score } = playerScore; - return ; + return `${formatNumberWithCommas(score.baseScore)}`; }, }, { @@ -38,14 +38,10 @@ const stats = [ const fullCombo = score.missedNotes === 0; return ( - -

{fullCombo ? "FC" : formatNumberWithCommas(score.missedNotes)}

- - - } - /> + <> +

{fullCombo ? "FC" : formatNumberWithCommas(score.missedNotes)}

+ + ); }, }, @@ -58,31 +54,31 @@ type Props = { export default function ScoreStats({ playerScore }: Props) { const itemsPerRow = 3; const totalStats = stats.length; - const remainingItems = totalStats % itemsPerRow; - const emptySpaces = remainingItems > 0 ? itemsPerRow - remainingItems : 0; + const numRows = Math.ceil(totalStats / itemsPerRow); return (
- {/* Render all but the last row of stats normally */} - {stats.slice(0, totalStats - remainingItems).map((stat) => ( -
- {stat.create(playerScore)} -
- ))} + {Array.from({ length: numRows }).map((_, rowIndex) => { + const startIndex = rowIndex * itemsPerRow; + const endIndex = startIndex + itemsPerRow; + const rowStats = stats.slice(startIndex, endIndex); + const emptySpaces = itemsPerRow - rowStats.length; - {/* Handle the last row - align right and push empty spaces to the left */} -
- {Array(emptySpaces) - .fill(null) - .map((_, index) => ( -
- ))} - {stats.slice(totalStats - remainingItems).map((stat) => ( -
- {stat.create(playerScore)} + return ( +
+ {rowIndex === numRows - 1 && + emptySpaces > 0 && + Array(emptySpaces) + .fill(null) + .map((_, index) =>
)} + {rowStats.map((stat) => ( +
+ +
+ ))}
- ))} -
+ ); + })}
); }