Skip to content

Commit

Permalink
feat: add NextImageLightbox component
Browse files Browse the repository at this point in the history
  • Loading branch information
rizqitsani committed Apr 24, 2023
1 parent 3793a63 commit ad75507
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/components/NextImageLightbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react';
import Lightbox from 'react-image-lightbox-rotation';

import 'react-image-lightbox-rotation/style.css';

import NextImage from '@/components/NextImage';

import { ExtractProps } from '@/types/helper';

type NextImageLightboxProps = {
src: string;
} & ExtractProps<typeof NextImage>;

export default function NextImageLightbox(props: NextImageLightboxProps) {
const [isOpen, setIsOpen] = React.useState(false);

return (
<div className='cursor-zoom-in'>
<NextImage onClick={() => setIsOpen(true)} {...props} />
{isOpen && (
<Lightbox
mainSrc={props.src}
rotate={0}
onCloseRequest={() => setIsOpen(false)}
/>
)}
</div>
);
}

1 comment on commit ad75507

@vercel
Copy link

@vercel vercel bot commented on ad75507 Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.