cleanup stat changes and add ranked and total scores change
All checks were successful
Deploy Backend / docker (ubuntu-latest) (push) Successful in 46s
Deploy Website / docker (ubuntu-latest) (push) Successful in 2m13s

This commit is contained in:
Lee
2024-10-20 19:17:17 +01:00
parent a68e53734d
commit 336518ff70
8 changed files with 214 additions and 105 deletions

View File

@ -0,0 +1,36 @@
import React from "react";
import Tooltip from "@/components/tooltip";
import { formatNumberWithCommas } from "@ssr/common/utils/number-utils";
import { PlayerStatValue } from "@ssr/common/player/player-stat";
// Props for DailyChangeComponent
interface DailyChangeProps {
type: PlayerStatValue;
change: number | undefined;
tooltip?: React.ReactElement | string;
format?: (value: number) => string;
}
export function DailyChange({ type, change, tooltip, format }: DailyChangeProps) {
const formatValue = format ?? formatNumberWithCommas;
if (change === 0 || change === undefined) {
return null;
}
const value = (
<p className={`text-sm ${change > 0 ? "text-green-400" : "text-red-400"}`}>
{change > 0 ? "+" : ""}
{formatValue(change)}
</p>
);
if (!tooltip) {
tooltip = `${type.displayName} change compared to yesterday`;
}
return (
<Tooltip display={tooltip} side="bottom">
{value}
</Tooltip>
);
}