Refine matte layouts based on aspect ratio

This commit is contained in:
Sam Becker 2025-01-25 19:40:12 -06:00
parent 24a1e396d6
commit b7eb946d18

View File

@ -115,6 +115,16 @@ export default function PhotoLarge({
prefetch={prefetch} prefetch={prefetch}
/>; />;
const matteContentWidthForAspectRatio = () => {
// Restrict width for landscape photos
// (portrait photos are always height restricted)
if (photo.aspectRatio > 3 / 2 + 0.1) {
return 'w-[90%]';
} else if (photo.aspectRatio >= 1) {
return 'w-[80%]';
}
};
return ( return (
<SiteGrid <SiteGrid
containerRef={ref} containerRef={ref}
@ -123,16 +133,15 @@ export default function PhotoLarge({
<Link <Link
href={pathForPhoto({ photo })} href={pathForPhoto({ photo })}
className={clsx(arePhotosMatted && className={clsx(arePhotosMatted &&
'flex items-center aspect-[3/2] bg-gray-100', 'flex items-center justify-center aspect-[3/2] bg-gray-100',
)} )}
prefetch={prefetch} prefetch={prefetch}
> >
<div className={clsx( <div className={clsx(
arePhotosMatted && arePhotosMatted && 'flex items-center justify-center',
'flex items-center justify-center w-full', // Always specify height to ensure fallback doesn't collapse
arePhotosMatted && photo.aspectRatio >= 1 arePhotosMatted && 'h-[90%]',
? 'h-[80%]' arePhotosMatted && matteContentWidthForAspectRatio(),
: 'h-[90%]',
)}> )}>
<ImageLarge <ImageLarge
className={clsx(arePhotosMatted && 'h-full')} className={clsx(arePhotosMatted && 'h-full')}