import NextLink from 'next/link';
import { GridBox } from '../../../atoms/grid-box';
import { Element } from '../../../primitives/element';
import { cn } from '../../../tools/cn';
import type { MediaSlideProps } from '../types';
import { mediaImageVariants, mediaSlideVariants } from '../variants';
/**
* One image, contained in its box. With `onOpen` the box is the button that opens the Lightbox;
* with `href` a hidden link covers it, so a tap opens the post while the image keeps its alt.
*/
export function MediaSlide({
item,
index,
single,
label,
href,
onOpen,
className,
}: MediaSlideProps) {
const box = cn(mediaSlideVariants({ single }), className);
const image = (
);
if (onOpen) {
return (
onOpen(index)}
aria-label={label ?? (item.alt || undefined)}
className={cn(
box,
'actionable:cursor-zoom-in',
// A slide's ring would be clipped by the scrolling track, so the track draws it.
single ? 'focus-visible:focus-ring' : 'outline-none',
)}
>
{image}
);
}
return (
{image}
{href && (
// The post's own link carries the keyboard path; this one is only a bigger tap area.
)}
);
}