From 4203fc8f327dcfd6b4859a84a1f03ffd51a63419 Mon Sep 17 00:00:00 2001 From: Michael Novotny Date: Mon, 17 Jul 2023 16:58:07 -0500 Subject: [PATCH] Fixes image alt errors (#1084) --- components/grid/tile.tsx | 1 - components/product/gallery.tsx | 19 ++++++++++--------- lib/shopify/index.ts | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/components/grid/tile.tsx b/components/grid/tile.tsx index 87ec8f3f1..610c49a94 100644 --- a/components/grid/tile.tsx +++ b/components/grid/tile.tsx @@ -36,7 +36,6 @@ export function GridTileImage({ 'transition duration-300 ease-in-out hover:scale-105': isInteractive })} {...props} - alt={props.title || ''} /> ) : null} {labels ? ( diff --git a/components/product/gallery.tsx b/components/product/gallery.tsx index 0e38ef375..4dca63643 100644 --- a/components/product/gallery.tsx +++ b/components/product/gallery.tsx @@ -6,13 +6,13 @@ import Image from 'next/image'; import { useState } from 'react'; export function Gallery({ images }: { images: { src: string; altText: string }[] }) { - const [currentImage, setCurrentImage] = useState(0); + const [currentImageIndex, setCurrentImageIndex] = useState(0); function handleNavigate(direction: 'next' | 'previous') { if (direction === 'next') { - setCurrentImage(currentImage + 1 < images.length ? currentImage + 1 : 0); + setCurrentImageIndex(currentImageIndex + 1 < images.length ? currentImageIndex + 1 : 0); } else { - setCurrentImage(currentImage === 0 ? images.length - 1 : currentImage - 1); + setCurrentImageIndex(currentImageIndex === 0 ? images.length - 1 : currentImageIndex - 1); } } @@ -22,13 +22,14 @@ export function Gallery({ images }: { images: { src: string; altText: string }[] return (
- {images[currentImage] && ( + {images[currentImageIndex] && ( {images[currentImage]?.altText )} @@ -58,16 +59,16 @@ export function Gallery({ images }: { images: { src: string; altText: string }[] {images.length > 1 ? (
{images.map((image, index) => { - const isActive = index === currentImage; + const isActive = index === currentImageIndex; return (