Created
February 21, 2022 19:58
-
-
Save serifcolakel/369ce690ea210da6b06ee9b780af1681 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import Link from "next/link"; | |
import Image from "next/image"; | |
import { formatter } from "../utils/helpers"; | |
export const ProductCard = ({ product, state }) => { | |
const { handle, title } = product.node; | |
const { altText, originalSrc } = product.node.images.edges[0].node; | |
const price = !state | |
? product.node.priceRange.minVariantPrice.amount | |
: product.node.priceRange.maxVariantPrice.amount; | |
return ( | |
<Link href={`/products/${handle}`}> | |
<a className="group"> | |
<div className="w-full rounded-3xl bg-gray-200 overflow-hidden"> | |
<div className="relative group-hover:opacity-75 h-72"> | |
<Image | |
src={originalSrc} | |
alt={altText} | |
layout="fill" | |
objectFit="cover" | |
/> | |
</div> | |
</div> | |
<h3 className="mt-4 text-lg font-medium text-gray900">{title}</h3> | |
<p className="mt-1 text-sm text-gray-700">{formatter.format(price)}</p> | |
</a> | |
</Link> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment