Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Created an onboarding sequence with Spline & Framer Motion

Steven Tey6a01cb525777
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index e7365e458a..e9155e9956 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -29,10 +29,12 @@ function AddEditLinkModal({
showAddEditLinkModal,
setShowAddEditLinkModal,
props,
+ hideXButton,
}: {
showAddEditLinkModal: boolean;
setShowAddEditLinkModal: Dispatch<SetStateAction<boolean>>;
props?: LinkProps;
+ hideXButton?: boolean;
}) {
const router = useRouter();
const { slug } = router.query as { slug: string };
@@ -139,12 +141,14 @@ function AddEditLinkModal({
closeWithX={true}
>
<div className="inline-block max-h-[calc(100vh-50px)] w-full transform overflow-scroll bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
- <button
- onClick={() => setShowAddEditLinkModal(false)}
- className="group absolute top-0 right-0 m-3 hidden rounded-full p-2 text-gray-500 transition-all duration-75 hover:bg-gray-100 focus:outline-none active:bg-gray-200 sm:block"
- >
- <X className="h-5 w-5" />
- </button>
+ {!hideXButton && (
+ <button
+ onClick={() => setShowAddEditLinkModal(false)}
+ className="group absolute top-0 right-0 m-3 hidden rounded-full p-2 text-gray-500 transition-all duration-75 hover:bg-gray-100 focus:outline-none active:bg-gray-200 sm:block"
+ >
+ <X className="h-5 w-5" />
+ </button>
+ )}
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 pt-10 pb-8 sm:px-16">
<BlurImage
@@ -188,7 +192,13 @@ function AddEditLinkModal({
)}`
: `/api/links${getQueryString(router)}`,
);
- setShowAddEditLinkModal(false);
+ if (router.asPath === "/welcome") {
+ router.push("/links").then(() => {
+ setShowAddEditLinkModal(false);
+ });
+ } else {
+ setShowAddEditLinkModal(false);
+ }
} else if (res.status === 403) {
setKeyExistsError(true);
} else if (res.status === 400) {
@@ -370,7 +380,13 @@ function AddEditLinkButton({
);
}
-export function useAddEditLinkModal({ props }: { props?: LinkProps }) {
+export function useAddEditLinkModal({
+ props,
+ hideXButton,
+}: {
+ props?: LinkProps;
+ hideXButton?: boolean;
+}) {
const [showAddEditLinkModal, setShowAddEditLinkModal] = useState(false);
const AddEditLinkModalCallback = useCallback(() => {
@@ -379,9 +395,10 @@ export function useAddEditLinkModal({ props }: { props?: LinkProps }) {
showAddEditLinkModal={showAddEditLinkModal}
setShowAddEditLinkModal={setShowAddEditLinkModal}
props={props}
+ hideXButton={hideXButton}
/>
);
- }, [showAddEditLinkModal, setShowAddEditLinkModal, props]);
+ }, [showAddEditLinkModal, setShowAddEditLinkModal, props, hideXButton]);
const AddEditLinkButtonCallback = useCallback(() => {
return (
diff --git a/components/app/modals/add-project-modal.tsx b/components/app/modals/add-project-modal.tsx
index d09f08df68..9ae7a5ea3e 100644
--- a/components/app/modals/add-project-modal.tsx
+++ b/components/app/modals/add-project-modal.tsx
@@ -18,9 +18,11 @@ import { generateSlugFromName } from "@/lib/utils";
function AddProjectModalHelper({
showAddProjectModal,
setShowAddProjectModal,
+ closeWithX,
}: {
showAddProjectModal: boolean;
setShowAddProjectModal: Dispatch<SetStateAction<boolean>>;
+ closeWithX?: boolean;
}) {
const router = useRouter();
@@ -77,6 +79,7 @@ function AddProjectModalHelper({
<Modal
showModal={showAddProjectModal}
setShowModal={setShowAddProjectModal}
+ closeWithX={closeWithX}
>
<div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
@@ -264,7 +267,7 @@ function AddProjectModalHelper({
);
}
-export function useAddProjectModal({ domain }: { domain?: string }) {
+export function useAddProjectModal({ closeWithX }: { closeWithX?: boolean }) {
const [showAddProjectModal, setShowAddProjectModal] = useState(false);
const AddProjectModal = useCallback(() => {
@@ -272,9 +275,10 @@ export function useAddProjectModal({ domain }: { domain?: string }) {
<AddProjectModalHelper
showAddProjectModal={showAddProjectModal}
setShowAddProjectModal={setShowAddProjectModal}
+ closeWithX={closeWithX}
/>
);
- }, [showAddProjectModal, setShowAddProjectModal, domain]);
+ }, [showAddProjectModal, setShowAddProjectModal, closeWithX]);
return useMemo(
() => ({ setShowAddProjectModal, AddProjectModal }),
diff --git a/components/app/welcome/interim.tsx b/components/app/welcome/interim.tsx
new file mode 100644
index 0000000000..60c06a345e
--- /dev/null
+++ b/components/app/welcome/interim.tsx
@@ -0,0 +1,51 @@
+import { Dispatch, SetStateAction, useState } from "react";
+import { motion } from "framer-motion";
+
+export default function Interim({
+ setState,
+ staggerChildVariants,
+}: {
+ setState: Dispatch<SetStateAction<string>>;
+ staggerChildVariants: any;
+}) {
+ return (
+ <motion.div
+ className="z-10 my-auto 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.3,
+ },
+ },
+ }}
+ initial="hidden"
+ animate="show"
+ exit="hidden"
+ transition={{ duration: 0.5, type: "spring" }}
+ >
+ <motion.h1
+ className="font-display text-4xl font-bold text-gray-800 transition-colors sm:text-5xl"
+ variants={staggerChildVariants}
+ >
+ Welcome to Dub
+ </motion.h1>
+ <motion.p
+ className="max-w-md text-gray-600 transition-colors sm:text-lg"
+ variants={staggerChildVariants}
+ >
+ Dub provides you with a suite of powerful features that gives you
+ marketing superpowers.
+ </motion.p>
+ <motion.button
+ variants={staggerChildVariants}
+ className="rounded-full bg-gray-800 px-10 py-2 font-medium text-white transition-colors hover:bg-black"
+ onClick={() => setState("interim")}
+ >
+ Get Started
+ </motion.button>
+ </motion.div>
+ );
+}
diff --git a/components/app/welcome/intro.tsx b/components/app/welcome/intro.tsx
new file mode 100644
index 0000000000..91047e85be
--- /dev/null
+++ b/components/app/welcome/intro.tsx
@@ -0,0 +1,76 @@
+import Spline from "@splinetool/react-spline";
+import { Dispatch, SetStateAction, useState } from "react";
+import { useDebounce } from "use-debounce";
+import { motion } from "framer-motion";
+
+export default function Intro({
+ setState,
+ staggerChildVariants,
+}: {
+ setState: Dispatch<SetStateAction<string>>;
+ staggerChildVariants: any;
+}) {
+ const [loading, setLoading] = useState(true);
+ const onLoad = () => {
+ setLoading(false);
+ };
+ // workarouond to avoid the blinking effect when Spline loads
+ const [opacity] = useDebounce(loading ? 0 : 1, 200);
+
+ const [showText] = useDebounce(loading ? false : true, 800);
+
+ return (
+ <motion.div
+ className="z-10"
+ exit={{ opacity: 0, scale: 0.95 }}
+ transition={{ duration: 0.5, type: "spring" }}
+ >
+ <div
+ className={`${
+ loading ? "scale-[25%] blur-md" : "scale-100 blur-0"
+ } mt-[5vh] h-[50vh] w-screen object-cover transition-all duration-1000`}
+ >
+ <Spline
+ onLoad={onLoad}
+ style={{ opacity: opacity }}
+ scene="https://prod.spline.design/cJkq6hsiUPNRHeMf/scene.splinecode"
+ />
+ </div>
+ {showText && (
+ <motion.div
+ variants={{
+ show: {
+ transition: {
+ staggerChildren: 0.3,
+ },
+ },
+ }}
+ 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-gray-800 transition-colors sm:text-5xl"
+ variants={staggerChildVariants}
+ >
+ Welcome to Dub
+ </motion.h1>
+ <motion.p
+ className="max-w-md text-gray-600 transition-colors sm:text-lg"
+ variants={staggerChildVariants}
+ >
+ Dub provides you with a suite of powerful features that gives you
+ marketing superpowers.
+ </motion.p>
+ <motion.button
+ variants={staggerChildVariants}
+ className="rounded-full bg-gray-800 px-10 py-2 font-medium text-white transition-colors hover:bg-black"
+ onClick={() => setState("interim")}
+ >
+ Get Started
+ </motion.button>
+ </motion.div>
+ )}
+ </motion.div>
+ );
+}
diff --git a/components/home/background.module.css b/components/shared/background/background.module.css
similarity index 100%
rename from components/home/background.module.css
rename to components/shared/background/background.module.css
diff --git a/components/home/background.tsx b/components/shared/background/index.tsx
similarity index 100%
rename from components/home/background.tsx
rename to components/shared/background/index.tsx
diff --git a/components/shared/blur-image.tsx b/components/shared/blur-image.tsx
index 01bc28dc8a..4b5a0910c4 100644
--- a/components/shared/blur-image.tsx
+++ b/components/shared/blur-image.tsx
@@ -2,7 +2,7 @@ import Image, { ImageProps } from "next/image";
import { useEffect, useState } from "react";
export default function BlurImage(props: ImageProps) {
- const [isLoading, setLoading] = useState(true);
+ const [loading, setLoading] = useState(true);
const [src, setSrc] = useState(props.src);
useEffect(() => setSrc(props.src), [props.src]); // update the `src` value when the `prop.src` value changes
@@ -12,7 +12,7 @@ export default function BlurImage(props: ImageProps) {
src={src}
alt={props.alt}
className={`${props.className} ${
- isLoading ? "blur-sm grayscale" : "blur-0 grayscale-0"
+ loading ? "blur-sm grayscale" : "blur-0 grayscale-0"
}`}
onLoadingComplete={async () => {
setLoading(false);
diff --git a/pages/app/index.tsx b/pages/app/index.tsx
index 8f129eea91..6faee66e37 100644
--- a/pages/app/index.tsx
+++ b/pages/app/index.tsx
@@ -18,7 +18,7 @@ export default function App() {
return (
<AppLayout>
- {data && <AddProjectModal />}
+ <AddProjectModal />
<div className="flex h-36 items-center border-b border-gray-200 bg-white">
<MaxWidthWrapper>
<div className="flex items-center justify-between">
diff --git a/pages/app/login.tsx b/pages/app/login.tsx
index 396f0e71eb..39ef41222c 100644
--- a/pages/app/login.tsx
+++ b/pages/app/login.tsx
@@ -4,6 +4,7 @@ import { signIn } from "next-auth/react";
import Meta from "@/components/layout/meta";
import BlurImage from "@/components/shared/blur-image";
import { LoadingDots } from "@/components/shared/icons";
+import Background from "@/components/shared/background";
export default function Login() {
const [signInClicked, setSignInClicked] = useState(false);
@@ -14,7 +15,8 @@ export default function Login() {
return (
<div className="flex h-screen w-screen items-center justify-center bg-gray-50">
<Meta />
- <div className="w-full max-w-md overflow-hidden rounded-2xl border border-gray-100 shadow-xl">
+ <Background />
+ <div className="z-10 w-full max-w-md overflow-hidden rounded-2xl border border-gray-100 shadow-xl">
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 bg-white px-4 py-6 pt-8 text-center sm:px-16">
<a href="https://dub.sh">
<BlurImage
diff --git a/pages/app/register.tsx b/pages/app/register.tsx
index bd0f8ca87e..ebc8305649 100644
--- a/pages/app/register.tsx
+++ b/pages/app/register.tsx
@@ -4,6 +4,7 @@ import { signIn } from "next-auth/react";
import Meta from "@/components/layout/meta";
import BlurImage from "@/components/shared/blur-image";
import { LoadingDots } from "@/components/shared/icons";
+import Background from "@/components/shared/background";
export default function Login() {
const [signInClicked, setSignInClicked] = useState(false);
@@ -14,7 +15,8 @@ export default function Login() {
return (
<div className="flex h-screen w-screen items-center justify-center bg-gray-50">
<Meta />
- <div className="w-full max-w-md overflow-hidden rounded-2xl border border-gray-100 shadow-xl">
+ <Background />
+ <div className="z-10 w-full max-w-md overflow-hidden rounded-2xl border border-gray-100 shadow-xl">
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 bg-white px-4 py-6 pt-8 text-center sm:px-16">
<BlurImage
src="/_static/logo.png"
@@ -42,6 +44,7 @@ export default function Login() {
signIn("email", {
email,
redirect: false,
+ callbackUrl: "/welcome",
}).then((res) => {
setSignInClicked(false);
if (res?.ok && !res?.error) {
diff --git a/pages/app/welcome.tsx b/pages/app/welcome.tsx
new file mode 100644
index 0000000000..916669e21b
--- /dev/null
+++ b/pages/app/welcome.tsx
@@ -0,0 +1,60 @@
+import Background from "@/components/shared/background";
+import Intro from "@/components/app/welcome/intro";
+import Interim from "@/components/app/welcome/interim";
+import { AnimatePresence } from "framer-motion";
+import { useEffect, useState } from "react";
+import { useAddProjectModal } from "@/components/app/modals/add-project-modal";
+import { useAddEditLinkModal } from "@/components/app/modals/add-edit-link-modal";
+
+const staggerChildVariants = {
+ hidden: { opacity: 0, y: 20 },
+ show: { opacity: 1, y: 0, transition: { duration: 0.4, type: "spring" } },
+};
+
+export default function Welcome() {
+ const [state, setState] = useState("intro");
+
+ const { setShowAddProjectModal, AddProjectModal } = useAddProjectModal({
+ closeWithX: true,
+ });
+ const { setShowAddEditLinkModal, AddEditLinkModal } = useAddEditLinkModal({
+ hideXButton: true,
+ });
+
+ useEffect(() => {
+ if (state === "project") {
+ setTimeout(() => {
+ setShowAddProjectModal(true);
+ }, 200);
+ }
+ if (state === "link") {
+ setTimeout(() => {
+ setShowAddEditLinkModal(true);
+ }, 200);
+ }
+ }, [state]);
+
+ return (
+ <div className="flex h-screen flex-col items-center">
+ <Background />
+ <AddProjectModal />
+ <AddEditLinkModal />
+ <AnimatePresence>
+ {state === "intro" && (
+ <Intro
+ key="intro"
+ setState={setState}
+ staggerChildVariants={staggerChildVariants}
+ />
+ )}
+ {state === "interim" && (
+ <Interim
+ key="interim"
+ setState={setState}
+ staggerChildVariants={staggerChildVariants}
+ />
+ )}
+ </AnimatePresence>
+ </div>
+ );
+}
diff --git a/pages/index.tsx b/pages/index.tsx
index ae8d7f87a6..a38df19ee5 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -2,7 +2,7 @@ import { useRouter } from "next/router";
import { useCallback, useEffect } from "react";
import prisma from "@/lib/prisma";
import { useStatsModal } from "@/components/app/modals/stats-modal";
-import Background from "@/components/home/background";
+import Background from "@/components/shared/background";
import Demo from "@/components/home/demo";
import Features from "@/components/home/features";
import Globe from "@/components/home/globe";