Files
blitzkit/packages/bot/src/components/Leaderboard/components/Item.tsx
T

171 lines
4.0 KiB
TypeScript
Raw Normal View History

2025-10-13 23:15:32 -05:00
import { type ComponentProps } from "react";
import { theme } from "../../../stitches.config";
2023-07-16 17:45:29 +00:00
2025-10-13 23:15:32 -05:00
interface ItemProps extends ComponentProps<"div"> {
2023-07-16 17:45:29 +00:00
position: number;
deltaPosition?: number;
2023-11-08 11:16:51 -06:00
score?: number;
2023-07-18 00:17:00 +00:00
deltaScore?: number;
2023-07-16 17:45:29 +00:00
nickname: string;
clan?: string;
2023-08-09 17:13:26 +00:00
highlight?: boolean;
2023-07-16 17:45:29 +00:00
}
export function Item({
position,
deltaPosition,
2023-07-18 00:17:00 +00:00
score,
deltaScore,
2023-07-16 17:45:29 +00:00
nickname,
clan,
2023-08-09 17:13:26 +00:00
highlight,
2023-11-07 11:13:30 -06:00
...props
2023-07-16 17:45:29 +00:00
}: ItemProps) {
return (
<div
2023-11-07 11:13:30 -06:00
{...props}
2023-07-16 17:45:29 +00:00
style={{
2025-10-13 23:15:32 -05:00
cursor: "pointer",
display: "flex",
2023-07-16 17:45:29 +00:00
padding: 8,
2023-08-09 17:13:26 +00:00
backgroundColor: highlight
? theme.colors.componentInteractive_blue
: theme.colors.componentInteractive,
2023-07-16 17:45:29 +00:00
borderRadius: 4,
2025-10-13 23:15:32 -05:00
alignItems: "center",
justifyContent: "center",
2023-07-16 17:45:29 +00:00
gap: 8,
}}
>
<span
style={{
2023-08-09 17:13:26 +00:00
color: highlight
? theme.colors.textLowContrast_blue
: theme.colors.textLowContrast,
2023-07-16 17:45:29 +00:00
fontSize: 16,
}}
>
2023-07-18 00:17:00 +00:00
{position.toLocaleString()}.
2023-07-16 17:45:29 +00:00
</span>
<div
style={{
2025-10-13 23:15:32 -05:00
display: "flex",
alignItems: "center",
justifyContent: "center",
2023-07-16 17:45:29 +00:00
gap: 4,
}}
>
<span
style={{
2023-08-09 17:13:26 +00:00
color: highlight
? theme.colors.textHighContrast_blue
: theme.colors.textHighContrast,
2023-07-16 17:45:29 +00:00
fontSize: 16,
}}
>
{nickname}
</span>
{clan && (
<span
style={{
2023-08-09 17:13:26 +00:00
color: highlight
? theme.colors.textLowContrast_blue
: theme.colors.textLowContrast,
2023-07-16 17:45:29 +00:00
fontSize: 16,
}}
>
[{clan}]
</span>
)}
</div>
{deltaPosition !== undefined && deltaPosition !== 0 && (
<div
style={{
2025-10-13 23:15:32 -05:00
display: "flex",
alignItems: "center",
justifyContent: "center",
2023-07-16 17:45:29 +00:00
gap: 4,
}}
>
<img
2025-10-13 23:15:32 -05:00
alt={deltaPosition > 0 ? "Increase" : "Decrease"}
2023-07-16 17:45:29 +00:00
style={{
width: 8,
height: 8,
}}
src={
deltaPosition > 0
2025-10-13 23:15:32 -05:00
? "https://i.imgur.com/qbjiXa1.png"
: "https://i.imgur.com/3uyNhun.png"
2023-07-16 17:45:29 +00:00
}
/>
<span
style={{
2023-08-09 17:13:26 +00:00
color: highlight
? theme.colors.textLowContrast_blue
: theme.colors.textLowContrast,
2023-07-16 17:45:29 +00:00
fontSize: 16,
}}
>
2023-07-18 00:17:00 +00:00
{Math.abs(deltaPosition).toLocaleString()}
2023-07-16 17:45:29 +00:00
</span>
</div>
)}
2023-07-16 18:15:34 +00:00
2024-03-20 17:04:59 -05:00
{/* TODO: lol remove this spacer div for a better solution */}
<div style={{ flex: 1 }} />
2023-07-18 00:17:00 +00:00
<div
style={{
2025-10-13 23:15:32 -05:00
display: "flex",
2023-07-18 00:17:00 +00:00
gap: 4,
2025-10-13 23:15:32 -05:00
alignItems: "center",
2023-08-09 00:35:33 +00:00
width: 96,
2025-10-13 23:15:32 -05:00
justifyContent: "flex-end",
2023-07-18 00:17:00 +00:00
}}
>
{deltaScore !== 0 && deltaScore !== undefined && (
2023-08-09 17:13:26 +00:00
<span
style={{
color: highlight
? theme.colors.textLowContrast_blue
: theme.colors.textLowContrast,
fontSize: 16,
}}
>
2023-07-18 00:17:00 +00:00
{Math.abs(deltaScore).toLocaleString()}
</span>
)}
{deltaScore !== 0 && deltaScore !== undefined && (
<img
2025-10-13 23:15:32 -05:00
alt={deltaScore > 0 ? "Increase" : "Decrease"}
2023-07-18 00:17:00 +00:00
style={{
width: 8,
height: 8,
}}
src={
deltaScore > 0
2025-10-13 23:15:32 -05:00
? "https://i.imgur.com/qbjiXa1.png"
: "https://i.imgur.com/3uyNhun.png"
2023-07-18 00:17:00 +00:00
}
/>
)}
2023-11-08 11:16:51 -06:00
{score !== undefined && (
<span
style={{
color: highlight
? theme.colors.textHighContrast_blue
: theme.colors.textHighContrast,
fontSize: 16,
}}
>
{score.toLocaleString()}
</span>
)}
2023-07-18 00:17:00 +00:00
</div>
2023-07-16 17:45:29 +00:00
</div>
);
}