Skip to content

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

add welcome page

Marc Seitzf013e89a6bb4
diff --git a/components/welcome/intro.tsx b/components/welcome/intro.tsx
new file mode 100644
index 00000000..327d62e4
--- /dev/null
+++ b/components/welcome/intro.tsx
@@ -0,0 +1,61 @@
+import { useRouter } from "next/router";
+import { motion } from "framer-motion";
+
+const STAGGER_CHILD_VARIANTS = {
+ hidden: { opacity: 0, y: 20 },
+ show: { opacity: 1, y: 0, transition: { duration: 0.4, type: "spring" } },
+};
+
+export default function Intro() {
+ const router = useRouter();
+
+ return (
+ <motion.div
+ className="z-10"
+ exit={{ opacity: 0, scale: 0.95 }}
+ transition={{ duration: 0.3, type: "spring" }}
+ >
+ <motion.div
+ variants={{
+ show: {
+ transition: {
+ staggerChildren: 0.2,
+ },
+ },
+ }}
+ initial="hidden"
+ animate="show"
+ className="mx-5 flex flex-col items-center space-y-10 text-center sm:mx-auto"
+ >
+ <motion.h1
+ className="font-display text-4xl font-bold text-white transition-colors sm:text-5xl"
+ variants={STAGGER_CHILD_VARIANTS}
+ >
+ Welcome to{" "}
+ <span className="font-bold tracking-tighter">Papermark</span>
+ </motion.h1>
+ <motion.p
+ className="max-w-md text-gray-200 transition-colors sm:text-lg"
+ variants={STAGGER_CHILD_VARIANTS}
+ >
+ Papermark makes you look cool when fundraising and helps you keep
+ track of your investors.
+ </motion.p>
+ <motion.button
+ variants={STAGGER_CHILD_VARIANTS}
+ className="rounded px-10 py-2 font-medium transition-colors text-gray-900 bg-gray-100 hover:text-gray-100 hover:bg-gray-500"
+ onClick={() =>
+ router.push({
+ pathname: "/welcome",
+ query: {
+ type: "next",
+ },
+ })
+ }
+ >
+ Get Started
+ </motion.button>
+ </motion.div>
+ </motion.div>
+ );
+}
diff --git a/components/welcome/next.tsx b/components/welcome/next.tsx
new file mode 100644
index 00000000..65071213
--- /dev/null
+++ b/components/welcome/next.tsx
@@ -0,0 +1,77 @@
+import { useRouter } from "next/router";
+import { motion } from "framer-motion";
+import { DocumentIcon, PresentationChartBarIcon } from "@heroicons/react/24/outline";
+
+const STAGGER_CHILD_VARIANTS = {
+ hidden: { opacity: 0, y: 20 },
+ show: { opacity: 1, y: 0, transition: { duration: 0.4, type: "spring" } },
+};
+
+export default function Next() {
+ const router = useRouter();
+ return (
+ <motion.div
+ className="z-10 mx-5 flex flex-col items-center space-y-10 text-center sm:mx-auto"
+ variants={{
+ hidden: { opacity: 0, scale: 0.95 },
+ show: {
+ opacity: 1,
+ scale: 1,
+ transition: {
+ staggerChildren: 0.2,
+ },
+ },
+ }}
+ initial="hidden"
+ animate="show"
+ exit="hidden"
+ transition={{ duration: 0.3, type: "spring" }}
+ >
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="flex flex-col items-center space-y-10 text-center"
+ >
+ {/* <Logo className="h-11 w-11" /> */}
+ <p className="text-2xl font-bold tracking-tighter text-white">
+ Papermark
+ </p>
+ <h1 className="font-display max-w-md text-3xl font-semibold text-gray-100 transition-colors sm:text-4xl">
+ Which document do you want to share today?
+ </h1>
+ </motion.div>
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="grid w-full grid-cols-1 divide-y divide-gray-900 text-white rounded-md border border-gray-800 md:grid-cols-2 md:divide-x"
+ >
+ <button
+ onClick={() =>
+ router.push({
+ pathname: "/welcome",
+ query: {
+ type: "pitchdeck",
+ },
+ })
+ }
+ className="flex flex-col items-center justify-center overflow-hidden p-5 space-y-5 transition-colors hover:bg-gray-800 md:p-10 min-h-[200px]"
+ >
+ <PresentationChartBarIcon className="h-auto pointer-events-none w-12 sm:w-12" />
+ <p>Pitchdeck</p>
+ </button>
+ <button
+ onClick={() =>
+ router.push({
+ pathname: "/welcome",
+ query: {
+ type: "document",
+ },
+ })
+ }
+ className="flex flex-col items-center justify-center overflow-hidden p-5 space-y-5 transition-colors hover:bg-gray-800 md:p-10 min-h-[200px]"
+ >
+ <DocumentIcon className="h-auto pointer-events-none w-12 sm:w-12" />
+ <p>Another document</p>
+ </button>
+ </motion.div>
+ </motion.div>
+ );
+}
diff --git a/components/welcome/upload.tsx b/components/welcome/upload.tsx
new file mode 100644
index 00000000..4f1bf2b9
--- /dev/null
+++ b/components/welcome/upload.tsx
@@ -0,0 +1,253 @@
+import { useRouter } from "next/router";
+import { motion } from "framer-motion";
+import { useEffect, useState } from "react";
+// @ts-ignore
+import type { PutBlobResult } from "@vercel/blob";
+import DocumentUpload from "../document-upload";
+import { ArrowRightIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline";
+import toast from "react-hot-toast";
+import Notification from "../Notification";
+import Skeleton from "../Skeleton";
+
+const STAGGER_CHILD_VARIANTS = {
+ hidden: { opacity: 0, y: 20 },
+ show: { opacity: 1, y: 0, transition: { duration: 0.4, type: "spring" } },
+};
+
+export default function Upload() {
+ const router = useRouter();
+ const [uploading, setUploading] = useState<boolean>(false);
+ const [currentFile, setCurrentFile] = useState<File | null>(null);
+ const [currentBlob, setCurrentBlob] = useState<boolean>(false);
+ const [currentLinkId, setCurrentLinkId] = useState<string | null>(null);
+ const [currentDocId, setCurrentDocId] = useState<string | null>(null);
+ const [copiedLink, setCopiedLink] = useState<boolean>(false);
+
+ const handleSubmit = async (event: any) => {
+ event.preventDefault();
+
+ // Check if the file is chosen
+ if (!currentFile) {
+ alert("Please select a file to upload.");
+ return; // prevent form from submitting
+ }
+
+ const data = new FormData();
+ if (currentFile) data.append("file", currentFile);
+
+ try {
+ setUploading(true);
+
+ // upload the file to the blob storage
+ const blobResponse = await fetch("/api/file/upload", {
+ method: "POST",
+ body: data,
+ });
+
+ if (!blobResponse.ok) {
+ throw new Error(`HTTP error! status: ${blobResponse.status}`);
+ }
+
+ // get the blob url from the response
+ const blob = (await blobResponse.json()) as PutBlobResult;
+
+ setCurrentFile(null);
+ setCurrentBlob(true);
+
+ setTimeout(async () => {
+ await createLink(blob.pathname, blob.url);
+ }, 2000);
+
+ setUploading(false);
+ } catch (error) {
+ console.error(error);
+ setCurrentFile(null);
+ setUploading(false);
+ }
+ };
+
+ const createLink = async (name: string, url: string) => {
+ // create a document in the database with the blob url
+ const response = await fetch("/api/documents", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ name: name,
+ url: url,
+ }),
+ });
+
+ if (!response.ok) {
+ throw new Error(`HTTP error! status: ${response.status}`);
+ }
+
+ const document = await response.json();
+ const linkId = document.links[0].id;
+ setCurrentDocId(document.id);
+ setCurrentLinkId(linkId);
+ return true;
+ };
+
+
+ const handleCopyToClipboard = (id: string) => {
+ navigator.clipboard.writeText(
+ `${process.env.NEXT_PUBLIC_BASE_URL}/view/${id}`
+ );
+
+ setCopiedLink(true);
+
+ toast.custom((t) => (
+ <Notification
+ visible={t.visible}
+ closeToast={() => toast.dismiss(t.id)}
+ message={``}
+ />
+ ));
+ };
+
+ return (
+ <>
+ {!currentBlob && (
+ <motion.div
+ className="z-10 flex flex-col space-y-10 text-center"
+ variants={{
+ hidden: { opacity: 0, scale: 0.95 },
+ show: {
+ opacity: 1,
+ scale: 1,
+ transition: {
+ staggerChildren: 0.2,
+ },
+ },
+ }}
+ initial="hidden"
+ animate="show"
+ exit="hidden"
+ transition={{ duration: 0.3, type: "spring" }}
+ >
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="flex flex-col items-center space-y-10 text-center"
+ >
+ <h1 className="font-display text-3xl font-semibold text-gray-100 transition-colors sm:text-4xl">
+ {`Upload your ${router.query.type}`}
+ </h1>
+ </motion.div>
+ <motion.div variants={STAGGER_CHILD_VARIANTS}>
+ <main className="mt-8">
+ <form encType="multipart/form-data" onSubmit={handleSubmit} className="flex flex-col">
+ <div className="space-y-12">
+ <div className="pb-6">
+ <div className="mt-10 grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
+ <DocumentUpload
+ currentFile={currentFile}
+ setCurrentFile={setCurrentFile}
+ />
+ </div>
+ </div>
+ </div>
+
+ <div className="flex justify-center">
+ <button
+ type="submit"
+ className="rounded-md bg-gray-100 px-3 py-2 w-full text-sm font-semibold text-gray-900 shadow-sm transition-colors hover:text-gray-100 hover:bg-gray-500 disabled:text-gray-400 disabled:bg-gray-800 disabled:cursor-not-allowed"
+ disabled={uploading || !currentFile}
+ >
+ {uploading ? "Uploading..." : "Upload Document"}
+ </button>
+ </div>
+ </form>
+ </main>
+ </motion.div>
+ </motion.div>
+ )}
+
+ {currentBlob && (
+ <motion.div
+ className="z-10 flex flex-col space-y-10 text-center"
+ variants={{
+ hidden: { opacity: 0, scale: 0.95 },
+ show: {
+ opacity: 1,
+ scale: 1,
+ transition: {
+ staggerChildren: 0.2,
+ },
+ },
+ }}
+ initial="hidden"
+ animate="show"
+ exit="hidden"
+ transition={{ duration: 0.3, type: "spring" }}
+ >
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="flex flex-col items-center space-y-10 text-center"
+ >
+ <h1 className="font-display text-3xl font-semibold text-gray-100 transition-colors sm:text-4xl">
+ Share your unique link
+ </h1>
+ </motion.div>
+
+ <motion.div variants={STAGGER_CHILD_VARIANTS}>
+ {!currentLinkId && (
+ <main className="min-h-[300px]">
+ <div className="flex flex-col justify-center">
+ <div className="flex py-8 rounded-md shadow-sm">
+ <div className="flex w-full focus-within:z-10">
+ <Skeleton className="h-6 w-full" />
+ </div>
+ </div>
+ </div>
+ </main>
+ )}
+ {currentLinkId && currentDocId && (
+ <main className="min-h-[300px]">
+ <div className="flex flex-col justify-center">
+ <div className="relative">
+ <div className="flex py-8 rounded-md shadow-sm">
+ <div className="flex w-full focus-within:z-10">
+ <input
+ type="text"
+ name="link"
+ id="link"
+ disabled={true}
+ className="block w-full md:min-w-[500px] rounded-none rounded-l-md border-0 py-1.5 text-gray-200 bg-gray-900 ring-1 ring-inset ring-gray-900 focus:ring-2 focus:ring-inset focus:ring-indigo-600 leading-6"
+ value={`${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`}
+ />
+ </div>
+ <button
+ type="button"
+ className="relative -ml-px inline-flex items-center rounded-r-md px-3 py-2 text-sm font-semibold bg-gray-700 ring-1 ring-inset ring-gray-800 hover:ring-gray-400 animate-pulse"
+ title="Copy link"
+ onClick={() => handleCopyToClipboard(currentLinkId)}
+ >
+ <DocumentDuplicateIcon
+ className="h-5 w-5 text-white"
+ aria-hidden="true"
+ />
+ </button>
+ </div>
+ </div>
+ <div className="flex items-center justify-center mb-4">
+ <button
+ onClick={() => router.push(`/documents/${currentDocId}`)}
+ type="submit"
+ className="flex items-center rounded-md px-5 py-2 w-fit text-sm font-semibold shadow-sm transition-colors text-gray-900 bg-gray-100 hover:text-gray-100 hover:bg-gray-500 disabled:hover:text-gray-900 disabled:bg-gray-700 disabled:cursor-not-allowed"
+ disabled={!copiedLink}
+ >
+ {"To analytics"}
+ <ArrowRightIcon className="h-4 w-4 ml-2" />
+ </button>
+ </div>
+ </div>
+ </main>
+ )}
+ </motion.div>
+ </motion.div>
+ )}
+ </>
+ );
+}
diff --git a/package-lock.json b/package-lock.json
index 3121cb6c..8006231f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -22,6 +22,7 @@
"date-fns": "^2.30.0",
"eslint": "8.41.0",
"eslint-config-next": "13.4.4",
+ "framer-motion": "^10.12.16",
"next": "13.4.4",
"next-auth": "^4.22.1",
"postcss": "8.4.23",
@@ -64,6 +65,21 @@
"node": ">=6.9.0"
}
},
+ "node_modules/@emotion/is-prop-valid": {
+ "version": "0.8.8",
+ "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz",
+ "integrity": "sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA==",
+ "optional": true,
+ "dependencies": {
+ "@emotion/memoize": "0.7.4"
+ }
+ },
+ "node_modules/@emotion/memoize": {
+ "version": "0.7.4",
+ "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz",
+ "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==",
+ "optional": true
+ },
"node_modules/@eslint-community/eslint-utils": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
@@ -2177,6 +2193,29 @@
"url": "https://www.patreon.com/infusion"
}
},
+ "node_modules/framer-motion": {
+ "version": "10.12.16",
+ "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-10.12.16.tgz",
+ "integrity": "sha512-w/SfWEIWJkYSgRHYBmln7EhcNo31ao8Xexol8lGXf1pR/tlnBtf1HcxoUmEiEh6pacB4/geku5ami53AAQWHMQ==",
+ "dependencies": {
+ "tslib": "^2.4.0"
+ },
+ "optionalDependencies": {
+ "@emotion/is-prop-valid": "^0.8.2"
+ },
+ "peerDependencies": {
+ "react": "^18.0.0",
+ "react-dom": "^18.0.0"
+ },
+ "peerDependenciesMeta": {
+ "react": {
+ "optional": true
+ },
+ "react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/fs-minipass": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
@@ -5225,6 +5264,21 @@
"regenerator-runtime": "^0.13.11"
}
},
+ "@emotion/is-prop-valid": {
+ "version": "0.8.8",
+ "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz",
+ "integrity": "sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA==",
+ "optional": true,
+ "requires": {
+ "@emotion/memoize": "0.7.4"
+ }
+ },
+ "@emotion/memoize": {
+ "version": "0.7.4",
+ "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz",
+ "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==",
+ "optional": true
+ },
"@eslint-community/eslint-utils": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
@@ -6695,6 +6749,15 @@
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz",
"integrity": "sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA=="
},
+ "framer-motion": {
+ "version": "10.12.16",
+ "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-10.12.16.tgz",
+ "integrity": "sha512-w/SfWEIWJkYSgRHYBmln7EhcNo31ao8Xexol8lGXf1pR/tlnBtf1HcxoUmEiEh6pacB4/geku5ami53AAQWHMQ==",
+ "requires": {
+ "@emotion/is-prop-valid": "^0.8.2",
+ "tslib": "^2.4.0"
+ }
+ },
"fs-minipass": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
diff --git a/package.json b/package.json
index 6567e143..2757142c 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"date-fns": "^2.30.0",
"eslint": "8.41.0",
"eslint-config-next": "13.4.4",
+ "framer-motion": "^10.12.16",
"next": "13.4.4",
"next-auth": "^4.22.1",
"postcss": "8.4.23",
diff --git a/pages/welcome.tsx b/pages/welcome.tsx
new file mode 100644
index 00000000..cee115d7
--- /dev/null
+++ b/pages/welcome.tsx
@@ -0,0 +1,41 @@
+import { useRouter } from "next/router";
+import Intro from "@/components/welcome/intro";
+import Next from "@/components/welcome/next";
+import Upload from "@/components/welcome/upload";
+import { ArrowLeftIcon } from "@heroicons/react/24/outline";
+
+export default function Welcome() {
+ const router = useRouter();
+
+ return (
+ <div className="flex h-screen flex-col items-center justify-center max-w-3xl mx-auto overflow-x-hidden">
+ <div
+ className="absolute inset-x-0 top-10 -z-10 flex transform-gpu justify-center overflow-hidden blur-3xl"
+ aria-hidden="true"
+ >
+ <div
+ className="aspect-[1108/632] w-[69.25rem] flex-none bg-gradient-to-r from-[#80caff] to-[#4f46e5] opacity-20"
+ style={{
+ clipPath:
+ "polygon(73.6% 51.7%, 91.7% 11.8%, 100% 46.4%, 97.4% 82.2%, 92.5% 84.9%, 75.7% 64%, 55.3% 47.5%, 46.5% 49.4%, 45% 62.9%, 50.3% 87.2%, 21.3% 64.1%, 0.1% 100%, 5.4% 51.1%, 21.4% 63.9%, 58.9% 0.2%, 73.6% 51.7%)",
+ }}
+ />
+ </div>
+ <div>
+ {router.query.type ? (
+ <button
+ className="group absolute left-2 top-10 z-40 rounded-full p-2 transition-all hover:bg-gray-400"
+ onClick={() => router.back()}
+ >
+ <ArrowLeftIcon className="h-8 w-8 text-gray-500 group-hover:text-gray-800 group-active:scale-90" />
+ </button>
+ ) : (
+ <Intro key="intro" />
+ )}
+ {router.query.type === "next" && <Next key="next" />}
+ {router.query.type === "pitchdeck" && <Upload key="pitchdeck" />}
+ {router.query.type === "document" && <Upload key="document" />}
+ </div>
+ </div>
+ );
+}