11import { getTranslations } from "next-intl/server" ;
22import { Suspense } from "react" ;
33
4+ import {
5+ aspectRatioClasses ,
6+ type ProductCardAspectRatio ,
7+ } from "@/components/product-card/components" ;
48import { BuyButtons } from "@/components/product-detail/buy-buttons" ;
59import {
610 ProductInfoDescription ,
@@ -36,10 +40,12 @@ export async function ProductDetailSection({
3640 product,
3741 locale,
3842 variantIdPromise,
43+ aspectRatio = "square" ,
3944} : {
4045 product : ProductDetails ;
4146 locale : Locale ;
4247 variantIdPromise : Promise < string | undefined > ;
48+ aspectRatio ?: ProductCardAspectRatio ;
4349} ) {
4450 const { handle, title, featuredImage, images, videos, variants, options } = product ;
4551
@@ -66,15 +72,28 @@ export async function ProductDetailSection({
6672 otherImages = { getSharedImages ( images , options , variants ) }
6773 videos = { videos }
6874 title = { title }
75+ aspectRatio = { aspectRatio }
6976 className = "lg:col-span-6"
7077 desktopSlot = {
7178 < Suspense
7279 fallback = {
7380 < >
74- < Skeleton className = "aspect-square w-full rounded-none" />
75- < Skeleton className = "aspect-square w-full rounded-none" />
76- < Skeleton className = "aspect-square w-full rounded-none" />
77- < Skeleton className = "aspect-square w-full rounded-none" />
81+ < Skeleton
82+ data-aspect-ratio = { aspectRatio }
83+ className = { cn ( "w-full rounded-none" , aspectRatioClasses ) }
84+ />
85+ < Skeleton
86+ data-aspect-ratio = { aspectRatio }
87+ className = { cn ( "w-full rounded-none" , aspectRatioClasses ) }
88+ />
89+ < Skeleton
90+ data-aspect-ratio = { aspectRatio }
91+ className = { cn ( "w-full rounded-none" , aspectRatioClasses ) }
92+ />
93+ < Skeleton
94+ data-aspect-ratio = { aspectRatio }
95+ className = { cn ( "w-full rounded-none" , aspectRatioClasses ) }
96+ />
7897 </ >
7998 }
8099 >
@@ -83,14 +102,21 @@ export async function ProductDetailSection({
83102 options = { options }
84103 variants = { variants }
85104 title = { title }
105+ aspectRatio = { aspectRatio }
86106 variantIdPromise = { variantIdPromise }
87107 />
88108 </ Suspense >
89109 }
90110 mobileSlot = {
91111 < Suspense
92112 fallback = {
93- < div className = "relative shrink-0 w-full aspect-square snap-start snap-always overflow-hidden" >
113+ < div
114+ data-aspect-ratio = { aspectRatio }
115+ className = { cn (
116+ "relative shrink-0 w-full snap-start snap-always overflow-hidden" ,
117+ aspectRatioClasses ,
118+ ) }
119+ >
94120 < Skeleton className = "size-full rounded-none" />
95121 </ div >
96122 }
@@ -100,6 +126,7 @@ export async function ProductDetailSection({
100126 options = { options }
101127 variants = { variants }
102128 title = { title }
129+ aspectRatio = { aspectRatio }
103130 variantIdPromise = { variantIdPromise }
104131 />
105132 </ Suspense >
@@ -110,6 +137,7 @@ export async function ProductDetailSection({
110137 otherImages = { images }
111138 videos = { videos }
112139 title = { title }
140+ aspectRatio = { aspectRatio }
113141 className = "lg:col-span-6"
114142 />
115143 ) }
@@ -297,12 +325,14 @@ async function ResolvedColorImages({
297325 options,
298326 variants,
299327 title,
328+ aspectRatio,
300329 variantIdPromise,
301330} : {
302331 images : ImageType [ ] ;
303332 options : ProductOption [ ] ;
304333 variants : ProductVariant [ ] ;
305334 title : string ;
335+ aspectRatio : ProductCardAspectRatio ;
306336 variantIdPromise : Promise < string | undefined > ;
307337} ) {
308338 const variantId = await variantIdPromise ;
@@ -316,20 +346,22 @@ async function ResolvedColorImages({
316346
317347 if ( colorImages . length === 0 ) return null ;
318348
319- return < ColorImageGrid images = { colorImages } title = { title } /> ;
349+ return < ColorImageGrid images = { colorImages } title = { title } aspectRatio = { aspectRatio } /> ;
320350}
321351
322352async function ResolvedColorCarouselImages ( {
323353 images,
324354 options,
325355 variants,
326356 title,
357+ aspectRatio,
327358 variantIdPromise,
328359} : {
329360 images : ImageType [ ] ;
330361 options : ProductOption [ ] ;
331362 variants : ProductVariant [ ] ;
332363 title : string ;
364+ aspectRatio : ProductCardAspectRatio ;
333365 variantIdPromise : Promise < string | undefined > ;
334366} ) {
335367 const variantId = await variantIdPromise ;
@@ -343,5 +375,5 @@ async function ResolvedColorCarouselImages({
343375
344376 if ( colorImages . length === 0 ) return null ;
345377
346- return < ColorImageCarouselItems images = { colorImages } title = { title } /> ;
378+ return < ColorImageCarouselItems images = { colorImages } title = { title } aspectRatio = { aspectRatio } /> ;
347379}
0 commit comments