fix(SW-272): fixed issue with image sizes and aspect ratio on cards mainly inside mega menu

This commit is contained in:
Erik Tiekstra
2024-09-27 13:38:56 +02:00
parent aa390bd171
commit d2121a3fed
4 changed files with 32 additions and 10 deletions

View File

@@ -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>
)}