Created
December 20, 2023 22:48
-
-
Save Jerga99/2e85f6053e912ac74e29d6aa65e6e3fb 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 { Product } from "@common/types/products" | |
import { FC } from "react" | |
import Link from "next/link" | |
import Image from "next/legacy/image" | |
import s from "./ProductCArd.module.css" | |
interface Props { | |
product: Product | |
} | |
const placeholderImage = "/product-image-placeholder.svg" | |
const ProductCard: FC<Props> = ({product}) => { | |
return ( | |
<Link legacyBehavior href={`/products/${product.slug}`}> | |
<a className={s.root}> | |
<div className={s.productBg}></div> | |
<div className={s.productTag}> | |
<h3 className={s.productTitle}> | |
<span>{product.name}</span> | |
</h3> | |
<span className={s.productPrice}>14 $</span> | |
</div> | |
{ product.images && ( | |
<Image | |
alt={product.name ?? "Product image"} | |
src={product.images[0].url ?? placeholderImage} | |
height={540} | |
width={540} | |
quality="85" | |
layout="responsive" | |
/> | |
) | |
} | |
</a> | |
</Link> | |
) | |
} | |
export default ProductCard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment