From 9c813577e1deaf69166ef96fc72e24c4bd98ca04 Mon Sep 17 00:00:00 2001 From: Michael Novotny Date: Wed, 2 Aug 2023 21:07:35 -0500 Subject: [PATCH] Optimizes image sizes (#1140) --- app/product/[handle]/page.tsx | 31 ++++++++-------- components/carousel.tsx | 35 +++++++++--------- components/cart/modal.tsx | 4 +- components/grid/three-items.tsx | 12 +++--- components/layout/product-grid-items.tsx | 6 +-- components/product/gallery.tsx | 47 ++++++++++++------------ 6 files changed, 69 insertions(+), 66 deletions(-) diff --git a/app/product/[handle]/page.tsx b/app/product/[handle]/page.tsx index 815078b56..d59423364 100644 --- a/app/product/[handle]/page.tsx +++ b/app/product/[handle]/page.tsx @@ -82,8 +82,8 @@ export default async function ProductPage({ params }: { params: { handle: string }} />
-
-
+
+
({ src: image.url, @@ -92,7 +92,7 @@ export default async function ProductPage({ params }: { params: { handle: string />
-
+
@@ -115,14 +115,13 @@ async function RelatedProducts({ id }: { id: string }) { return (

Related Products

-
- {relatedProducts.map((product, i) => { - return ( - +
    + {relatedProducts.map((product) => ( +
  • + - ); - })} -
+ + ))} +
); } diff --git a/components/carousel.tsx b/components/carousel.tsx index d67ba5deb..a4c58bd5d 100644 --- a/components/carousel.tsx +++ b/components/carousel.tsx @@ -10,27 +10,28 @@ export async function Carousel() { return (
-
+
    {[...products, ...products].map((product, i) => ( - - - + + + + ))} -
+
); } diff --git a/components/cart/modal.tsx b/components/cart/modal.tsx index a6b45b9ae..4fbfcc6ad 100644 --- a/components/cart/modal.tsx +++ b/components/cart/modal.tsx @@ -111,7 +111,7 @@ export default function CartModal({ cart }: { cart: Cart | undefined }) { >
{
-

+

{item.quantity}

diff --git a/components/grid/three-items.tsx b/components/grid/three-items.tsx index 4a680fc36..abb379e5c 100644 --- a/components/grid/three-items.tsx +++ b/components/grid/three-items.tsx @@ -6,13 +6,15 @@ import Link from 'next/link'; function ThreeItemGridItem({ item, size }: { item: Product; size: 'full' | 'half' }) { return (
- + +
diff --git a/components/layout/product-grid-items.tsx b/components/layout/product-grid-items.tsx index d9060adbb..ea8a5ebf7 100644 --- a/components/layout/product-grid-items.tsx +++ b/components/layout/product-grid-items.tsx @@ -8,7 +8,7 @@ export default function ProductGridItems({ products }: { products: Product[] }) <> {products.map((product) => ( - + diff --git a/components/product/gallery.tsx b/components/product/gallery.tsx index 99742a917..d1f567aef 100644 --- a/components/product/gallery.tsx +++ b/components/product/gallery.tsx @@ -27,13 +27,13 @@ export function Gallery({ images }: { images: { src: string; altText: string }[] 'h-full px-6 transition-all ease-in-out hover:scale-110 hover:text-black dark:hover:text-white flex items-center justify-center'; return ( -
-
+ <> +
{images[imageIndex] && ( {images[imageIndex]?.altText {images.length > 1 ? ( -
+
    {images.map((image, index) => { const isActive = index === imageIndex; const imageSearchParams = new URLSearchParams(searchParams.toString()); @@ -68,25 +68,26 @@ export function Gallery({ images }: { images: { src: string; altText: string }[] imageSearchParams.set('image', index.toString()); return ( - - - +
  • + + + +
  • ); })} -
+ ) : null} -
+ ); }