mirror of
https://github.com/aljazceru/landscape-template.git
synced 2026-01-07 08:24:21 +01:00
33 lines
664 B
TypeScript
33 lines
664 B
TypeScript
|
|
import { useUpdateEffect } from '@react-hookz/web';
|
|
import { useState } from 'react';
|
|
|
|
import FsLightbox from 'fslightbox-react';
|
|
|
|
interface Props {
|
|
images: string[];
|
|
isOpen?: boolean;
|
|
onClose?: () => void;
|
|
initOpenIndex?: number;
|
|
}
|
|
|
|
export default function Lightbox(props: Props) {
|
|
const [toggler, setToggler] = useState(false);
|
|
|
|
useUpdateEffect(() => {
|
|
if (props.isOpen)
|
|
setToggler(!toggler)
|
|
}, [props.isOpen])
|
|
|
|
|
|
|
|
return (
|
|
<FsLightbox
|
|
toggler={toggler}
|
|
onClose={props.onClose}
|
|
sources={props.images}
|
|
sourceIndex={props.initOpenIndex}
|
|
/>
|
|
)
|
|
}
|