The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add dashboard onboarding menu
Tim Wilson218f6d4c0e7f
diff --git a/apps/web/app/app.dub.co/(auth)/layout.tsx b/apps/web/app/app.dub.co/(auth)/layout.tsxindex ba4f19769c..08f1e01538 100644--- a/apps/web/app/app.dub.co/(auth)/layout.tsx+++ b/apps/web/app/app.dub.co/(auth)/layout.tsx@@ -1,4 +1,4 @@-import HelpPortal from "@/ui/layout/help";+import Toolbar from "@/ui/layout/toolbar/toolbar";import { Background } from "@dub/ui";import Providers from "app/providers";import { ReactNode } from "react";@@ -6,7 +6,7 @@ import { ReactNode } from "react";export default function AuthLayout({ children }: { children: ReactNode }) {return (<Providers>- <HelpPortal />+ <Toolbar /><Background /><div className="relative z-10 flex min-h-screen w-screen justify-center">{children}diff --git a/apps/web/app/app.dub.co/(dashboard)/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/layout.tsxindex 60537a95e7..da2233af35 100644--- a/apps/web/app/app.dub.co/(dashboard)/layout.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/layout.tsx@@ -1,7 +1,7 @@import ChangelogPopup from "@/ui/layout/changelog-popup";-import HelpPortal from "@/ui/layout/help";import { MainNav } from "@/ui/layout/main-nav";import NavTabs from "@/ui/layout/nav-tabs";+import Toolbar from "@/ui/layout/toolbar/toolbar";import { MaxWidthWrapper } from "@dub/ui";import { constructMetadata } from "@dub/utils";import { ReactNode, Suspense } from "react";@@ -26,7 +26,7 @@ export default function Layout({ children }: { children: ReactNode }) {</div>{/* <UserSurveyPopup /> */}<ChangelogPopup />- <HelpPortal />+ <Toolbar /></Providers>);}diff --git a/apps/web/lib/swr/use-domains-count.ts b/apps/web/lib/swr/use-domains-count.tsindex 2d72ce2747..f15e99190e 100644--- a/apps/web/lib/swr/use-domains-count.ts+++ b/apps/web/lib/swr/use-domains-count.ts@@ -17,7 +17,7 @@ export default function useDomainsCount() {return {data,- loading: !error && !data,+ loading: !error && data === undefined,error,};}diff --git a/apps/web/ui/layout/help/index.tsx b/apps/web/ui/layout/help/index.tsxdeleted file mode 100644index 4116d04bd8..0000000000--- a/apps/web/ui/layout/help/index.tsx+++ /dev/null@@ -1,37 +0,0 @@-import { Suspense } from "react";-import { HelpButton } from "./portal";--export interface HelpArticle {- title: string;- summary: string;- searchableSummary?: string;- slug: string;-}--export default function HelpPortal() {- return (- <Suspense fallback={null}>- <div className="fixed bottom-0 right-0 z-40 m-5">- <HelpPortalRSC />- </div>- </Suspense>- );-}--async function HelpPortalRSC() {- const { popularHelpArticles, allHelpArticles } = await fetch(- "https://dub.co/api/content",- {- next: {- revalidate: 60 * 60 * 24, // cache for 24 hours- },- },- ).then((res) => res.json());-- return (- <HelpButton- popularHelpArticles={popularHelpArticles}- allHelpArticles={allHelpArticles}- />- );-}diff --git a/apps/web/ui/layout/nav-tabs.tsx b/apps/web/ui/layout/nav-tabs.tsxindex e54dcdc9dd..06ca9204e7 100644--- a/apps/web/ui/layout/nav-tabs.tsx+++ b/apps/web/ui/layout/nav-tabs.tsx@@ -1,17 +1,14 @@"use client";import useDomains from "@/lib/swr/use-domains";-import useDomainsCount from "@/lib/swr/use-domains-count";import useLinksCount from "@/lib/swr/use-links-count";-import useUsers from "@/lib/swr/use-users";import useWorkspace from "@/lib/swr/use-workspace";-import { ModalContext } from "@/ui/modals/modal-provider";-import { Badge, useScroll } from "@dub/ui";+import { useScroll } from "@dub/ui";import { cn } from "@dub/utils";import { motion } from "framer-motion";import Link from "next/link";import { useParams, usePathname, useSearchParams } from "next/navigation";-import { useContext, useMemo } from "react";+import { useMemo } from "react";export default function NavTabs() {const pathname = usePathname();@@ -66,39 +63,6 @@ export default function NavTabs() {</Link>);})}- {slug &&- !loading &&- !error &&- !loadingDomains &&- !domain &&- linksCount === 0 && <OnboardingChecklist />}</div>);}-const OnboardingChecklist = () => {- const { setShowCompleteSetupModal } = useContext(ModalContext);- const { data: domainsCount } = useDomainsCount();- const { data: links } = useLinksCount({ ignoreParams: true });- const { users } = useUsers();- const { users: invites } = useUsers({ invites: true });-- const remainder = useMemo(() => {- return (- (domainsCount && domainsCount > 0 ? 0 : 1) +- (links > 0 ? 0 : 1) +- ((users && users.length > 1) || (invites && invites.length > 0) ? 0 : 1)- );- }, [domainsCount, links, invites, users]);-- return (- <button- onClick={() => setShowCompleteSetupModal(true)}- className="flex items-center space-x-2 rounded-md border-b-2 border-transparent p-1 px-3 py-2 transition-all duration-75 hover:bg-gray-100 active:bg-gray-200"- >- <p className="whitespace-nowrap text-sm text-gray-600">- Onboarding Checklist- </p>- <Badge variant="blue">{remainder.toString()}</Badge>- </button>- );-};diff --git a/apps/web/ui/layout/help/contact-form.tsx b/apps/web/ui/layout/toolbar/help/contact-form.tsxsimilarity index 100%rename from apps/web/ui/layout/help/contact-form.tsxrename to apps/web/ui/layout/toolbar/help/contact-form.tsxdiff --git a/apps/web/ui/layout/help/help-articles.tsx b/apps/web/ui/layout/toolbar/help/help-articles.tsxsimilarity index 99%rename from apps/web/ui/layout/help/help-articles.tsxrename to apps/web/ui/layout/toolbar/help/help-articles.tsxindex 3ff501e07f..c999db8ec2 100644--- a/apps/web/ui/layout/help/help-articles.tsx+++ b/apps/web/ui/layout/toolbar/help/help-articles.tsx@@ -7,7 +7,7 @@ import posthog from "posthog-js";import { Dispatch, SetStateAction, useContext, useMemo, useRef } from "react";import Highlighter from "react-highlight-words";import { useDebouncedCallback } from "use-debounce";-import { HelpContext } from "./portal";+import { HelpContext } from "./help-button";export function HelpArticles({setScreen,diff --git a/apps/web/ui/layout/help/portal.tsx b/apps/web/ui/layout/toolbar/help/help-button.tsxsimilarity index 100%rename from apps/web/ui/layout/help/portal.tsxrename to apps/web/ui/layout/toolbar/help/help-button.tsxdiff --git a/apps/web/ui/layout/toolbar/help/index.tsx b/apps/web/ui/layout/toolbar/help/index.tsxnew file mode 100644index 0000000000..730aaa67f2--- /dev/null+++ b/apps/web/ui/layout/toolbar/help/index.tsx@@ -0,0 +1,6 @@+export interface HelpArticle {+ title: string;+ summary: string;+ searchableSummary?: string;+ slug: string;+}diff --git a/apps/web/ui/layout/toolbar/onboarding/onboarding-button.tsx b/apps/web/ui/layout/toolbar/onboarding/onboarding-button.tsxnew file mode 100644index 0000000000..57a7636f91--- /dev/null+++ b/apps/web/ui/layout/toolbar/onboarding/onboarding-button.tsx@@ -0,0 +1,181 @@+"use client";++import useDomainsCount from "@/lib/swr/use-domains-count";+import useLinksCount from "@/lib/swr/use-links-count";+import useUsers from "@/lib/swr/use-users";+import { CheckCircleFill, ThreeDots, X } from "@/ui/shared/icons";+import { Popover, useLocalStorage, useMediaQuery } from "@dub/ui";+import { CircleDotted, ExpandingArrow } from "@dub/ui/src/icons";+import { ChevronDown } from "lucide-react";+import Link from "next/link";+import { useParams } from "next/navigation";+import { forwardRef, HTMLAttributes, Ref, useMemo, useState } from "react";++export function OnboardingButton() {+ const { isMobile } = useMediaQuery();+ const [hideForever, setHideForever] = useLocalStorage(+ "onboarding-hide-forever",+ false,+ );++ return !isMobile && !hideForever ? (+ <OnboardingButtonInner onHideForever={() => setHideForever(true)} />+ ) : null;+}++function OnboardingButtonInner({+ onHideForever,+}: {+ onHideForever: () => void;+}) {+ const { slug } = useParams() as { slug: string };++ const { data: domainsCount, loading: domainsLoading } = useDomainsCount();+ const { data: linksCount, loading: linksLoading } = useLinksCount({+ ignoreParams: true,+ });+ const { users, loading: usersLoading } = useUsers();+ const { users: invites, loading: invitesLoading } = useUsers({+ invites: true,+ });++ const loading =+ domainsLoading || linksLoading || usersLoading || invitesLoading;++ const tasks = useMemo(() => {+ return [+ {+ display: "Create a new Dub link",+ cta: `/${slug}`,+ checked: linksCount > 0,+ },+ {+ display: "Set up your custom domain",+ cta: `/${slug}/settings/domains`,+ checked: domainsCount && domainsCount > 0,+ },+ {+ display: "Invite your teammates",+ cta: `/${slug}/settings/people`,+ checked: (users && users.length > 1) || (invites && invites.length > 0),+ },+ ];+ }, [slug, domainsCount, linksCount, users, invites]);++ const [isOpen, setIsOpen] = useState(false);++ const completedTasks = tasks.filter((task) => task.checked).length;++ return loading || completedTasks === tasks.length ? null : (+ <Popover+ align="end"+ popoverContentClassName="rounded-xl"+ content={+ <div>+ <div className="rounded-t-xl bg-black p-4 text-white">+ <div className="flex items-start justify-between gap-2">+ <div>+ <span className="text-base font-medium">Getting Started</span>+ <p className="mt-1 text-sm text-gray-300">+ Get familiar with Dub by completing the{" "}+ <br className="hidden sm:block" />+ following tasks+ </p>+ </div>+ <div className="flex items-center gap-1">+ <OnboardingMenu+ onHideForever={() => {+ onHideForever();+ setIsOpen(false);+ }}+ />+ <MiniButton onClick={() => setIsOpen(false)}>+ <ChevronDown className="size-4" />+ </MiniButton>+ </div>+ </div>+ </div>+ <div className="p-3">+ <div className="grid divide-y divide-gray-200 rounded-lg border border-gray-200 bg-white">+ {tasks.map(({ display, cta, checked }) => {+ return (+ <Link+ key={display}+ href={cta}+ onClick={() => setIsOpen(false)}+ >+ <div className="group flex items-center justify-between gap-3 p-3 sm:gap-10">+ <div className="flex items-center gap-2">+ {checked ? (+ <CheckCircleFill className="size-5 text-green-500" />+ ) : (+ <CircleDotted className="size-5 text-gray-400" />+ )}+ <p className="text-sm text-gray-800">{display}</p>+ </div>+ <div className="mr-5">+ <ExpandingArrow className="text-gray-500" />+ </div>+ </div>+ </Link>+ );+ })}+ </div>+ </div>+ </div>+ }+ openPopover={isOpen}+ setOpenPopover={setIsOpen}+ >+ <button+ type="button"+ className="animate-slide-up-fade -mt-1 flex h-12 flex-col items-center justify-center rounded-full border border-gray-950 bg-gray-950 px-6 text-xs font-medium leading-tight text-white shadow-md transition-all [--offset:10px] hover:bg-gray-800 hover:ring-4 hover:ring-gray-200"+ >+ <span>Getting Started</span>+ <span className="text-gray-400">+ {Math.round((completedTasks / tasks.length) * 100)}% complete+ </span>+ </button>+ </Popover>+ );+}++const MiniButton = forwardRef(+ (props: HTMLAttributes<HTMLButtonElement>, ref: Ref<HTMLButtonElement>) => {+ return (+ <button+ ref={ref}+ type="button"+ {...props}+ className="rounded-md px-1 py-1 text-gray-400 transition-colors hover:bg-white/20 active:text-white"+ />+ );+ },+);++function OnboardingMenu({ onHideForever }: { onHideForever: () => void }) {+ const [isOpen, setIsOpen] = useState(false);++ return (+ <Popover+ align="end"+ content={+ <div className="p-2">+ <button+ onClick={onHideForever}+ className="flex w-full items-center gap-2 rounded-md p-2 text-sm text-gray-600 hover:bg-gray-100 active:bg-gray-200"+ >+ <X className="size-4" />+ Dismiss forever+ </button>+ </div>+ }+ openPopover={isOpen}+ setOpenPopover={setIsOpen}+ >+ <MiniButton>+ <ThreeDots className="size-4" />+ </MiniButton>+ </Popover>+ );+}diff --git a/apps/web/ui/layout/toolbar/toolbar.tsx b/apps/web/ui/layout/toolbar/toolbar.tsxnew file mode 100644index 0000000000..bcf23dc487--- /dev/null+++ b/apps/web/ui/layout/toolbar/toolbar.tsx@@ -0,0 +1,38 @@+import { Suspense } from "react";+import { HelpButton } from "./help/help-button";+import { OnboardingButton } from "./onboarding/onboarding-button";++export default function Toolbar() {+ return (+ <Suspense fallback={null}>+ <div className="fixed bottom-0 right-0 z-40 m-5">+ <ToolbarRSC />+ </div>+ </Suspense>+ );+}++async function ToolbarRSC() {+ const { popularHelpArticles, allHelpArticles } = await fetch(+ "https://dub.co/api/content",+ {+ next: {+ revalidate: 60 * 60 * 24, // cache for 24 hours+ },+ },+ ).then((res) => res.json());++ return (+ <div className="flex items-center gap-3">+ <div className="shrink-0">+ <OnboardingButton />+ </div>+ <div className="shrink-0">+ <HelpButton+ popularHelpArticles={popularHelpArticles}+ allHelpArticles={allHelpArticles}+ />+ </div>+ </div>+ );+}diff --git a/apps/web/ui/links/links-container.tsx b/apps/web/ui/links/links-container.tsxindex a917ddccc8..1f4788e327 100644--- a/apps/web/ui/links/links-container.tsx+++ b/apps/web/ui/links/links-container.tsx@@ -11,6 +11,7 @@ import {usePagination,} from "@dub/ui";import { LoadingSpinner } from "@dub/ui/src/icons";+import { cn } from "@dub/utils";import { useSearchParams } from "next/navigation";import {Dispatch,@@ -124,7 +125,12 @@ function LinksList({{links && (<><div className="h-[90px]" />- <div className="fixed bottom-4 left-1/2 w-full max-w-[768px] -translate-x-1/2 px-2.5 max-[920px]:bottom-5 max-[920px]:pr-20">+ <div+ className={cn(+ "fixed bottom-4 left-1/2 w-full max-w-[768px] -translate-x-1/2 px-2.5",+ "max-[1216px]:bottom-5 max-[1216px]:left-2 max-[1216px]:max-w-[min(calc(100%-232px),768px)] max-[1216px]:translate-x-0",+ )}+ ><div className="rounded-xl border border-gray-200 bg-white px-4 py-3.5 [filter:drop-shadow(0_5px_8px_#222A351d)]"><PaginationControlspagination={pagination}diff --git a/packages/ui/src/icons/nucleo/circle-dotted.tsx b/packages/ui/src/icons/nucleo/circle-dotted.tsxnew file mode 100644index 0000000000..035ecc7ee0--- /dev/null+++ b/packages/ui/src/icons/nucleo/circle-dotted.tsx@@ -0,0 +1,104 @@+import { SVGProps } from "react";++export function CircleDotted(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="18"+ width="18"+ viewBox="0 0 18 18"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <circle+ cx="3.873"+ cy="14.127"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle cx="1.75" cy="9" fill="currentColor" r=".75" stroke="none" />+ <circle+ cx="3.873"+ cy="3.873"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle+ cx="6.226"+ cy="15.698"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle+ cx="2.302"+ cy="11.774"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle+ cx="2.302"+ cy="6.226"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle+ cx="6.226"+ cy="2.302"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle cx="9" cy="1.75" fill="currentColor" r=".75" stroke="none" />+ <circle cx="9" cy="16.25" fill="currentColor" r=".75" stroke="none" />+ <circle+ cx="14.127"+ cy="14.127"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle cx="16.25" cy="9" fill="currentColor" r=".75" stroke="none" />+ <circle+ cx="14.127"+ cy="3.873"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle+ cx="11.774"+ cy="15.698"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle+ cx="15.698"+ cy="11.774"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle+ cx="15.698"+ cy="6.226"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle+ cx="11.774"+ cy="2.302"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.tsindex c271c618b7..fa0fb9f636 100644--- a/packages/ui/src/icons/nucleo/index.ts+++ b/packages/ui/src/icons/nucleo/index.ts@@ -13,6 +13,7 @@ export * from "./chart-activity2";export * from "./chart-line";export * from "./check";export * from "./circle-check";+export * from "./circle-dotted";export * from "./circle-half-dotted-clock";export * from "./circle-info";export * from "./circle-warning";