Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

add blur image component

Marc Seitz1a40ed0a4c61
diff --git a/components/PagesViewer.tsx b/components/PagesViewer.tsx
index 45bdc095..2d5d1f85 100644
--- a/components/PagesViewer.tsx
+++ b/components/PagesViewer.tsx
@@ -1,6 +1,6 @@
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/20/solid";
import { useEffect, useRef, useState } from "react";
-import Image from "next/image";
+import { BlurImage } from "@/components/shared/blur-image";
export default function PagesViewer({pages, linkId, documentId, viewId}: {pages: { file: string, pageNumber: string }[], linkId: string, documentId: string, viewId: string}) {
const [pageNumber, setPageNumber] = useState<number>(1); // start on first page
@@ -111,7 +111,7 @@ export default function PagesViewer({pages, linkId, documentId, viewId}: {pages:
</div>
<div className="flex justify-center mx-auto">
- <Image
+ <BlurImage
className="object-contain mx-auto"
src={pages[pageNumber - 1].file}
alt={`Page ${pageNumber}`}
diff --git a/components/shared/blur-image.tsx b/components/shared/blur-image.tsx
new file mode 100644
index 00000000..8e95cf5b
--- /dev/null
+++ b/components/shared/blur-image.tsx
@@ -0,0 +1,18 @@
+import { cn } from "@/lib/utils";
+import Image, { ImageProps } from "next/image";
+import { useState } from "react";
+
+export function BlurImage(props: ImageProps) {
+ const [isLoading, setLoading] = useState(true);
+
+ return (
+ <Image
+ {...props}
+ alt={props.alt}
+ className={cn(isLoading ? "blur-[2px]" : "blur-0", props.className)}
+ onLoadingComplete={async () => {
+ setLoading(false);
+ }}
+ />
+ );
+}