import { asset, Avatar } from "@blitzkit/core"; import { Cross1Icon, DownloadIcon } from "@radix-ui/react-icons"; import { Dialog, Flex, IconButton, Link, Skeleton, Text, } from "@radix-ui/themes"; import { useRef } from "react"; import { useIntersection } from "../../hooks/useIntersection"; import { useLocale } from "../../hooks/useLocale"; import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps"; type GalleryCardProps = MaybeSkeletonComponentProps<{ avatar: Avatar; }>; export function GalleryCard(props: GalleryCardProps) { const src = asset( `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)} ); }