aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/Gaming/ScoreBar.tsx
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-18 01:46:36 +0900
committernsfisis <nsfisis@gmail.com>2024-08-18 01:46:36 +0900
commited796dddde6db433c88b04a1ad154bf88a24faa4 (patch)
treede82ed4ae74c75ba7ddf9e478cb6129177ee4c89 /frontend/app/components/Gaming/ScoreBar.tsx
parent7653eb2b28911a0479b3b673c9b63fd490aedb6b (diff)
parent9bd1f89febe6311781aca3e8ee2b6a706a606e3c (diff)
downloadphperkaigi-2025-albatross-ed796dddde6db433c88b04a1ad154bf88a24faa4.tar.gz
phperkaigi-2025-albatross-ed796dddde6db433c88b04a1ad154bf88a24faa4.tar.zst
phperkaigi-2025-albatross-ed796dddde6db433c88b04a1ad154bf88a24faa4.zip
Merge branch 'feat/watch-page'
Diffstat (limited to 'frontend/app/components/Gaming/ScoreBar.tsx')
-rw-r--r--frontend/app/components/Gaming/ScoreBar.tsx25
1 files changed, 25 insertions, 0 deletions
diff --git a/frontend/app/components/Gaming/ScoreBar.tsx b/frontend/app/components/Gaming/ScoreBar.tsx
new file mode 100644
index 0000000..4eac3ad
--- /dev/null
+++ b/frontend/app/components/Gaming/ScoreBar.tsx
@@ -0,0 +1,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>
+ );
+}