From 89a0c870e6759d7b07f97e079c03a07efd023dc7 Mon Sep 17 00:00:00 2001 From: Aamir Azad Date: Sat, 29 Jun 2024 11:24:08 +0530 Subject: [PATCH 1/2] feat: skeleton loaders instead of spinner --- src/app/paperless/document/[id]/page.tsx | 6 +++- src/components/document-viewer.tsx | 35 +++++++++++++++++------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/app/paperless/document/[id]/page.tsx b/src/app/paperless/document/[id]/page.tsx index 89eec4f..71f8717 100644 --- a/src/app/paperless/document/[id]/page.tsx +++ b/src/app/paperless/document/[id]/page.tsx @@ -5,5 +5,9 @@ export default function ModalDocumentPage({ }: { params: { id: number }; }) { - return ; + return ( +
+ +
+ ); } diff --git a/src/components/document-viewer.tsx b/src/components/document-viewer.tsx index c84d51e..3fb19c6 100644 --- a/src/components/document-viewer.tsx +++ b/src/components/document-viewer.tsx @@ -41,6 +41,29 @@ export default function DocumentViewer(props: { id: number }) { const [pdfUrl, setPdfUrl] = useState(null); const [loading, setLoading] = useState(true); + const SkeletonLoader = () => ( +
+
+
+
+ {/* PDF Skeleton */} +
+ {/* Button Skeleton */} +
+
+
+
+
+
+
+
+
+
+
+
+
+ ); + useEffect(() => { const fetchData = async () => { setLoading(true); @@ -65,15 +88,7 @@ export default function DocumentViewer(props: { id: number }) { }, [props.id]); // Dependency array to refetch if id changes if (loading) { - return ( -
-
- - Loading... - -
-
- ); + return ; } if (!pdfUrl) { @@ -81,7 +96,7 @@ export default function DocumentViewer(props: { id: number }) { } return ( -
+
From 0923645d23bff64768c6bb32462c8109308fc638 Mon Sep 17 00:00:00 2001 From: Aamir Azad Date: Sat, 29 Jun 2024 19:01:20 +0530 Subject: [PATCH 2/2] Fix coloring and formating of document viewer --- package.json | 2 +- src/components/document-viewer.tsx | 22 +++++++++++----------- tailwind.config.ts | 1 - 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 12bd6ae..b698f44 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "db:migrate": "drizzle-kit migrate", "db:push": "drizzle-kit push", "db:studio": "drizzle-kit studio", - "dev": "next dev", + "dev": "next dev --turbo", "lint": "next lint", "start": "next start" }, diff --git a/src/components/document-viewer.tsx b/src/components/document-viewer.tsx index 3fb19c6..ae9a853 100644 --- a/src/components/document-viewer.tsx +++ b/src/components/document-viewer.tsx @@ -42,21 +42,21 @@ export default function DocumentViewer(props: { id: number }) { const [loading, setLoading] = useState(true); const SkeletonLoader = () => ( -
-
+
+
{/* PDF Skeleton */} -
+
{/* Button Skeleton */}
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -96,7 +96,7 @@ export default function DocumentViewer(props: { id: number }) { } return ( -
+
diff --git a/tailwind.config.ts b/tailwind.config.ts index 4ff1b0a..b0a0df9 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -1,5 +1,4 @@ import type { Config } from "tailwindcss"; -const { fontFamily } = require("tailwindcss/defaultTheme"); const config = { darkMode: ["class"],