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 a3bae4b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
16 changes: 13 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,19 @@
@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="

Check warning on line 15 in packages/varlet-ui/src/uploader/Uploader.vue

View check run for this annotation

Codecov / codecov/patch

packages/varlet-ui/src/uploader/Uploader.vue#L15

Added line #L15 was not covered by tests
() => {
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: () => 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: () => 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: () => void): VNode[]
}

getLoading(): VarFile[]
Expand Down

0 comments on commit a3bae4b

Please sign in to comment.