diff --git a/.prettierrc.json b/.prettierrc.json index 33dade2..fedda30 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,7 +1,7 @@ { - "semi": false, - "singleQuote": true, - "jsxSingleQuote": true, - "trailingComma": "all", - "printWidth": 80 - } \ No newline at end of file + "semi": false, + "singleQuote": true, + "jsxSingleQuote": true, + "trailingComma": "all", + "printWidth": 80 +} \ No newline at end of file diff --git a/src/components/organisms/ImageGallery/ImageGallery.tsx b/src/components/organisms/ImageGallery/ImageGallery.tsx index 1abf9f7..5085bb0 100644 --- a/src/components/organisms/ImageGallery/ImageGallery.tsx +++ b/src/components/organisms/ImageGallery/ImageGallery.tsx @@ -2,7 +2,7 @@ import { useRef } from 'react' import Slider from 'react-slick' import { useShallow } from 'zustand/react/shallow' import clsx from 'clsx' -import Lightbox, { ZoomRef } from 'yet-another-react-lightbox' +import Lightbox, { ControllerRef, ZoomRef } from 'yet-another-react-lightbox' import 'yet-another-react-lightbox/styles.css' import Zoom from 'yet-another-react-lightbox/plugins/zoom' import 'slick-carousel/slick/slick.css' @@ -21,8 +21,8 @@ interface Props { function ImageGallery({ images }: Props) { const zoomRef = useRef(null) const { - index: galleryIndex, - setIndex: setGalleryIndex, + id: galleryId, + setId: setGalleryId, isOpen, setIsOpen, isOpeningWithZoom, @@ -33,8 +33,8 @@ function ImageGallery({ images }: Props) { setZoom, } = useImageGalleryStore( useShallow((state) => ({ - index: state.index, - setIndex: state.setIndex, + id: state.id, + setId: state.setId, isOpeningWithZoom: state.isOpeningWithZoom, isOpen: state.isOpen, setIsOpen: state.setIsOpen, @@ -46,10 +46,12 @@ function ImageGallery({ images }: Props) { })), ) const lighboxImages = images.map((i) => ({ src: i.url })) + const ref = useRef(null) + const galleryIndex = images.findIndex((i) => i.id === galleryId) - const handleOnImageClick = (index: number) => { + const handleOnImageClick = (index: string) => { setIsOpeningWithZoom(true) - setGalleryIndex(index) + setGalleryId(index) setIsOpen(true) } @@ -64,7 +66,7 @@ function ImageGallery({ images }: Props) {