From 5aa1ec4ffda11533d1b4383c34eb3c4833302c53 Mon Sep 17 00:00:00 2001 From: Aamir Azad <82281117+aamirazad@users.noreply.github.com> Date: Sat, 6 Jul 2024 13:12:47 -0400 Subject: [PATCH] feat: skeleton loaders instead of spinner (#49) --- package.json | 2 +- src/app/paperless/document/[id]/page.tsx | 6 ++++- src/components/document-viewer.tsx | 33 +++++++++++++++++------- tailwind.config.ts | 1 - 4 files changed, 30 insertions(+), 12 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/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..ae9a853 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) { 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"],