update score stat labels again
All checks were successful
deploy / deploy (push) Successful in 54s

This commit is contained in:
Lee 2023-10-21 02:38:18 +01:00
parent b3ad0d413d
commit 51ecd67747
2 changed files with 44 additions and 28 deletions

@ -2,6 +2,7 @@ import { ScoresaberLeaderboardInfo } from "@/schemas/scoresaber/leaderboard";
import { ScoresaberScore } from "@/schemas/scoresaber/score"; import { ScoresaberScore } from "@/schemas/scoresaber/score";
import { formatNumber } from "@/utils/number"; import { formatNumber } from "@/utils/number";
import { GlobeAsiaAustraliaIcon } from "@heroicons/react/20/solid"; import { GlobeAsiaAustraliaIcon } from "@heroicons/react/20/solid";
import clsx from "clsx";
import moment from "moment"; import moment from "moment";
import Image from "next/image"; import Image from "next/image";
import ScoreStatLabel from "./ScoreStatLabel"; import ScoreStatLabel from "./ScoreStatLabel";
@ -12,6 +13,8 @@ type ScoreProps = {
}; };
export default function Score({ score, leaderboard }: ScoreProps) { export default function Score({ score, leaderboard }: ScoreProps) {
const isFullCombo = score.missedNotes + score.badCuts === 0;
return ( return (
<div className="grid grid-cols-1 pb-2 pt-2 first:pt-0 last:pb-0 md:grid-cols-[1.1fr_6fr_3fr] xl:xs:grid-cols-[.95fr_6fr_3fr]"> <div className="grid grid-cols-1 pb-2 pt-2 first:pt-0 last:pb-0 md:grid-cols-[1.1fr_6fr_3fr] xl:xs:grid-cols-[.95fr_6fr_3fr]">
<div className="ml-3 flex flex-col items-start justify-center"> <div className="ml-3 flex flex-col items-start justify-center">
@ -59,7 +62,8 @@ export default function Score({ score, leaderboard }: ScoreProps) {
</div> </div>
{/* PP */} {/* PP */}
<div className="grid w-fit grid-cols-2 grid-rows-1 justify-end gap-2"> <div className="flex flex-col justify-end gap-2">
<div className="flex justify-end gap-2">
{score.pp > 0 && ( {score.pp > 0 && (
<ScoreStatLabel <ScoreStatLabel
className="bg-blue-500 text-center" className="bg-blue-500 text-center"
@ -72,19 +76,30 @@ export default function Score({ score, leaderboard }: ScoreProps) {
value={ value={
!leaderboard.maxScore !leaderboard.maxScore
? formatNumber(score.baseScore) ? formatNumber(score.baseScore)
: ((score.baseScore / leaderboard.maxScore) * 100).toFixed(2) + : ((score.baseScore / leaderboard.maxScore) * 100).toFixed(
"%" 2,
) + "%"
} }
/> />
</div>
<div className="flex justify-end gap-2">
{/* Missed Notes */} {/* Missed Notes */}
<ScoreStatLabel <ScoreStatLabel
className="min-w-[3rem] bg-red-500" className={clsx(
"min-w-[2rem]",
isFullCombo ? "bg-green-500" : "bg-red-500",
)}
title={`${score.missedNotes} missed notes. ${score.badCuts} bad cuts.`} title={`${score.missedNotes} missed notes. ${score.badCuts} bad cuts.`}
value={formatNumber(score.missedNotes + score.badCuts) + "x"} value={
isFullCombo
? "FC"
: formatNumber(score.missedNotes + score.badCuts) + "x"
}
/> />
</div> </div>
</div> </div>
</div> </div>
</div>
); );
} }

@ -3,24 +3,25 @@ import clsx from "clsx";
type LabelProps = { type LabelProps = {
value: string; value: string;
title?: string; title?: string;
icon?: JSX.Element;
className?: string; className?: string;
}; };
export default function ScoreStatLabel({ export default function ScoreStatLabel({
value, value,
title, title,
icon,
className = "bg-neutral-700", className = "bg-neutral-700",
}: LabelProps) { }: LabelProps) {
return ( return (
<div <div className={clsx("flex flex-col rounded-md", className)}>
className={clsx(
"flex min-w-[5rem] flex-col justify-center rounded-md",
className,
)}
>
<div className="p4-[0.3rem] flex items-center gap-2 pb-[0.2rem] pl-[0.3rem] pr-[0.3rem] pt-[0.2rem]"> <div className="p4-[0.3rem] flex items-center gap-2 pb-[0.2rem] pl-[0.3rem] pr-[0.3rem] pt-[0.2rem]">
<p className="w-full text-center" title={title}> <p
className="flex w-full items-center justify-center gap-1"
title={title}
>
{value} {value}
{icon}
</p> </p>
</div> </div>
</div> </div>