Skip to content

Commit a1c3b55

Browse files
committed
refactor(AvatarUpload): Rewrite zoom event,align the current item index.
1. Make the hover style of the delete button more prominent, 2. Rewrite zoom onclick event and set stopPropagation.
1 parent c0496e5 commit a1c3b55

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/BootstrapBlazor/Components/Upload/AvatarUpload.razor

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
{
1717
<div @key="item" class="@GetItemClassString()" id="@item.ValidateId" style="@ItemStyleString">
1818
<Avatar Url="@item.PrevUrl" />
19-
<div class="upload-item-actions">
20-
<span class="upload-item-delete" @onclick="@(e => OnFileDelete(item))">
19+
<div class="upload-item-actions" @onclick="@(() => Preview(item.ValidateId ?? ""))">
20+
<span class="upload-item-delete" @onclick="@(e => OnFileDelete(item))"
21+
@onclick:stopPropagation="true">
2122
<i class="@DeleteIcon"></i>
2223
</span>
2324
@if (GetShowProgress(item))

src/BootstrapBlazor/Components/Upload/AvatarUpload.razor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ protected override async Task TriggerOnChanged(UploadFile file)
154154
/// 预览当前头像方法
155155
/// </summary>
156156
/// <returns></returns>
157-
public async Task Preview()
157+
public async Task Preview(string id)
158158
{
159-
if(ShowPreviewList)
159+
if(ShowPreviewList && !string.IsNullOrWhiteSpace(id) && Files.Any(r => r.ValidateId == id))
160160
{
161-
await InvokeVoidAsync("preview", PreviewerId, 0);
161+
await InvokeVoidAsync("preview", PreviewerId, Files.IndexOf(Files.First(r => r.ValidateId == id)));
162162
}
163163
}
164164

src/BootstrapBlazor/Components/Upload/InputUpload.razor.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@
157157
.upload .upload-body.is-avatar .upload-item:hover .upload-item-actions .upload-item-delete {
158158
display: block;
159159
color: var(--bs-danger);
160+
padding: 0.1rem;
161+
border-radius: 0.5rem;
162+
border: 0.1rem solid var(--bs-danger);
163+
}
164+
165+
.upload .upload-body.is-avatar .upload-item:hover .upload-item-actions .upload-item-delete:hover {
166+
color: var(--bs-white);
167+
background-color: var(--bs-danger);
160168
}
161169

162170
.upload .upload-body.is-avatar .upload-item.is-invalid .upload-item-spin {

0 commit comments

Comments
 (0)