From 86380198528ae578a6a5346ae3fa71db3c8d51d3 Mon Sep 17 00:00:00 2001 From: Hendrik Liebau Date: Thu, 15 May 2025 12:28:00 +0200 Subject: [PATCH] Optimize product page route shell --- app/product/[handle]/page.tsx | 24 +++---- components/cart/add-to-cart-skeleton.tsx | 30 +++++++++ components/cart/add-to-cart.tsx | 11 +++- components/grid/tile.tsx | 6 +- components/product/gallery-skeleton.tsx | 66 +++++++++++++++++++ components/product/gallery.tsx | 11 +++- components/product/product-description.tsx | 17 ++++- .../{product-context.tsx => use-product.ts} | 20 ++---- .../product/variant-selector-skeleton.tsx | 40 +++++++++++ components/product/variant-selector.tsx | 24 ++++--- 10 files changed, 202 insertions(+), 47 deletions(-) create mode 100644 components/cart/add-to-cart-skeleton.tsx create mode 100644 components/product/gallery-skeleton.tsx rename components/product/{product-context.tsx => use-product.ts} (71%) create mode 100644 components/product/variant-selector-skeleton.tsx diff --git a/app/product/[handle]/page.tsx b/app/product/[handle]/page.tsx index 038173879..587b1b072 100644 --- a/app/product/[handle]/page.tsx +++ b/app/product/[handle]/page.tsx @@ -4,7 +4,7 @@ import { notFound } from 'next/navigation'; import { GridTileImage } from 'components/grid/tile'; import Footer from 'components/layout/footer'; import { Gallery } from 'components/product/gallery'; -import { ProductProvider } from 'components/product/product-context'; +import { GallerySkeleton } from 'components/product/gallery-skeleton'; import { ProductDescription } from 'components/product/product-description'; import { HIDDEN_PRODUCT_TAG } from 'lib/constants'; import { getProduct, getProductRecommendations } from 'lib/shopify'; @@ -76,8 +76,13 @@ export default async function ProductPage(props: { } }; + const images = product.images.slice(0, 5).map((image: Image) => ({ + src: image.url, + altText: image.altText + })); + return ( - + <>