Skip to content

Commit 6e1dfac

Browse files
committed
feat(tpl): prevent upload label wrap at 50% width
Uploading label use CSS `left 50%; transform: translate(-50%, -50%)` to make center aligned, which results line wrap at 50% width since the line reached the end of the container(caused by left:50%). Use inline block align center instead.
1 parent 7e206dc commit 6e1dfac

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

src/tpl/frontend/index.css

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,26 +210,36 @@ html.dragging::before {
210210
pointer-events: none;
211211
}
212212

213+
.upload-status > *,
213214
.upload-status.uploading,
214215
.upload-status.failed {
215216
visibility: visible;
216217
}
217218

218219
.upload-status .label {
219220
position: absolute;
220-
left: 50%;
221-
top: 100%;
221+
left: 0;
222+
top: 0;
223+
width: 100%;
224+
color: #fff;
225+
text-align: center;
222226
opacity: 0;
223-
transform: translate(-50%, -50%);
224227
transition: transform .2s, opacity .2s;
228+
}
229+
230+
.upload-status .label .content {
231+
position: relative;
232+
display: inline-block;
233+
vertical-align: top;
234+
text-align: left;
235+
text-align: start;
225236
padding: 0.5em 1em;
226-
color: #fff;
227237
box-sizing: border-box;
228-
max-width: 100%;
229238
overflow-wrap: break-word;
239+
word-break: break-word;
230240
}
231241

232-
.upload-status .label.tips {
242+
.upload-status .info .content {
233243
padding-left: 2.5em;
234244
background: #c9c;
235245
background-color: rgba(204, 153, 204, 0.8);
@@ -244,8 +254,8 @@ html.dragging::before {
244254
}
245255
}
246256

247-
.upload-status .label.tips:before,
248-
.upload-status .label.tips:after {
257+
.upload-status .info .content:before,
258+
.upload-status .info .content:after {
249259
content: '';
250260
position: absolute;
251261
left: 1em;
@@ -258,19 +268,19 @@ html.dragging::before {
258268
animation: wheel 1s linear infinite;
259269
}
260270

261-
.upload-status .label.tips:after {
271+
.upload-status .info .content:after {
262272
border-color: currentColor transparent transparent transparent;
263273
}
264274

265-
.upload-status .label.failed {
275+
.upload-status .warn .content {
266276
background: #800000;
267277
background-color: rgba(128, 0, 0, 0.8);
268278
}
269279

270-
.upload-status.uploading .label.tips,
271-
.upload-status.failed .label.failed {
280+
.upload-status.uploading .info,
281+
.upload-status.failed .warn {
272282
opacity: 1;
273-
transform: translate(-50%, 10%);
283+
transform: translateY(25%);
274284
}
275285

276286
.upload-status .progress {

src/tpl/frontend/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424

2525
{{if .CanUpload}}
2626
<div class="upload-status">
27-
<span class="label tips">{{.Trans.UploadingLabel}}</span>
28-
<span class="label failed">{{.Trans.UploadFailLabel}}<span class="message"></span></span>
27+
<span class="label info">
28+
<span class="content">{{.Trans.UploadingLabel}}</span>
29+
</span>
30+
<span class="label warn">
31+
<span class="content">{{.Trans.UploadFailLabel}}<span class="message"></span></span>
32+
</span>
2933
<span class="progress"></span>
3034
</div>
3135
{{end}}

src/tpl/frontend/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@
801801
var classFailed = 'failed';
802802
var elUploadStatus = document.body.querySelector('.upload-status');
803803
var elProgress = elUploadStatus && elUploadStatus.querySelector('.progress');
804-
var elFailedMessage = elUploadStatus && elUploadStatus.querySelector('.failed .message');
804+
var elFailedMessage = elUploadStatus && elUploadStatus.querySelector('.warn .message');
805805

806806
function onComplete() {
807807
if (elProgress) {

0 commit comments

Comments
 (0)