"use client" import { memo, useState } from "react" import { Button as ButtonRAC } from "react-aria-components" import { useIntl } from "react-intl" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import Image from "@scandic-hotels/design-system/Image" import ImageFallback from "@scandic-hotels/design-system/ImageFallback" import Lightbox from "@scandic-hotels/design-system/Lightbox" import { Typography } from "@scandic-hotels/design-system/Typography" import styles from "./imageGallery.module.css" import type { ImageGalleryProps } from "@/types/components/imageGallery" function ImageGallery({ images, title, fill, height = 280, sizes, hideLabel, imageCountPosition = "bottom", }: ImageGalleryProps) { const intl = useIntl() const [isOpen, setIsOpen] = useState(false) const [imageError, setImageError] = useState(false) const imageProps = fill ? { fill, sizes } : { height, width: height * 1.5 } if (!images || images.length === 0 || imageError) { return } const firstImage = images[0] return ( <>
{firstImage.alt} setImageError(true)} {...imageProps} /> {images.length} setIsOpen(true)} aria-label={intl.formatMessage({ defaultMessage: "Open image gallery", })} />
{isOpen ? ( setIsOpen(false)} hideLabel={hideLabel} /> ) : null} ) } export default memo(ImageGallery)