cleanup score badges
Some checks are pending
Deploy / deploy (push) Waiting to run

This commit is contained in:
Lee
2024-09-30 23:06:06 +01:00
parent 7ca22a07e0
commit be89f6ba71
3 changed files with 25 additions and 18 deletions

View File

@ -1,5 +1,6 @@
import ScoreSaberScoreToken from "@/common/model/token/scoresaber/score-saber-score-token";
import ScoreSaberLeaderboardToken from "@/common/model/token/scoresaber/score-saber-leaderboard-token";
import StatValue from "@/components/stat-value";
/**
* A badge to display in the score stats.
@ -12,3 +13,23 @@ export type ScoreBadge = {
leaderboard: ScoreSaberLeaderboardToken
) => string | React.ReactNode | undefined;
};
/**
* The badges to display in the score stats.
*/
type ScoreBadgeProps = {
badges: ScoreBadge[];
score: ScoreSaberScoreToken;
leaderboard: ScoreSaberLeaderboardToken;
};
export function ScoreBadges({ badges, score, leaderboard }: ScoreBadgeProps) {
return badges.map((badge, index) => {
const toRender = badge.create(score, leaderboard);
const color = badge.color?.(score, leaderboard);
if (toRender === undefined) {
return <div key={index} />;
}
return <StatValue key={index} color={color} value={toRender} />;
});
}