-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add image component * fix: lint fix * fix: test fix
- Loading branch information
Showing
24 changed files
with
3,285 additions
and
0 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,14 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import Image from '@/src/image/index.ts'; | ||
|
||
describe('Image 组件测试', () => { | ||
test('Image 测试', () => { | ||
const wrapper = mount({ | ||
render() { | ||
return <Image src="https://tdesign.gtimg.com/demo/demo-image-1.png" />; | ||
}, | ||
}); | ||
|
||
expect(wrapper.exists()).toBe(true); | ||
}); | ||
}); |
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,68 @@ | ||
<template> | ||
<t-space :size="32"> | ||
<t-space direction="vertical"> | ||
<strong :style="{ fontSize: '20px' }">有遮罩</strong> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
:style="{ width: '284px', height: '160px' }" | ||
:overlay-content="renderMask" | ||
/> | ||
</t-space> | ||
<t-space direction="vertical"> | ||
<strong :style="{ fontSize: '20px' }">无遮罩</strong> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
:style="{ width: '284px', height: '160px' }" | ||
:overlay-content="renderButton" | ||
/> | ||
</t-space> | ||
</t-space> | ||
</template> | ||
|
||
<script setup lang="jsx"> | ||
import { PrintIcon } from 'tdesign-icons-vue-next'; | ||
import { Tag } from 'tdesign-vue-next'; | ||
const renderMask = ( | ||
<div | ||
style={{ | ||
background: 'rgba(0,0,0,.4)', | ||
height: '100%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
fontSize: '14px', | ||
lineHeight: '22px', | ||
}} | ||
> | ||
<Tag | ||
shape="mark" | ||
theme="warning" | ||
style={{ | ||
borderRadius: '3px', | ||
background: 'transparent', | ||
color: '#fff', | ||
}} | ||
> | ||
<PrintIcon size="16" /> 高清 | ||
</Tag> | ||
</div> | ||
); | ||
const renderButton = ( | ||
<Tag | ||
shape="mark" | ||
theme="warning" | ||
style={{ | ||
position: 'absolute', | ||
right: '8px', | ||
bottom: '8px', | ||
borderRadius: '3px', | ||
background: 'rgba(236,242,254,1)', | ||
color: 'rgba(0,82,217,1)', | ||
}} | ||
> | ||
<PrintIcon size="16" /> 高清 | ||
</Tag> | ||
); | ||
</script> |
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,25 @@ | ||
<template> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
:style="{ width: '284px', height: '160px' }" | ||
:overlay-content="renderMask" | ||
overlay-trigger="hover" | ||
/> | ||
</template> | ||
|
||
<script setup lang="jsx"> | ||
const renderMask = ( | ||
<div | ||
style={{ | ||
background: 'rgba(0,0,0,.4)', | ||
color: '#fff', | ||
height: '100%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
预览 | ||
</div> | ||
); | ||
</script> |
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,16 @@ | ||
<template> | ||
<t-space :break-line="true" :size="16"> | ||
<t-space v-for="item in mode" :key="item" direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
:fit="item" | ||
:style="{ width: '120px', height: '120px' }" | ||
/> | ||
<span>{{ item }}</span> | ||
</t-space> | ||
</t-space> | ||
</template> | ||
|
||
<script setup> | ||
const mode = ['fill', 'contain', 'cover', 'none', 'scale-down']; | ||
</script> |
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,102 @@ | ||
<template> | ||
<t-space direction="vertical" :style="{ width: '100%' }"> | ||
<t-space break-line> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="cover" | ||
position="center" | ||
:style="{ width: '120px', height: '120px' }" | ||
/> | ||
<span>cover center</span> | ||
</t-space> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="cover" | ||
:style="{ width: '120px', height: '120px' }" | ||
position="left" | ||
/> | ||
<span>cover left</span> | ||
</t-space> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="cover" | ||
:style="{ width: '120px', height: '120px' }" | ||
position="right" | ||
/> | ||
<span>cover right</span> | ||
</t-space> | ||
</t-space> | ||
<t-space :style="{ marginTop: 20 }" break-line> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="cover" | ||
:style="{ width: '280px', height: '120px' }" | ||
position="top" | ||
/> | ||
<span>cover top</span> | ||
</t-space> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="cover" | ||
:style="{ width: '280px', height: '120px' }" | ||
position="bottom" | ||
/> | ||
<span>cover bottom</span> | ||
</t-space> | ||
</t-space> | ||
<t-space :style="{ marginTop: 20 }" break-line> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="contain" | ||
:style="{ width: '120px', height: '200px' }" | ||
position="top" | ||
/> | ||
<span>contain top</span> | ||
</t-space> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="contain" | ||
:style="{ width: '120px', height: '200px' }" | ||
position="bottom" | ||
/> | ||
<span>contain bottom</span> | ||
</t-space> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="contain" | ||
:style="{ width: '120px', height: '200px' }" | ||
position="center" | ||
/> | ||
<span>contain center</span> | ||
</t-space> | ||
<t-space :style="{ marginTop: 20 }" break-line> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="contain" | ||
:style="{ width: '280px', height: '120px' }" | ||
position="left" | ||
/> | ||
<span>contain left</span> | ||
</t-space> | ||
<t-space direction="vertical" align="start"> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
fit="contain" | ||
:style="{ width: '280px', height: '120px' }" | ||
position="right" | ||
/> | ||
<span>contain right</span> | ||
</t-space> | ||
</t-space> | ||
</t-space> | ||
</t-space> | ||
</template> |
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,27 @@ | ||
<template> | ||
<t-image | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
:style="{ width: '284px', height: '160px' }" | ||
:gallery="true" | ||
:overlay-content="label" | ||
/> | ||
</template> | ||
|
||
<script setup lang="jsx"> | ||
import { Tag } from 'tdesign-vue-next'; | ||
const label = ( | ||
<Tag | ||
shape="mark" | ||
theme="warning" | ||
style={{ | ||
margin: '8px', | ||
borderRadius: '3px', | ||
background: 'rgba(236,242,254,1)', | ||
color: 'rgba(0,82,217,1)', | ||
}} | ||
> | ||
标签一 | ||
</Tag> | ||
); | ||
</script> |
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,28 @@ | ||
<template> | ||
<t-space :key="loadingCount" direction="vertical"> | ||
<t-space :break-line="true" :style="{ height: '240px', 'overflow-y': 'scroll' }"> | ||
<t-image | ||
v-for="item in list" | ||
:key="item" | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
:style="{ width: '230px', height: '120px' }" | ||
:lazy="true" | ||
/> | ||
</t-space> | ||
<t-button variant="outline" :icon="renderRefreshIcon" @click="loadingCount = loadingCount + 1"> | ||
重演 lazy load | ||
</t-button> | ||
</t-space> | ||
</template> | ||
|
||
<script setup lang="jsx"> | ||
import { ref } from 'vue'; | ||
import { RefreshIcon } from 'tdesign-icons-vue-next'; | ||
const loadingCount = ref(0); | ||
const list = ref(Array.from({ length: 24 }).map((_, index) => index)); | ||
const renderRefreshIcon = () => { | ||
return <RefreshIcon />; | ||
}; | ||
</script> |
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,51 @@ | ||
<template> | ||
<t-space direction="vertical"> | ||
<t-image | ||
:key="loadingCount" | ||
src="https://tdesign.gtimg.com/demo/demo-image-1.png" | ||
:style="{ width: '284px', height: '160px' }" | ||
:lazy="true" | ||
:placeholder="renderPlaceholder" | ||
:loading="renderLoading" | ||
/> | ||
<t-button variant="outline" :icon="renderRefreshIcon" @click="loadingCount = loadingCount + 1"> | ||
重演 lazy load | ||
</t-button> | ||
</t-space> | ||
</template> | ||
|
||
<script setup lang="jsx"> | ||
import { ref } from 'vue'; | ||
import { RefreshIcon } from 'tdesign-icons-vue-next'; | ||
import { Loading } from 'tdesign-vue-next'; | ||
const loadingCount = ref(0); | ||
const renderPlaceholder = <img width="100%" height="100%" src="https://tdesign.gtimg.com/demo/demo-image-5.png" />; | ||
const renderLoading = ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
width: '100%', | ||
height: '100%', | ||
background: 'rgba(255,255,255,.4)', | ||
backdropFilter: 'blur(10px)', | ||
}} | ||
> | ||
<Loading | ||
delay={0} | ||
fullscreen={false} | ||
indicator | ||
inheritColor={false} | ||
loading | ||
preventScrollThrough | ||
showOverlay | ||
size="small" | ||
/> | ||
</div> | ||
); | ||
const renderRefreshIcon = () => { | ||
return <RefreshIcon />; | ||
}; | ||
</script> |
Oops, something went wrong.