commerce/components/layout/product-grid-items.tsx
2025-03-15 11:15:46 +00:00

42 lines
1.2 KiB
TypeScript

import Grid from "components/grid";
import { GridTileImage } from "components/grid/tile";
import { Product } from "lib/store/types";
import { getImageUrl } from "lib/utils/image";
import Link from "next/link";
export default function ProductGridItems({
products,
}: {
products: Product[];
}) {
return (
<>
{products.map((product) => (
<Grid.Item key={product.handle} className="animate-fadeIn">
<Link
className="relative inline-block h-full w-full"
href={`/product/${product.handle}`}
prefetch={true}
>
<GridTileImage
alt={product.title}
label={{
title: product.title,
amount: product.priceRange.maxVariantPrice.amount,
currencyCode: product.priceRange.maxVariantPrice.currencyCode,
}}
src={
product.featuredImage
? getImageUrl(product.featuredImage.source)
: ""
}
fill
sizes="(min-width: 768px) 33vw, (min-width: 640px) 50vw, 100vw"
/>
</Link>
</Grid.Item>
))}
</>
);
}