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
|
|
|
|
|
|
|
export type LightBoxProps = {
|
|
|
|
setState:
|
|
|
|
| Dispatch<SetStateAction<boolean>>
|
|
|
|
| Dispatch<SetStateAction<boolean | undefined>>;
|
|
|
|
state: boolean;
|
2022-03-18 12:51:48 +00:00
|
|
|
images: string[];
|
|
|
|
index: number;
|
|
|
|
setIndex: Dispatch<SetStateAction<number>>;
|
2022-03-18 00:54:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function LightBox(props: LightBoxProps): JSX.Element {
|
2022-03-18 12:51:48 +00:00
|
|
|
const { state, setState, images, index, setIndex } = props;
|
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)}
|
|
|
|
imagePadding={50}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</>
|
2022-03-18 00:54:10 +00:00
|
|
|
);
|
|
|
|
}
|