From 59902d5a483672de30b3e40c99e293bedccb1dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Fri, 19 Apr 2024 23:25:48 -0700 Subject: [PATCH] add upload progress to works and disable loading buttons (#803) Also tossed a small css change in there --- assets/css/app.css | 2 +- .../components/work_uploads/work_uploads.css | 6 +++++- .../components/work_uploads/work_uploads.ex | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/assets/css/app.css b/assets/css/app.css index d7167c81..998066ee 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -36,7 +36,7 @@ &.phx-keyup-loading, &.phx-keydown-loading, &.phx-loading { - @apply loading; + @apply loading btn-disabled; } } diff --git a/lib/banchan_web/live/work_live/components/work_uploads/work_uploads.css b/lib/banchan_web/live/work_live/components/work_uploads/work_uploads.css index 2b1a21b8..fe154df2 100644 --- a/lib/banchan_web/live/work_live/components/work_uploads/work_uploads.css +++ b/lib/banchan_web/live/work_live/components/work_uploads/work_uploads.css @@ -3,7 +3,7 @@ } .preview-item { - @apply relative bg-base-100 mx-auto my-auto w-full h-full flex flex-col justify-center items-center cursor-pointer; + @apply relative bg-base-100 mx-auto my-auto w-full h-full flex flex-col justify-center items-center cursor-pointer min-h-40; &:first-child:nth-last-child(1) { @apply md:col-span-6 w-full; @@ -33,3 +33,7 @@ .remove-upload { @apply absolute z-20 btn btn-sm btn-circle left-2 top-2; } + +.upload-progress { + @apply absolute z-10 radial-progress text-primary bg-primary-content opacity-80; +} diff --git a/lib/banchan_web/live/work_live/components/work_uploads/work_uploads.ex b/lib/banchan_web/live/work_live/components/work_uploads/work_uploads.ex index 8bd6566d..54b0375b 100644 --- a/lib/banchan_web/live/work_live/components/work_uploads/work_uploads.ex +++ b/lib/banchan_web/live/work_live/components/work_uploads/work_uploads.ex @@ -116,6 +116,12 @@ defmodule BanchanWeb.WorkLive.Components.WorkUploads do send(pid, {:canceled_upload, id, ref}) end + defp get_upload_entry(entries, wupload) do + Enum.find(entries, fn entry -> + entry.ref == wupload.ref + end) + end + def render(assigns) do ~F""" @@ -130,6 +136,12 @@ defmodule BanchanWeb.WorkLive.Components.WorkUploads do wupload.ref end} > + {#if type == :live} +
{get_upload_entry(@live_entries, wupload).progress}%
+ {/if} {#if @editing} {/if}