From a64ca7d4ac8a4b0f125cf3bc8ff0a6f0bf1d1e30 Mon Sep 17 00:00:00 2001 From: BFlat Date: Thu, 17 Apr 2025 02:48:25 +0700 Subject: [PATCH] editor3d: activity card improvements and share lightbox with gallery (#518) **activity:** - dropdown cards to show better download icon for completed items - show spinner for in progress items - activity button itself to show a spinner when at least one job is running - use the new lightbox component - click the completed item to view image in lightbox **gallery (library modal):** - use the new lightbox component - the new lightbox has a download button - use cdn images --- .../app/components/reusable/LightboxModal.tsx | 122 +++++++++++++++ .../app/components/signaled/TopBar/TopBar.tsx | 6 +- .../comps/GenerateModals/Activity.tsx | 114 +++++++------- .../comps/GenerateModals/CompletedCard.tsx | 144 ++++++++---------- .../comps/GenerateModals/InProgressCard.tsx | 44 +++--- .../comps/LibraryModal/LibraryModal.tsx | 106 +++---------- 6 files changed, 286 insertions(+), 250 deletions(-) create mode 100644 frontend/apps/editor3d/app/components/reusable/LightboxModal.tsx diff --git a/frontend/apps/editor3d/app/components/reusable/LightboxModal.tsx b/frontend/apps/editor3d/app/components/reusable/LightboxModal.tsx new file mode 100644 index 0000000000..6ed68e8f89 --- /dev/null +++ b/frontend/apps/editor3d/app/components/reusable/LightboxModal.tsx @@ -0,0 +1,122 @@ +import { CloseButton, Button } from "~/components"; +import { Transition } from "@headlessui/react"; +import { createPortal } from "react-dom"; +import dayjs from "dayjs"; +import { faDownToLine } from "@fortawesome/pro-solid-svg-icons"; + +interface LightboxModalProps { + isOpen: boolean; + onClose: () => void; + imageUrl?: string | null; + imageAlt?: string; + onImageError?: () => void; + title?: string; + createdAt?: string; + additionalInfo?: React.ReactNode; + downloadUrl?: string; +} + +export function LightboxModal({ + isOpen, + onClose, + imageUrl, + imageAlt = "", + onImageError, + title, + createdAt, + additionalInfo, + downloadUrl, +}: LightboxModalProps) { + return createPortal( + +
+ +
+ +
+ +
e.stopPropagation()} + > + +
+
+ {!imageUrl ? ( +
+ Image not available +
+ ) : ( + {imageAlt} + )} +
+
+
+
+ {title || "Image Generation"} +
+ {createdAt && ( +
+ Created:{" "} + {dayjs(createdAt).format("MMM D, YYYY HH:mm:ss")} +
+ )} + {additionalInfo} +
+ {downloadUrl && ( + + )} +
+
+
+
+
+
+ , + document.body, + ); +} diff --git a/frontend/apps/editor3d/app/components/signaled/TopBar/TopBar.tsx b/frontend/apps/editor3d/app/components/signaled/TopBar/TopBar.tsx index 8d2777620d..9c01ec5344 100644 --- a/frontend/apps/editor3d/app/components/signaled/TopBar/TopBar.tsx +++ b/frontend/apps/editor3d/app/components/signaled/TopBar/TopBar.tsx @@ -27,16 +27,16 @@ export const TopBar = ({ pageName }: Props) => { return ( <> -
+