import { literals } from "@blitzkit/i18n"; import { Grade } from "@protos/blitz_static_standard_grades_enum"; import { DownloadIcon, StarFilledIcon } from "@radix-ui/react-icons"; import type { Color } from "../../core/ui/color"; import { useGameStrings } from "../../hooks/useGameStrings"; import { useStrings } from "../../hooks/useStrings"; import type { Avatar } from "../../protos/avatar"; import type { PropsWithSkeleton } from "../../types/propsWithSkeleton"; import { Badge } from "../Badge"; import { Button } from "../Button"; import { Dialog } from "../Dialog"; import { InlineSkeleton } from "../InlineSkeleton"; import { Link } from "../Link"; import { Skeleton } from "../Skeleton"; import { Text } from "../Text"; import styles from "./index.module.css"; interface Props { name: string; avatars: Avatar[]; } const MAX_CARDS = 3; const CARD_TRIM = "var(--space-3)"; export function AvatarCard(props: PropsWithSkeleton) { const card = (
{props.skeleton ? : props.name}
); if (props.skeleton) return card; return ( {card} {props.name}
); } interface DetailsProps { avatars: Avatar[]; } const gradeColors: Record = { [Grade.GRADE_UNSPECIFIED]: "gray", [Grade.GRADE_COMMON]: "gray", [Grade.GRADE_RARE]: "blue", [Grade.GRADE_EPIC]: "purple", [Grade.GRADE_LEGENDARY]: "amber", }; function Details({ avatars }: DetailsProps) { const gameStrings = useGameStrings("ProfileAvatarEntity"); const strings = useStrings(); return [...avatars].reverse().map((avatar) => { const description = gameStrings[avatar.stuff_ui!.description]; const obtaining = gameStrings[avatar.stuff_ui!.obtaining_methods]; const hasDescription = description || obtaining; return (
{strings.grades[avatar.stuff_ui!.grade]}
{hasDescription ? ( <> {description} {obtaining} ) : ( strings.avatars.no_description )}
); }); } interface SeriesProps { avatars: Avatar[]; } function Series(props: PropsWithSkeleton) { const count = Math.min(props.skeleton ? 0 : props.avatars.length, MAX_CARDS); const strings = useStrings(); return (
{!props.skeleton && props.avatars.slice(-MAX_CARDS).map((avatar, index) => (
))} {!props.skeleton && props.avatars.length > 1 && ( {literals(strings.units.x, { value: props.avatars.length })} )} {props.skeleton && }
); }