From b0ea964ad74852e67de636ae00844865f44d8721 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Thu, 29 Feb 2024 23:16:58 -0600 Subject: [PATCH] Refactor photo link prefetching behavior --- src/components/ImageLarge.tsx | 26 +++++++++----------------- src/photo/PhotoLarge.tsx | 27 +++++++++++++++++---------- src/photo/PhotoSmall.tsx | 4 +++- src/photo/PhotoTiny.tsx | 4 +++- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/components/ImageLarge.tsx b/src/components/ImageLarge.tsx index 927fb64e..d82a2212 100644 --- a/src/components/ImageLarge.tsx +++ b/src/components/ImageLarge.tsx @@ -1,10 +1,8 @@ import { IMAGE_LARGE_WIDTH } from '@/site'; -import Link from 'next/link'; import ImageBlurFallback from './ImageBlurFallback'; export default function ImageLarge({ className, - href, src, alt, aspectRatio, @@ -12,7 +10,6 @@ export default function ImageLarge({ priority, }: { className?: string - href: string src: string alt: string aspectRatio: number @@ -20,19 +17,14 @@ export default function ImageLarge({ priority?: boolean }) { return ( - - - + ); }; diff --git a/src/photo/PhotoLarge.tsx b/src/photo/PhotoLarge.tsx index 0c3d1c2b..06b787bf 100644 --- a/src/photo/PhotoLarge.tsx +++ b/src/photo/PhotoLarge.tsx @@ -22,6 +22,7 @@ export default function PhotoLarge({ photo, primaryTag, priority, + prefetch = false, prefetchRelatedLinks = false, showCamera = true, showSimulation = true, @@ -33,6 +34,7 @@ export default function PhotoLarge({ photo: Photo primaryTag?: string priority?: boolean + prefetch?: boolean prefetchRelatedLinks?: boolean showCamera?: boolean showSimulation?: boolean @@ -58,15 +60,20 @@ export default function PhotoLarge({ return ( } + className="active:brightness-75" + prefetch={prefetch} + > + + } contentSide={
{titleForPhoto(photo)} diff --git a/src/photo/PhotoSmall.tsx b/src/photo/PhotoSmall.tsx index 5437cfa9..e3d086d3 100644 --- a/src/photo/PhotoSmall.tsx +++ b/src/photo/PhotoSmall.tsx @@ -13,6 +13,7 @@ export default function PhotoSmall({ simulation, selected, priority, + prefetch = false, }: { photo: Photo tag?: string @@ -20,6 +21,7 @@ export default function PhotoSmall({ simulation?: FilmSimulation selected?: boolean priority?: boolean + prefetch?: boolean }) { return (