-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: separate Gallery and CustomGallery
closes #16
- Loading branch information
Showing
7 changed files
with
114 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import PhotoswipeUIDefault from 'photoswipe/dist/photoswipe-ui-default' | ||
import React, { useRef, FC } from 'react' | ||
import PropTypes, { InferProps } from 'prop-types' | ||
import { CustomGallery, DefaultLayout, layoutPropTypes, LayoutProps } from '.' | ||
|
||
const propTypes = { | ||
children: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node, | ||
]).isRequired, | ||
options: PropTypes.object, | ||
...layoutPropTypes, | ||
} | ||
|
||
type Props = InferProps<typeof propTypes> | ||
|
||
export interface GalleryProps extends Omit<Props & LayoutProps, 'options'> { | ||
options?: PhotoSwipe.Options & PhotoswipeUIDefault.Options | ||
} | ||
|
||
export const Gallery: FC<GalleryProps> = ({ | ||
children, | ||
options, | ||
...restProps | ||
}) => { | ||
const defaultLayoutRef = useRef<HTMLElement>() | ||
return ( | ||
<CustomGallery | ||
layoutRef={defaultLayoutRef} | ||
ui={PhotoswipeUIDefault} | ||
options={options} | ||
> | ||
{children} | ||
<DefaultLayout {...restProps} ref={defaultLayoutRef} /> | ||
</CustomGallery> | ||
) | ||
} | ||
|
||
// @ts-ignore | ||
Gallery.propTypes = propTypes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './photoswipe-layout' | ||
export * from './gallery' | ||
export * from './gallery-custom' | ||
export * from './gallery-default' | ||
export * from './item' | ||
export * from './types' |