import { alias } from "@blitzkit/core"; import { Avatar } from "@blitzkit/protos"; import { Cross1Icon, DownloadIcon } from "@radix-ui/react-icons"; import { useRef } from "react"; import { useIntersection } from "../hooks/useIntersection"; import { useLocale } from "../hooks/useLocale"; import type { MaybeSkeletonComponentProps } from "../types/maybeSkeletonComponentProps"; import { Skeleton } from "./Skeleton"; import { Text } from "./Text"; type GalleryCardProps = MaybeSkeletonComponentProps<{ avatar: Avatar; }>; export function AvatarCard(props: GalleryCardProps) { const src = alias( "api", `/gallery/avatars/${ !props.skeleton && `${props.avatar.id}${props.avatar.extension}` }` ); const card = useRef(null!); const { unwrap } = useLocale(); useIntersection(() => props.skeleton && props.onIntersection?.(), card, { disabled: !props.skeleton || props.onIntersection === undefined, }); const content = (
{props.skeleton && ( <> )} {!props.skeleton && ( <> {unwrap(props.avatar.name!)} {unwrap(props.avatar.name!)} )}
); if (props.skeleton) return content; return ( {content} event.preventDefault()} width="fit-content" >
{unwrap(props.avatar.name!)}
{unwrap(props.avatar.name!)}
); }