Skip to content

Commit

Permalink
docs(ui/uploader): add remove button slot example
Browse files Browse the repository at this point in the history
  • Loading branch information
chouchouji committed Dec 25, 2024
1 parent 1fb3faa commit 9958ac7
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 1 deletion.
38 changes: 38 additions & 0 deletions packages/varlet-ui/src/uploader/docs/en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,44 @@ const files = ref([
</style>
```

### Custom Remove Button

```html
<script setup>
import { ref } from 'vue'
const files = ref([
{
url: 'https://varletjs.org/cat.jpg',
cover: 'https://varletjs.org/cat.jpg'
},
{
url: 'https://www.runoob.com/try/demo_source/mov_bbb.mp4',
cover: 'https://varletjs.org/cover.jpg'
}
])
</script>

<template>
<var-uploader v-model="files">
<template #remove-button="{ remove }">
<div class="custom-remove-button">
<var-icon color="#fff" name="window-close" @click.stop="remove"></var-icon>
</div>
</template>
</var-uploader>
</template>

<style>
.custom-remove-button {
position: absolute;
top: 0;
right: 0;
z-index: 3;
}
</style>
```

## API

### Props
Expand Down
38 changes: 38 additions & 0 deletions packages/varlet-ui/src/uploader/docs/zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,44 @@ const files = ref([
</style>
```

### 自定义删除按钮

```html
<script setup>
import { ref } from 'vue'
const files = ref([
{
url: 'https://varletjs.org/cat.jpg',
cover: 'https://varletjs.org/cat.jpg'
},
{
url: 'https://www.runoob.com/try/demo_source/mov_bbb.mp4',
cover: 'https://varletjs.org/cover.jpg'
}
])
</script>

<template>
<var-uploader v-model="files">
<template #remove-button="{ remove }">
<div class="custom-remove-button">
<var-icon color="#fff" name="window-close" @click.stop="remove"></var-icon>
</div>
</template>
</var-uploader>
</template>

<style>
.custom-remove-button {
position: absolute;
top: 0;
right: 0;
z-index: 3;
}
</style>
```

## API

### 属性
Expand Down
16 changes: 15 additions & 1 deletion packages/varlet-ui/src/uploader/example/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,14 @@ function handleActionClick(chooseFile) {
</var-uploader>
</var-space>

<var-space></var-space>
<app-type>{{ t('removeButtonSlot') }}</app-type>
<var-uploader v-model="values.files2">
<template #remove-button="{ remove }">
<div class="custom-remove-button">
<var-icon color="#fff" name="window-close" @click.stop="remove"></var-icon>
</div>
</template>
</var-uploader>
</template>

<style scoped lang="less">
Expand All @@ -235,4 +242,11 @@ function handleActionClick(chooseFile) {
font-size: 12px;
object-fit: cover;
}
.custom-remove-button {
position: absolute;
top: 0;
right: 0;
z-index: 3;
}
</style>
1 change: 1 addition & 0 deletions packages/varlet-ui/src/uploader/example/locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export default {
useProgress: 'Use Progress',
beforeFilter: 'File List Filter',
clickAction: 'Upload Button Click Event',
removeButtonSlot: 'Custom Remove Button',
}
1 change: 1 addition & 0 deletions packages/varlet-ui/src/uploader/example/locale/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export default {
useProgress: '使用进度条',
beforeFilter: '文件列表过滤',
clickAction: '上传按钮点击事件',
removeButtonSlot: '自定义删除按钮',
}

0 comments on commit 9958ac7

Please sign in to comment.