This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
scoresaber-reloadedv3/src/app/components/player/player-header.tsx

64 lines
2.0 KiB
TypeScript
Raw Normal View History

import ScoreSaberPlayer from "@/app/common/leaderboard/types/scoresaber/scoresaber-player";
import { formatNumberWithCommas } from "@/app/common/number-utils";
import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
2024-09-11 14:38:04 +00:00
import Card from "../card";
import CountryFlag from "../country-flag";
import { Avatar, AvatarImage } from "../ui/avatar";
import ClaimProfile from "./claim-profile";
2024-09-11 14:38:04 +00:00
import PlayerDataPoint from "./player-data-point";
const playerSubNames = [
{
icon: () => {
return <GlobeAmericasIcon className="h-5 w-5" />;
},
render: (player: ScoreSaberPlayer) => {
return <p>#{formatNumberWithCommas(player.rank)}</p>;
},
},
{
icon: (player: ScoreSaberPlayer) => {
2024-09-11 17:33:16 +00:00
return <CountryFlag country={player.country.toLowerCase()} size={15} />;
},
render: (player: ScoreSaberPlayer) => {
return <p>#{formatNumberWithCommas(player.countryRank)}</p>;
},
},
{
render: (player: ScoreSaberPlayer) => {
2024-09-11 14:38:04 +00:00
return <p className="text-pp">{formatNumberWithCommas(player.pp)}pp</p>;
},
},
];
type Props = {
player: ScoreSaberPlayer;
};
export default function PlayerHeader({ player }: Props) {
return (
2024-09-11 14:38:04 +00:00
<Card>
<div className="flex gap-3 flex-col items-center text-center sm:flex-row sm:items-start sm:text-start relative select-none">
<Avatar className="w-32 h-32 pointer-events-none">
<AvatarImage fetchPriority="high" src={player.profilePicture} />
</Avatar>
<div>
<p className="font-bold text-2xl">{player.name}</p>
<div className="flex gap-2">
{playerSubNames.map((subName, index) => {
return (
2024-09-11 14:38:04 +00:00
<PlayerDataPoint icon={subName.icon && subName.icon(player)} key={index}>
{subName.render(player)}
2024-09-11 14:38:04 +00:00
</PlayerDataPoint>
);
})}
</div>
<div className="absolute top-0 right-0">
<ClaimProfile playerId={player.id} />
</div>
</div>
</div>
2024-09-11 14:38:04 +00:00
</Card>
);
}