Skip to content

Commit 1b1e6b0

Browse files
authored
feat(Gallery): add callback to close action (#330)
1 parent 1427405 commit 1b1e6b0

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/hooks/useGallery/GalleryContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import type {GalleryItemProps} from '../../components';
55
export type GalleryContextType = {
66
openGallery: (items: GalleryItemProps[], initialFileIndex?: number) => void;
77
closeGallery: () => void;
8+
open: boolean;
89
};
910

1011
export const GalleryContext = React.createContext<GalleryContextType>({
1112
openGallery: () => {},
1213
closeGallery: () => {},
14+
open: false,
1315
});

src/hooks/useGallery/GalleryProvider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export const GalleryProvider = ({
4040
closeGallery: () => {
4141
setIsOpen(false);
4242
},
43+
open: isOpen,
4344
}),
44-
[],
45+
[isOpen],
4546
);
4647

4748
return (

src/hooks/useGallery/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ _useGallery hook returns_:
4949
| :----------- | :--------------------------------------------------------- | :----------------------------------- |
5050
| openGallery | `(items: GalleryItem[], initialItemIndex: number) => void` | The function for opening the gallery |
5151
| closeGallery | `() => void` | The function for closing the gallery |
52+
| open | `boolean` | The boolean value of gallery state |
5253

5354
_openGallery function args_:
5455

0 commit comments

Comments
 (0)