Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
chore: cleanup loading states
Marc Seitz8bb61d8123c4
diff --git a/pages/documents.tsx b/pages/documents.tsxindex 21b58268..438d6cd2 100644--- a/pages/documents.tsx+++ b/pages/documents.tsx@@ -1,6 +1,7 @@import Sidebar from "@/components/Sidebar";import useDocuments from "@/lib/swr/use-documents";import DocumentCard from "@/components/documents/document-card";+import Skeleton from "@/components/Skeleton";export default function Documents() {const { documents } = useDocuments();@@ -18,15 +19,18 @@ export default function Documents() {{/* Documents list */}<ul role="list" className="divide-y divide-white/5">- {documents ? (- documents.map((document) => {- return <DocumentCard key={document.id} document={document} />;- })- ) : (- <div className="flex justify-center items-center h-96">- <p className="text-gray-400">Loading documents</p>- </div>- )}+ {documents+ ? documents.map((document) => {+ return (+ <DocumentCard key={document.id} document={document} />+ );+ })+ : Array.from({ length: 3 }).map((_, i) => (+ <li className="flex flex-col space-y-4 px-4 py-4 sm:px-6 lg:px-8">+ <Skeleton key={i} className="h-5 w-20" />+ <Skeleton key={i} className="mt-3 h-3 w-10" />+ </li>+ ))}</ul></main></Sidebar>diff --git a/pages/documents/[id].tsx b/pages/documents/[id].tsxindex 04f822ac..5bcf9f5c 100644--- a/pages/documents/[id].tsx+++ b/pages/documents/[id].tsx@@ -1,5 +1,5 @@import Sidebar from "@/components/Sidebar";-import { classNames, getExtension } from "@/lib/utils";+import { getExtension } from "@/lib/utils";import Link from "next/link";import { useDocument } from "@/lib/swr/use-document";import ErrorPage from "next/error";@@ -9,10 +9,6 @@ import StatsCard from "@/components/documents/stats-card";export default function DocumentPage() {const { document, error } = useDocument();- if (!document) {- return <div>Loading...</div>;- }-if (error && error.status === 404) {return <ErrorPage statusCode={404} />;}@@ -22,38 +18,44 @@ export default function DocumentPage() {<div><Sidebar><main>- <header>- {/* Heading */}- <div className="flex flex-col items-start justify-between gap-x-8 gap-y-4 bg-gray-700/10 px-4 py-4 sm:flex-row sm:items-center sm:px-6 lg:px-8">- <div>- <div className="flex items-center gap-x-3">- <h1 className="flex gap-x-3 text-base leading-7">- <span className="font-semibold text-white">- {document.name}- </span>- <span className="text-gray-600">/</span>- <span className="font-semibold text-gray-500">- {getExtension(document.file)}- </span>- </h1>+ {document ? (+ <>+ <header>+ {/* Heading */}+ <div className="flex flex-col items-start justify-between gap-x-8 gap-y-4 bg-gray-700/10 px-4 py-4 sm:flex-row sm:items-center sm:px-6 lg:px-8">+ <div>+ <div className="flex items-center gap-x-3">+ <h1 className="flex gap-x-3 text-base leading-7">+ <span className="font-semibold text-white">+ {document.name}+ </span>+ <span className="text-gray-600">/</span>+ <span className="font-semibold text-gray-500">+ {getExtension(document.file)}+ </span>+ </h1>+ </div>+ <p className="mt-2 text-xs leading-6 text-gray-400">+ {document.description}+ </p>+ </div>+ <Link+ className="order-first rounded flex-none px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-400 hover:text-gray-50 sm:order-none"+ href={document.file}+ >+ View Document+ </Link></div>- <p className="mt-2 text-xs leading-6 text-gray-400">- {document.description}- </p>- </div>- <Link- className="order-first rounded flex-none px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-400 hover:text-gray-50 sm:order-none"- href={document.file}- >- View Document- </Link>- </div>- {/* Stats */}- <StatsCard />- </header>+ {/* Stats */}+ <StatsCard />+ </header>- <LinksContainer />+ <LinksContainer />+ </>+ ) : (+ <div>Loading...</div>+ )}</main></Sidebar></div>