fix(SW-272): fixed issue with image sizes and aspect ratio on cards mainly inside mega menu
This commit is contained in:
@@ -21,11 +21,20 @@ export default function Card({
|
||||
className,
|
||||
theme,
|
||||
backgroundImage,
|
||||
imageHeight,
|
||||
imageWidth,
|
||||
onPrimaryButtonClick,
|
||||
onSecondaryButtonClick,
|
||||
}: CardProps) {
|
||||
const { buttonTheme, primaryLinkColor, secondaryLinkColor } = getTheme(theme)
|
||||
|
||||
imageHeight = imageHeight || 320
|
||||
imageWidth =
|
||||
imageWidth ||
|
||||
(backgroundImage
|
||||
? backgroundImage.dimensions.aspectRatio * imageHeight
|
||||
: 420)
|
||||
|
||||
return (
|
||||
<article
|
||||
className={cardVariants({
|
||||
@@ -39,8 +48,8 @@ export default function Card({
|
||||
src={backgroundImage.url}
|
||||
className={styles.image}
|
||||
alt={backgroundImage.meta.alt || backgroundImage.title}
|
||||
width={backgroundImage.dimensions.width || 420}
|
||||
height={backgroundImage.dimensions.height || 320}
|
||||
width={imageWidth}
|
||||
height={imageHeight}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user