mirror of
https://github.com/vercel/commerce.git
synced 2025-06-18 13:11:23 +00:00
Avoid repeating placeholder image reference and move to a variable
This commit is contained in:
parent
da11c82b7b
commit
d23cbdb3c8
@ -32,6 +32,7 @@ const ProductCard: FC<Props> = ({
|
|||||||
imgLayout = 'responsive',
|
imgLayout = 'responsive',
|
||||||
}) => {
|
}) => {
|
||||||
const src = p.images.edges?.[0]?.node?.urlOriginal!
|
const src = p.images.edges?.[0]?.node?.urlOriginal!
|
||||||
|
const placeholderImg = '/product-img-placeholder.svg';
|
||||||
const { price } = usePrice({
|
const { price } = usePrice({
|
||||||
amount: p.prices?.price?.value,
|
amount: p.prices?.price?.value,
|
||||||
baseAmount: p.prices?.retailPrice?.value,
|
baseAmount: p.prices?.retailPrice?.value,
|
||||||
@ -58,7 +59,7 @@ const ProductCard: FC<Props> = ({
|
|||||||
layout={imgLayout}
|
layout={imgLayout}
|
||||||
loading={imgLoading}
|
loading={imgLoading}
|
||||||
priority={imgPriority}
|
priority={imgPriority}
|
||||||
src={p.images.edges?.[0]?.node.urlOriginal! || '/product-img-placeholder.svg'}
|
src={p.images.edges?.[0]?.node.urlOriginal! || placeholderImg}
|
||||||
alt={p.images.edges?.[0]?.node.altText || 'Product Image'}
|
alt={p.images.edges?.[0]?.node.altText || 'Product Image'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -81,7 +82,7 @@ const ProductCard: FC<Props> = ({
|
|||||||
<div className={s.imageContainer}>
|
<div className={s.imageContainer}>
|
||||||
<Image
|
<Image
|
||||||
quality="85"
|
quality="85"
|
||||||
src={src || '/product-img-placeholder.svg'}
|
src={src || placeholderImg}
|
||||||
alt={p.name}
|
alt={p.name}
|
||||||
className={s.productImage}
|
className={s.productImage}
|
||||||
width={imgWidth}
|
width={imgWidth}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user