Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: replace react-hot-toast with sonner
Marc Seitz500b7a78f6ee
diff --git a/components/Notification.tsx b/components/Notification.tsxdeleted file mode 100644index afc72865..00000000--- a/components/Notification.tsx+++ /dev/null@@ -1,60 +0,0 @@-import { CheckCircleIcon } from "@heroicons/react/24/outline";-import { XMarkIcon } from "@heroicons/react/20/solid";-import { Transition } from "@headlessui/react";-import { Fragment } from "react";-import { Toast } from "react-hot-toast";--export default function Notification({- visible,- closeToast,- message = "Document uploaded and link copied to clipboard.",-}: {- visible: boolean;- closeToast: () => void;- message?: string;-}) {- return (- <div className="flex w-full flex-col items-center space-y-4 sm:items-end">- {/* Notification panel, dynamically insert this into the live region when it needs to be displayed */}- <Transition- show={visible}- as={Fragment}- enter="transform ease-out duration-300 transition"- enterFrom="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"- enterTo="translate-y-0 opacity-100 sm:translate-x-0"- leave="transition ease-in duration-100"- leaveFrom="opacity-100"- leaveTo="opacity-0"- >- <div className="pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg bg-gray-900 shadow-lg ring-1 ring-black ring-opacity-5">- <div className="p-4">- <div className="flex items-start">- <div className="flex-shrink-0">- <CheckCircleIcon- className="h-6 w-6 text-green-400"- aria-hidden="true"- />- </div>- <div className="ml-3 w-0 flex-1 pt-0.5">- <p className="text-sm font-medium text-gray-300">- Link copied to clipboard!- </p>- <p className="mt-1 text-sm text-gray-500">{message}</p>- </div>- <div className="ml-4 flex flex-shrink-0">- <button- type="button"- className="inline-flex rounded-md bg-gray-900 text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"- onClick={closeToast}- >- <span className="sr-only">Close</span>- <XMarkIcon className="h-5 w-5" aria-hidden="true" />- </button>- </div>- </div>- </div>- </div>- </Transition>- </div>- );-}diff --git a/components/documents/add-document-modal.tsx b/components/documents/add-document-modal.tsxindex 1c0701d9..6e37cff4 100644--- a/components/documents/add-document-modal.tsx+++ b/components/documents/add-document-modal.tsx@@ -10,8 +10,7 @@ import { useState } from "react";import { useRouter } from "next/router";// @ts-ignoreimport type { PutBlobResult } from "@vercel/blob";-import toast from "react-hot-toast";-import Notification from "@/components/Notification";+import { toast } from "sonner";import DocumentUpload from "@/components/document-upload";import { pdfjs } from "react-pdf";import { getExtension } from "@/lib/utils";@@ -75,15 +74,7 @@ export function AddDocumentModal({children}: {children: React.ReactNode}) {console.log("Failed to copy text to clipboard", error);});- toast.custom((t) => (- <Notification- visible={t.visible}- closeToast={() => toast.dismiss(t.id)}- message={- "Document uploaded and link copied to clipboard. Redirecting to document page..."- }- />- ));+ toast.success("Document uploaded and link copied to clipboard. Redirecting to document page...")setTimeout(() => {router.push("/documents/" + document.id);diff --git a/components/documents/document-card.tsx b/components/documents/document-card.tsxindex 3b742533..8868a30a 100644--- a/components/documents/document-card.tsx+++ b/components/documents/document-card.tsx@@ -3,8 +3,7 @@ import { ChevronRightIcon } from "@heroicons/react/20/solid";import { DocumentDuplicateIcon } from "@heroicons/react/24/outline";import Link from "next/link";import { DocumentWithLinksAndLinkCountAndViewCount } from "@/lib/types";-import toast from "react-hot-toast";-import Notification from "@/components/Notification";+import { toast } from "sonner";import Copy from "@/components/shared/icons/copy";import BarChart from "@/components/shared/icons/bar-chart";import Image from "next/image";@@ -21,13 +20,7 @@ export default function DocumentsCard({console.log("Failed to copy text to clipboard", error);});- toast.custom((t) => (- <Notification- visible={t.visible}- closeToast={() => toast.dismiss(t.id)}- message={``}- />- ));+ toast.success("Link copied to clipboard.");}diff --git a/components/links/links-table.tsx b/components/links/links-table.tsxindex 48c4dca6..0f4e517d 100644--- a/components/links/links-table.tsx+++ b/components/links/links-table.tsx@@ -23,8 +23,7 @@ import {import { Button } from "@/components/ui/button";import { useDocumentLinks } from "@/lib/swr/use-document";-import toast from "react-hot-toast";-import Notification from "../Notification";+import { toast } from "sonner";import BarChart from "../shared/icons/bar-chart";import { nFormatter, timeAgo } from "@/lib/utils";import MoreHorizontal from "../shared/icons/more-horizontal";@@ -43,13 +42,7 @@ export default function LinksTable() {console.log("Failed to copy text to clipboard", error);});- toast.custom((t) => (- <Notification- visible={t.visible}- closeToast={() => toast.dismiss(t.id)}- message={``}- />- ));+ toast.success("Link copied to clipboard.");};return (diff --git a/package-lock.json b/package-lock.jsonindex f07abb9c..be8a1083 100644--- a/package-lock.json+++ b/package-lock.json@@ -48,10 +48,10 @@"react-dom": "18.2.0","react-dropzone": "^14.2.3","react-email": "^1.9.4",- "react-hot-toast": "^2.4.1","react-icons": "^4.10.1","react-pdf": "^7.3.3","resend": "^0.17.2",+ "sonner": "^0.6.2","swr": "^2.2.1","tailwind-merge": "^1.14.0","tailwindcss": "^3.3.3",@@ -5487,14 +5487,6 @@"url": "https://github.com/sponsors/sindresorhus"}},- "node_modules/goober": {- "version": "2.1.13",- "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.13.tgz",- "integrity": "sha512-jFj3BQeleOoy7t93E9rZ2de+ScC4lQICLwiAQmKMg9F6roKGaLSHoCDYKkWlSafg138jejvq/mTdvmnwDQgqoQ==",- "peerDependencies": {- "csstype": "^3.0.10"- }- },"node_modules/gopd": {"version": "1.0.1","resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",@@ -8036,21 +8028,6 @@"node": ">=10"}},- "node_modules/react-hot-toast": {- "version": "2.4.1",- "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.4.1.tgz",- "integrity": "sha512-j8z+cQbWIM5LY37pR6uZR6D4LfseplqnuAO4co4u8917hBUvXlEqyP1ZzqVLcqoyUesZZv/ImreoCeHVDpE5pQ==",- "dependencies": {- "goober": "^2.1.10"- },- "engines": {- "node": ">=10"- },- "peerDependencies": {- "react": ">=16",- "react-dom": ">=16"- }- },"node_modules/react-icons": {"version": "4.10.1","resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.10.1.tgz",@@ -8829,6 +8806,15 @@"node": ">=8"}},+ "node_modules/sonner": {+ "version": "0.6.2",+ "resolved": "https://registry.npmjs.org/sonner/-/sonner-0.6.2.tgz",+ "integrity": "sha512-bh4FWhYoNN481ZIW94W4e0kSLBTMGislYg2YXvDS1px1AJJz4erQe9jHV8s5pS1VMVDgfh3CslNSFLaU6Ldrnw==",+ "peerDependencies": {+ "react": "^18.0.0",+ "react-dom": "^18.0.0"+ }+ },"node_modules/source-map": {"version": "0.6.1","resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",@@ -13800,12 +13786,6 @@"slash": "^3.0.0"}},- "goober": {- "version": "2.1.13",- "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.13.tgz",- "integrity": "sha512-jFj3BQeleOoy7t93E9rZ2de+ScC4lQICLwiAQmKMg9F6roKGaLSHoCDYKkWlSafg138jejvq/mTdvmnwDQgqoQ==",- "requires": {}- },"gopd": {"version": "1.0.1","resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",@@ -15531,14 +15511,6 @@}}},- "react-hot-toast": {- "version": "2.4.1",- "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.4.1.tgz",- "integrity": "sha512-j8z+cQbWIM5LY37pR6uZR6D4LfseplqnuAO4co4u8917hBUvXlEqyP1ZzqVLcqoyUesZZv/ImreoCeHVDpE5pQ==",- "requires": {- "goober": "^2.1.10"- }- },"react-icons": {"version": "4.10.1","resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.10.1.tgz",@@ -16074,6 +16046,12 @@"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz","integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q=="},+ "sonner": {+ "version": "0.6.2",+ "resolved": "https://registry.npmjs.org/sonner/-/sonner-0.6.2.tgz",+ "integrity": "sha512-bh4FWhYoNN481ZIW94W4e0kSLBTMGislYg2YXvDS1px1AJJz4erQe9jHV8s5pS1VMVDgfh3CslNSFLaU6Ldrnw==",+ "requires": {}+ },"source-map": {"version": "0.6.1","resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",diff --git a/package.json b/package.jsonindex 2c487cce..781ca920 100644--- a/package.json+++ b/package.json@@ -53,10 +53,10 @@"react-dom": "18.2.0","react-dropzone": "^14.2.3","react-email": "^1.9.4",- "react-hot-toast": "^2.4.1","react-icons": "^4.10.1","react-pdf": "^7.3.3","resend": "^0.17.2",+ "sonner": "^0.6.2","swr": "^2.2.1","tailwind-merge": "^1.14.0","tailwindcss": "^3.3.3",diff --git a/pages/_app.tsx b/pages/_app.tsxindex 1a0daf4c..791fc344 100644--- a/pages/_app.tsx+++ b/pages/_app.tsx@@ -3,7 +3,7 @@ import type { AppProps } from "next/app";import { Inter } from "next/font/google";import type { Session } from "next-auth";import { SessionProvider } from "next-auth/react";-import { Toaster } from "react-hot-toast";+import { Toaster } from "sonner";import Head from "next/head";import { Analytics } from "@vercel/analytics/react";import { ThemeProvider } from "@/components/theme-provider";@@ -23,7 +23,7 @@ export default function App({<SessionProvider session={session}><ThemeProvider attribute="class" defaultTheme="dark" enableSystem><main className={inter.className}>- <Toaster position="top-right" reverseOrder={false} />+ <Toaster closeButton richColors theme={"dark"} /><Component {...pageProps} /></main></ThemeProvider>