From 984541d17a4e692e6a0906d22c9bc53c58663dff Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Wed, 9 Apr 2025 18:32:57 +0100 Subject: [PATCH] feat: add transition to qr-scanner dialog --- src/app/components/image-viewer.tsx | 4 +-- src/app/components/submit/qr-scanner.tsx | 33 +++++++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/app/components/image-viewer.tsx b/src/app/components/image-viewer.tsx index d8ac853..74aaeb1 100644 --- a/src/app/components/image-viewer.tsx +++ b/src/app/components/image-viewer.tsx @@ -21,7 +21,7 @@ export default function ImageViewer({ src, alt, width, height, className }: Prop setIsVisible(false); setTimeout(() => { setIsOpen(false); - }, 300); // duration matches animation timing + }, 300); }; useEffect(() => { @@ -43,7 +43,7 @@ export default function ImageViewer({ src, alt, width, height, className }: Prop className={`z-40 absolute inset-0 backdrop-brightness-75 backdrop-blur-xs transition-opacity duration-300 ${ isVisible ? "opacity-100" : "opacity-0" }`} - > + />
(null); const [devices, setDevices] = useState([]); @@ -86,6 +88,20 @@ export default function QrScanner({ isOpen, setIsOpen, setQrBytesRaw }: Props) { .catch(() => setPermissionGranted(false)); }; + const close = () => { + setIsVisible(false); + setTimeout(() => { + setIsOpen(false); + }, 300); + }; + + useEffect(() => { + if (isOpen) { + // slight delay to trigger animation + setTimeout(() => setIsVisible(true), 10); + } + }, [isOpen]); + useEffect(() => { if (!isOpen) return; requestPermission(); @@ -108,12 +124,21 @@ export default function QrScanner({ isOpen, setIsOpen, setQrBytesRaw }: Props) { return (
-
setIsOpen(false)} className="z-40 absolute inset-0 backdrop-brightness-75 backdrop-blur-xs">
+
-
+

Scan QR Code

-
@@ -177,7 +202,7 @@ export default function QrScanner({ isOpen, setIsOpen, setQrBytesRaw }: Props) {
-