"use client" import { AnimatePresence, motion } from "motion/react" import { useEffect, useState } from "react" import { useIntl } from "react-intl" import { IconButton } from "@scandic-hotels/design-system/IconButton" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import Image from "@scandic-hotels/design-system/Image" import { Typography } from "@scandic-hotels/design-system/Typography" import styles from "./fullView.module.css" import type { FullViewProps } from "@/types/components/lightbox/lightbox" export default function FullView({ image, onClose, onNext, onPrev, currentIndex, totalImages, hideLabel, }: FullViewProps) { const intl = useIntl() const [animateLeft, setAnimateLeft] = useState(true) function handleSwipe(offset: number) { if (offset > 30) onPrev() if (offset < -30) onNext() } function handleNext() { setAnimateLeft(true) onNext() } function handlePrev() { setAnimateLeft(false) onPrev() } const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "ArrowLeft") { handlePrev() } else if (e.key === "ArrowRight") { handleNext() } } useEffect(() => { window.addEventListener("keydown", handleKeyDown) return () => { window.removeEventListener("keydown", handleKeyDown) } }) const variants = { initial: (animateLeft: boolean) => ({ opacity: 0, x: animateLeft ? 300 : -300, }), animate: { opacity: 1, x: 0 }, exit: (animateLeft: boolean) => ({ opacity: 0, x: animateLeft ? -300 : 300, }), } return (
{image.caption}