-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ImageViewer): support native svg preview (#2958)
* feat(image-viewer): support native svg display * fix: optimiza element selector * chore: fix spell check --------- Co-authored-by: Heising <[email protected]>
- Loading branch information
1 parent
53404f6
commit 5118760
Showing
9 changed files
with
396 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React from 'react'; | ||
import { ImageViewer, Image } from 'tdesign-react'; | ||
import { BrowseIcon } from 'tdesign-icons-react'; | ||
|
||
const img = [ | ||
{ | ||
mainImage: 'https://tdesign.gtimg.com/demo/tdesign-logo.svg', | ||
isSvg: true, | ||
}, | ||
{ | ||
mainImage: 'https://tdesign.gtimg.com/demo/demo-image-1.png', | ||
}, | ||
]; | ||
|
||
const Svg = () => { | ||
const trigger = ({ open }) => { | ||
const mask = ( | ||
<div | ||
style={{ | ||
background: 'rgba(0,0,0,.6)', | ||
color: '#fff', | ||
height: '100%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
onClick={open} | ||
> | ||
<span> | ||
<BrowseIcon size="16px" name={'browse'} /> 预览 | ||
</span> | ||
</div> | ||
); | ||
|
||
return ( | ||
<Image | ||
alt={'test'} | ||
src={img[0].mainImage} | ||
overlayContent={mask} | ||
overlayTrigger="hover" | ||
fit="contain" | ||
style={{ | ||
width: 160, | ||
height: 160, | ||
border: '4px solid var(--td-bg-color-secondarycontainer)', | ||
borderRadius: 'var(--td-radius-medium)', | ||
backgroundColor: '#fff', | ||
}} | ||
/> | ||
); | ||
}; | ||
return ( | ||
<div | ||
style={{ | ||
position: 'fixed', | ||
inset: 0, | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<div> | ||
<ImageViewer trigger={trigger} images={img} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Svg; |
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
Oops, something went wrong.