Skip to content

Commit dd7cfeb

Browse files
committed
feat(tpl): improve uploading indicator
- move upload progress bar after path list - add uploading label
1 parent 5536e53 commit dd7cfeb

File tree

3 files changed

+65
-15
lines changed

3 files changed

+65
-15
lines changed

src/tpl/frontend/index.css

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ html::before {
101101
content: '';
102102
position: absolute;
103103
position: fixed;
104-
z-index: 1;
104+
z-index: 2;
105105
left: 0;
106106
top: 0;
107107
right: 0;
@@ -195,6 +195,53 @@ html.dragging::before {
195195
background: #f7f7f7;
196196
}
197197

198+
.upload-status {
199+
visibility: hidden;
200+
position: absolute;
201+
position: sticky;
202+
z-index: 1;
203+
left: 0;
204+
top: 0;
205+
width: 100%;
206+
height: 4px;
207+
margin-bottom: -4px;
208+
background: #faf5fa;
209+
background-color: rgba(204, 153, 204, 0.1);
210+
pointer-events: none;
211+
}
212+
213+
.upload-status.uploading {
214+
visibility: visible;
215+
}
216+
217+
.upload-status .label {
218+
position: absolute;
219+
left: 50%;
220+
top: 100%;
221+
opacity: 0;
222+
transform: translate(-50%, -50%);
223+
transition: transform .2s, opacity .2s;
224+
padding: 0.5em 1em;
225+
color: #fff;
226+
background: #c9c;
227+
background-color: rgba(204, 153, 204, 0.8);
228+
white-space: nowrap;
229+
}
230+
231+
.upload-status.uploading .label {
232+
opacity: 1;
233+
transform: translate(-50%, 10%);
234+
}
235+
236+
.upload-status .progress {
237+
position: absolute;
238+
left: 0;
239+
top: 0;
240+
width: 0;
241+
height: 100%;
242+
background: #c9c;
243+
}
244+
198245
.upload {
199246
position: relative;
200247
}
@@ -216,17 +263,6 @@ html.dragging::before {
216263
position: relative;
217264
}
218265

219-
.upload .progress {
220-
position: fixed;
221-
left: 0;
222-
top: 0;
223-
width: 0;
224-
height: 4px;
225-
opacity: 0.5;
226-
background: #c9c;
227-
pointer-events: none;
228-
}
229-
230266
.archive {
231267
margin: 1em;
232268
overflow: hidden;

src/tpl/frontend/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
{{end}}
2222
</ol>
2323

24+
{{if .CanUpload}}
25+
<div class="upload-status">
26+
<span class="label">{{.Trans.UploadingLabel}}</span>
27+
<span class="progress"></span>
28+
</div>
29+
{{end}}
30+
2431
{{if .CanMkdir}}
2532
<div class="panel mkdir">
2633
<form method="POST" action="{{.SubItemPrefix}}?mkdir">
@@ -41,7 +48,6 @@
4148
<input type="file" name="file" multiple="multiple" class="file"/>
4249
<button type="submit" class="submit">{{.Trans.UploadLabel}}</button>
4350
</form>
44-
<span class="progress"></span>
4551
</div>
4652
{{end}}
4753

src/tpl/frontend/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,9 @@
740740

741741
var uploading = false;
742742
var batches = [];
743-
var elProgress = upload.querySelector('.progress');
743+
var classUploading = 'uploading';
744+
var elUploadStatus = document.body.querySelector('.upload-status');
745+
var elProgress = elUploadStatus && elUploadStatus.querySelector('.progress');
744746

745747
function onComplete() {
746748
if (elProgress) {
@@ -750,6 +752,9 @@
750752
uploadBatch(batches.shift());
751753
} else {
752754
uploading = false;
755+
if (elUploadStatus) {
756+
elUploadStatus.classList.remove(classUploading);
757+
}
753758
}
754759
}
755760

@@ -773,6 +778,9 @@
773778
batches.push(files);
774779
} else {
775780
uploading = true;
781+
if (elUploadStatus) {
782+
elUploadStatus.classList.add(classUploading);
783+
}
776784
uploadBatch(files);
777785
}
778786
}
@@ -840,7 +848,7 @@
840848
}
841849

842850
function onDragEnterOver(e) {
843-
if(!isSelfDragging) {
851+
if (!isSelfDragging) {
844852
e.stopPropagation();
845853
e.preventDefault();
846854
addClass(e.currentTarget, classDragging);

0 commit comments

Comments
 (0)