Merged in fix/card-width-fix (pull request #1369)
feat(images): calculate width correct using aspect ratio * feat(images): calculate width correct using aspect ratio Approved-by: Erik Tiekstra
This commit is contained in:
@@ -30,25 +30,30 @@ export default function TopImages({ images, destinationName }: TopImageProps) {
|
||||
return (
|
||||
<div className={styles.topImages}>
|
||||
<div className={styles.imageWrapper}>
|
||||
{visibleImages.map((image, index) => (
|
||||
<Image
|
||||
key={image.url}
|
||||
src={image.url}
|
||||
alt={image.meta.alt || image.meta.caption || ""}
|
||||
width={index === 0 ? maxWidth : maxWidth / visibleImages.length}
|
||||
height={Math.ceil(
|
||||
(index === 0 ? maxWidth : maxWidth / visibleImages.length) /
|
||||
image.dimensions.aspectRatio
|
||||
)}
|
||||
focalPoint={image.focalPoint}
|
||||
className={`${styles.image} ${images.length > 1 ? styles.clickable : ""}`}
|
||||
onClick={() =>
|
||||
images.length
|
||||
? setLightboxState({ open: true, activeIndex: index })
|
||||
: null
|
||||
}
|
||||
/>
|
||||
))}
|
||||
{visibleImages.map((image, index) => {
|
||||
const width = index === 0 ? maxWidth : maxWidth / visibleImages.length
|
||||
const height =
|
||||
image.dimensions.aspectRatio >= 1
|
||||
? Math.ceil(width / image.dimensions.aspectRatio)
|
||||
: Math.ceil(width * image.dimensions.aspectRatio)
|
||||
|
||||
return (
|
||||
<Image
|
||||
key={image.url}
|
||||
src={image.url}
|
||||
alt={image.meta.alt || image.meta.caption || ""}
|
||||
width={width}
|
||||
height={height}
|
||||
focalPoint={image.focalPoint}
|
||||
className={`${styles.image} ${images.length > 1 ? styles.clickable : ""}`}
|
||||
onClick={() =>
|
||||
images.length
|
||||
? setLightboxState({ open: true, activeIndex: index })
|
||||
: null
|
||||
}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
{images.length > 1 && (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user