-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support PreviewGroup controlled (#65)
* feat: support PreviewGroup controlled * improve if preview re show * rename defaultShowIndex to defaultCurrent and add doc * rename defaultCurrent to current * use useMemo hook to cache previewUrlsKeys * improve calc current key * remove useMemo
- Loading branch information
1 parent
7ba368f
commit d292367
Showing
5 changed files
with
160 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-disable global-require */ | ||
import * as React from 'react'; | ||
import Image from '../src'; | ||
import '../assets/index.less'; | ||
|
||
export default function Base() { | ||
const [visible, setVisible] = React.useState(false); | ||
return ( | ||
<div> | ||
<div> | ||
<button | ||
type="button" | ||
onClick={() => { | ||
setVisible(true); | ||
}} | ||
> | ||
Switch Preview | ||
</button> | ||
</div> | ||
<Image.PreviewGroup | ||
preview={{ | ||
visible, | ||
onVisibleChange: value => { | ||
setVisible(value); | ||
}, | ||
current: 1, | ||
}} | ||
> | ||
<Image | ||
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" | ||
width={200} | ||
/> | ||
<Image wrapperStyle={{ marginRight: 24, width: 200 }} src={require('./images/1.jpeg')} /> | ||
</Image.PreviewGroup> | ||
</div> | ||
); | ||
} |
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,56 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Preview With Controlled 1`] = ` | ||
<div | ||
class="rc-image-preview" | ||
role="document" | ||
> | ||
<div | ||
aria-hidden="true" | ||
style="width: 0px; height: 0px; overflow: hidden; outline: none;" | ||
tabindex="0" | ||
/> | ||
<div | ||
class="rc-image-preview-content" | ||
> | ||
<div | ||
class="rc-image-preview-body" | ||
> | ||
<ul | ||
class="rc-image-preview-operations" | ||
> | ||
<li | ||
class="rc-image-preview-operations-operation" | ||
/> | ||
<li | ||
class="rc-image-preview-operations-operation" | ||
/> | ||
<li | ||
class="rc-image-preview-operations-operation rc-image-preview-operations-operation-disabled" | ||
/> | ||
<li | ||
class="rc-image-preview-operations-operation" | ||
/> | ||
<li | ||
class="rc-image-preview-operations-operation" | ||
/> | ||
</ul> | ||
<div | ||
class="rc-image-preview-img-wrapper" | ||
style="transform: translate3d(0px, 0px, 0);" | ||
> | ||
<img | ||
class="rc-image-preview-img" | ||
src="src1" | ||
style="transform: scale3d(1, 1, 1) rotate(0deg);" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
aria-hidden="true" | ||
style="width: 0px; height: 0px; overflow: hidden; outline: none;" | ||
tabindex="0" | ||
/> | ||
</div> | ||
`; |
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
d292367
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: