-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add previewer #55
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/react-component/image/fjs0x9hs4 |
Codecov Report
@@ Coverage Diff @@
## master #55 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 6 +1
Lines 220 239 +19
Branches 57 61 +4
=========================================
+ Hits 220 239 +19
Continue to review full report at Codecov.
|
return ( | ||
<button | ||
onClick={() => { | ||
Image.previewer( |
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.
方法调用不是好的范式,要解决的问题是 需要预览的内容和预览前的内容是不同的
。
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.
有些场景去要通过点击“预览”按钮触发预览
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.
方法调用不是好的范式,要解决的问题是 需要预览的内容和预览前的内容是不同的
,而不是需要主动触发预览功能。
嗯,这个 PR 解决的核心的问题不是 需要预览的内容和预览前的内容是不同的,主动预览在不需要 |
这样如何,有 trigger 就隐藏 image。 |
一般般,举个例子,比如 现在默认是新标签打开,如果我想在 onPreview = file => Image.previewer(file.url) 如果用 onPreview = file => Modal.Confirm({ content: <img src={file.url} />, footer: null }) |
<Image.PreviewGroup previewVisible={this.state.previewVisible} showChildren={false} onPreviewVisibleChange={}>
<Image src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" />
<Image src="https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*P0S-QIRUbsUAAAAAAAAAAABkARQnAQ" />
</Image.PreviewGroup> 那最好是做成受控模式,静态方法调用的语法糖对于 Context 场景(redux/国际化/prefixCls)都有很多问题,不建议再开新的了。 |
我也不赞成做成静态方法,看起来的确是 Group 的受控场景。 |
|
应该和 ant-design/ant-design#27273 这个需求更类似。 |
fixes ant-design/ant-design#28321