scoresaber-reloaded-v2/src/components/player/ScoreStatLabel.tsx

43 lines
917 B
TypeScript
Raw Normal View History

2023-10-20 09:50:19 +00:00
import clsx from "clsx";
2023-10-29 15:35:10 +00:00
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/Tooltip";
2023-10-20 09:50:19 +00:00
type LabelProps = {
value: string;
2023-10-29 15:35:10 +00:00
tooltip?: React.ReactNode;
2023-10-21 01:38:18 +00:00
icon?: JSX.Element;
2023-10-20 09:50:19 +00:00
className?: string;
};
export default function ScoreStatLabel({
value,
2023-10-29 15:35:10 +00:00
tooltip,
2023-10-21 01:38:18 +00:00
icon,
2023-10-20 09:50:19 +00:00
className = "bg-neutral-700",
}: LabelProps) {
2023-10-29 15:35:10 +00:00
const base = (
<div
className={clsx(
"flex flex-col rounded-md hover:cursor-default",
className,
)}
>
2023-10-20 09:50:19 +00:00
<div className="p4-[0.3rem] flex items-center gap-2 pb-[0.2rem] pl-[0.3rem] pr-[0.3rem] pt-[0.2rem]">
2023-10-29 15:35:10 +00:00
<p className="flex w-full items-center justify-center gap-1">
{value}
2023-10-21 01:38:18 +00:00
{icon}
</p>
2023-10-20 09:50:19 +00:00
</div>
</div>
);
2023-10-29 15:35:10 +00:00
if (tooltip) {
return (
<Tooltip>
<TooltipTrigger>{base}</TooltipTrigger>
<TooltipContent>{tooltip}</TooltipContent>
</Tooltip>
);
}
return base;
2023-10-20 09:50:19 +00:00
}