2022-03-18 13:01:25 +00:00
|
|
|
import { useMediaMobile } from "hooks/useMediaQuery";
|
2022-03-18 00:54:10 +00:00
|
|
|
import { Dispatch, SetStateAction } from "react";
|
2022-03-18 12:51:48 +00:00
|
|
|
import Lightbox from "react-image-lightbox";
|
2022-03-18 00:54:10 +00:00
|
|
|
|
2022-04-03 08:34:21 +00:00
|
|
|
interface Props {
|
2022-03-18 00:54:10 +00:00
|
|
|
setState:
|
2022-03-27 15:01:14 +00:00
|
|
|
| Dispatch<SetStateAction<boolean | undefined>>
|
|
|
|
| Dispatch<SetStateAction<boolean>>;
|
2022-03-18 00:54:10 +00:00
|
|
|
state: boolean;
|
2022-03-18 12:51:48 +00:00
|
|
|
images: string[];
|
|
|
|
index: number;
|
|
|
|
setIndex: Dispatch<SetStateAction<number>>;
|
2022-04-03 08:34:21 +00:00
|
|
|
}
|
2022-03-18 00:54:10 +00:00
|
|
|
|
2022-04-03 08:34:21 +00:00
|
|
|
export default function LightBox(props: Props): JSX.Element {
|
2022-03-18 12:51:48 +00:00
|
|
|
const { state, setState, images, index, setIndex } = props;
|
2022-03-18 13:01:25 +00:00
|
|
|
const mobile = useMediaMobile();
|
|
|
|
|
2022-03-18 00:54:10 +00:00
|
|
|
return (
|
2022-03-18 12:51:48 +00:00
|
|
|
<>
|
|
|
|
{state && (
|
|
|
|
<Lightbox
|
|
|
|
reactModalProps={{
|
|
|
|
parentSelector: () => document.getElementById("MyAppLayout"),
|
|
|
|
}}
|
|
|
|
mainSrc={images[index]}
|
|
|
|
prevSrc={index > 0 ? images[index - 1] : undefined}
|
|
|
|
nextSrc={index < images.length ? images[index + 1] : undefined}
|
|
|
|
onMovePrevRequest={() => setIndex(index - 1)}
|
|
|
|
onMoveNextRequest={() => setIndex(index + 1)}
|
|
|
|
imageCaption=""
|
|
|
|
imageTitle=""
|
|
|
|
onCloseRequest={() => setState(false)}
|
2022-03-18 13:01:25 +00:00
|
|
|
imagePadding={mobile ? 0 : 70}
|
2022-03-18 12:51:48 +00:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</>
|
2022-03-18 00:54:10 +00:00
|
|
|
);
|
|
|
|
}
|