diff --git a/components/officeLightbox/OfficeLightbox.tsx b/components/officeLightbox/OfficeLightbox.tsx index 3e45c04..2ae23dd 100644 --- a/components/officeLightbox/OfficeLightbox.tsx +++ b/components/officeLightbox/OfficeLightbox.tsx @@ -1,10 +1,12 @@ 'use client' +import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline'; +import { Mouse } from '@playwright/test'; import Image from 'next/image'; import React, { useState } from 'react'; const OfficeLightbox: React.FC = () => { const [selectedImage, setSelectedImage] = useState(null); - + const [currentIndex, setCurrentIndex] = useState(0); const images = [ '/office1.jpeg', '/office5.jpeg', @@ -13,28 +15,45 @@ const OfficeLightbox: React.FC = () => { '/office6.jpeg', '/office8.jpeg' ]; - const openLightbox = (image: string) => { + const openLightbox = (image: string, index: number) => { setSelectedImage(image); + setCurrentIndex(index); }; const closeLightbox = () => { setSelectedImage(null); }; + const handlePrev = (event: React.MouseEvent) => { + event.stopPropagation(); + setCurrentIndex(prevIndex => (prevIndex === 0 ? images.length -1 : prevIndex -1)); + setSelectedImage(images[currentIndex -1 < 0 ? images.length -1 : currentIndex -1]); + }; + const handleNext = (event: React.MouseEvent) => { + event.stopPropagation(); + setCurrentIndex(prevIndex => (prevIndex === images.length -1 ? 0 : prevIndex +1)); + setSelectedImage(images[currentIndex +1 >= images.length ? 0 : currentIndex +1]) + } return ( -
-
+
+
+

Coworking copy

+

Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorem quo quibusdam ipsam aliquid sequi, qui alias. Repellat quasi exercitationem impedit, officia odio veniam pariatur temporibus reprehenderit aspernatur, perferendis soluta quaerat.

+
+
+
{images.map((image, index) => ( {`Image openLightbox(image)} + onClick={() => openLightbox(image, index)} className="cursor-pointer" width={600} height={275} /> ))}
+
{/* Render the lightbox when an image is selected */} {selectedImage && ( @@ -47,8 +66,20 @@ const OfficeLightbox: React.FC = () => { src={selectedImage} alt="Selected Image" fill={true} - className="object-contain p-2"/> + className="object-contain p-1"/>
+ +
)}
@@ -56,3 +87,4 @@ const OfficeLightbox: React.FC = () => { }; export default OfficeLightbox; +