forge
Explore
Log in

Don't you dare go Hollow

The upload bar carries the house's cross for abandoning the flight

Browse files at this commit

1ec4a8da93c949c47f73da1839fdc808c51d59dbAhmet Kaan GümüşParent: 627f67b
The progress bar ends in the same cross the file rows wear — same 20px
box, same glyph, same hover — wired to the request's abort: the bar and
cross go, the pick is cleared so choosing the same file again starts
fresh, and nothing more is sent. The error path keeps the files for the
native-submit fallback; only a deliberate cancel clears them.
crates/izlek-web/src/detail.rsmodified+1 -1
@@ -2181,7 +2181,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
21812181 <span class="detail-count">(detail.files.len())</span>
21822182 </div>
21832183 if may_comment {
2184- <form class="file-upload" method="post" action="/files" enctype="multipart/form-data">
2184+ <form class="file-upload" method="post" action="/files" enctype="multipart/form-data" data-cancel-label=(t(lang, Key::Cancel)) data-empty-label=(t(lang, Key::File))>
21852185 <input type="hidden" name="task_id" value=(detail.id.clone())>
21862186 <label class="field-box file-upload-box">
21872187 (glyph::plus(cx).await?)
crates/izlek-web/src/layout.rsmodified+18 -3
@@ -535,7 +535,7 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
535535 var n = navStep(); \
536536 var box = form.querySelector('.file-upload-box'); \
537537 var input = form.querySelector('.file-upload-input'); \
538- var bar = null; \
538+ var bar = null, drop = null; \
539539 if (box) { \
540540 bar = document.createElement('div'); \
541541 bar.className = 'upload-progress'; \
@@ -543,19 +543,28 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
543543 fill.className = 'upload-progress-fill'; \
544544 bar.appendChild(fill); \
545545 box.appendChild(window.__izlekAdded(bar)); \
546+ drop = document.createElement('button'); \
547+ drop.type = 'button'; \
548+ drop.className = 'file-chip-drop upload-progress-drop'; \
549+ var cancelLabel = form.getAttribute('data-cancel-label'); \
550+ if (cancelLabel) { drop.setAttribute('aria-label', cancelLabel); } \
551+ drop.innerHTML = '<svg class=\"glyph\" width=\"13\" height=\"13\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" aria-hidden=\"true\"><path d=\"M4 4l8 8M12 4l-8 8\"></path></svg>'; \
552+ drop.addEventListener('click', function (e) { e.preventDefault(); e.stopPropagation(); x.abort(); }); \
553+ box.appendChild(window.__izlekAdded(drop)); \
546554 } \
547555 if (input) { input.disabled = true; window.__izlekOwn(input, [], ['disabled']); } \
548556 var settle = function () { \
549557 form.__izlekUploading = false; \
550558 if (input) { input.disabled = false; } \
551559 if (bar && bar.parentNode) { bar.parentNode.removeChild(bar); } \
560+ if (drop && drop.parentNode) { drop.parentNode.removeChild(drop); } \
552561 }; \
553562 var x = new XMLHttpRequest(); \
554563 x.open('POST', form.getAttribute('action') || window.location.href); \
555564 x.setRequestHeader('accept', 'text/html'); \
556565 x.upload.onprogress = function (ev) { \
557566 if (!fill) { return; } \
558- if (!bar.isConnected) { box.appendChild(bar); } \
567+ if (!bar.isConnected) { box.appendChild(bar); if (drop) { box.appendChild(drop); } } \
559568 if (ev.lengthComputable && ev.total > 0) { fill.style.width = Math.min(100, Math.round((ev.loaded / ev.total) * 100)) + '%'; } \
560569 }; \
561570 x.onload = function () { \
@@ -564,7 +573,13 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
564573 swap(x.responseText, x.responseURL || form.getAttribute('action') || window.location.href); \
565574 }; \
566575 x.onerror = function () { settle(); form.submit(); }; \
567- x.onabort = function () { settle(); }; \
576+ x.onabort = function () { \
577+ if (input) { input.value = ''; } \
578+ var name = box ? box.querySelector('.file-upload-name') : null; \
579+ var empty = form.getAttribute('data-empty-label'); \
580+ if (name && empty) { name.textContent = empty; } \
581+ settle(); \
582+ }; \
568583 x.send(data); \
569584 return; \
570585 } \
style/main.scssmodified+11 -1
@@ -2702,7 +2702,7 @@ img.avatar {
27022702 .upload-progress {
27032703 position: absolute;
27042704 left: 1px;
2705- right: 1px;
2705+ right: 22px;
27062706 bottom: 1px;
27072707 height: 2px;
27082708 background: var(--border);
@@ -2718,6 +2718,16 @@ img.avatar {
27182718 transition: width var(--dur-fast) var(--ease);
27192719 }
27202720
2721+// The cancel cross is the chip remove control seconded to the bar: same
2722+// `.file-chip-drop` 20px hit box, glyph and hover-to-danger, only moved to
2723+// the track's right end. It cancels the request and nothing else — never
2724+// the picker the box itself is.
2725+.upload-progress-drop {
2726+ position: absolute;
2727+ right: 1px;
2728+ bottom: 1px;
2729+}
2730+
27212731 // -- comments ---------------------------------------------------------------
27222732
27232733 .comment-list {