'use client'; import { ReactNode, ComponentProps, RefObject } from 'react'; import { Photo, titleForPhoto } from '@/photo'; import { PhotoSetCategory } from '@/category'; import { AnimationConfig } from '../components/AnimateItems'; import { useAppState } from '@/app/AppState'; import { pathForPhoto } from '@/app/path'; import { clsx } from 'clsx/lite'; import LinkWithStatus from '@/components/LinkWithStatus'; import Spinner from '@/components/Spinner'; import LinkWithLoaderBackground from '@/components/LinkWithLoaderBackground'; export default function PhotoLink({ ref, photo, scroll, prefetch, nextPhotoAnimation, className, children: _children, loaderType = 'spinner', ...categories }: { ref?: RefObject photo?: Photo scroll?: boolean prefetch?: boolean nextPhotoAnimation?: AnimationConfig className?: string children?: ReactNode loaderType?: 'spinner' | 'badge' } & PhotoSetCategory) { const { setNextPhotoAnimation } = useAppState(); const linkProps: Omit, 'children'> | undefined = photo ? { ref, className, href: pathForPhoto({ photo, ...categories }), onClick: () => { if (nextPhotoAnimation) { setNextPhotoAnimation?.(nextPhotoAnimation); } }, scroll, prefetch, } : undefined; const children = photo ? (_children ?? titleForPhoto(photo)) : _children; return ( photo && linkProps ? loaderType === 'spinner' ? {({ isLoading }) => <> {children} {isLoading && <>   } } : {children} : {children} ); };