mirror of
https://github.com/vercel/commerce.git
synced 2025-06-18 05:01:22 +00:00
Avoid repeating placeholder image reference and move to a variable
This commit is contained in:
parent
4c03104f6a
commit
25129c699c
@ -31,6 +31,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,
|
||||||
@ -57,7 +58,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>
|
||||||
@ -80,7 +81,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.image}
|
className={s.image}
|
||||||
width={imgWidth}
|
width={imgWidth}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user