Vercel/src/photo/PhotoSmall.tsx
Sam Becker 646f32e642
Rich sort controls (#283)
* Generalize app switcher menus

* Organize sort module

* Build configuration for nav sort control

* Refine sort menu styles

* Upgrade next.js

* Reset custom sort when clicking grid/full a second time

* Light up sort button when overridden
2025-07-15 22:43:36 -05:00

60 lines
1.4 KiB
TypeScript

import {
Photo,
altTextForPhoto,
doesPhotoNeedBlurCompatibility,
} from '.';
import { PhotoSetCategory } from '../category';
import ImageSmall from '@/components/image/ImageSmall';
import Link from 'next/link';
import { clsx } from 'clsx/lite';
import { pathForPhoto } from '@/app/path';
import { SHOULD_PREFETCH_ALL_LINKS } from '@/app/config';
import { useRef } from 'react';
import useVisible from '@/utility/useVisible';
export default function PhotoSmall({
photo,
selected,
className,
prefetch = SHOULD_PREFETCH_ALL_LINKS,
forceFallbackFade,
onVisible,
...categories
}: {
photo: Photo
selected?: boolean
className?: string
prefetch?: boolean
forceFallbackFade?: boolean
onVisible?: () => void
} & PhotoSetCategory) {
const ref = useRef<HTMLAnchorElement>(null);
useVisible({ ref, onVisible });
return (
<Link
ref={ref}
href={pathForPhoto({ photo, ...categories })}
className={clsx(
className,
'active:brightness-75',
selected && 'brightness-50',
'min-w-[50px]',
'rounded-[3px] overflow-hidden',
'border-main',
)}
prefetch={prefetch}
>
<ImageSmall
src={photo.url}
aspectRatio={photo.aspectRatio}
blurDataURL={photo.blurData}
blurCompatibilityMode={doesPhotoNeedBlurCompatibility(photo)}
alt={altTextForPhoto(photo)}
forceFallbackFade={forceFallbackFade}
/>
</Link>
);
};