aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/Gaming/ScoreBar.tsx
blob: 4eac3ad1cfff3a533798d69249798f1454a17be5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
type Props = {
	scoreA: number | null;
	scoreB: number | null;
	bgA: string;
	bgB: string;
};

export default function ScoreBar({ scoreA, scoreB, bgA, bgB }: Props) {
	let scoreRatio;
	if (scoreA === null && scoreB === null) {
		scoreRatio = 50;
	} else if (scoreA === null) {
		scoreRatio = 0;
	} else if (scoreB === null) {
		scoreRatio = 100;
	} else {
		scoreRatio = (scoreB / (scoreA + scoreB)) * 100;
	}

	return (
		<div className={`w-full ${bgB}`}>
			<div className={`h-6 ${bgA}`} style={{ width: `${scoreRatio}%` }}></div>
		</div>
	);
}