Skip to content

Commit

Permalink
feat(ui/uploader): support remove button slot
Browse files Browse the repository at this point in the history
  • Loading branch information
chouchouji committed Dec 24, 2024
1 parent 6dd2257 commit 9907100
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/varlet-ui/src/uploader/Uploader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
@click="preview(f)"
>
<div :class="n('file-name')">{{ f.name || f.url }}</div>
<div :class="n('file-close')" v-if="removable" @click.stop="handleRemove(f)">
<var-icon :class="n('file-close-icon')" var-uploader-cover name="delete" />
</div>
<slot name="remove-button" v-if="removable" :remove="handleRemove(f)">
<div :class="n('file-close')" @click.stop="handleRemove(f)">
<var-icon :class="n('file-close-icon')" var-uploader-cover name="delete" />
</div>
</slot>
<img
role="img"
:class="n('file-cover')"
Expand Down
1 change: 1 addition & 0 deletions packages/varlet-ui/src/uploader/docs/en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ const files = ref([
| --- | --- | --- |
| `default` | Upload action content | `-` |
| `extra-message` | Extra message | `-` |
| `remove-button` | Remove button | `remove: (file: VarFile) => void` |

### Style Variables

Expand Down
1 change: 1 addition & 0 deletions packages/varlet-ui/src/uploader/docs/zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ const files = ref([
| --- | --- | --- |
| `default` | 上传按钮内容 | `-` |
| `extra-message` | 附加信息 | `-` |
| `remove-button` | 删除按钮 | `remove: (file: VarFile) => void` |

### 样式变量

Expand Down
1 change: 1 addition & 0 deletions packages/varlet-ui/types/uploader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class Uploader extends VarComponent {
$slots: {
default(): VNode[]
'extra-message'(): VNode[]
'remove-button'(remove: (file: VarFile) => void): VNode[]
}

getLoading(): VarFile[]
Expand Down

0 comments on commit 9907100

Please sign in to comment.