The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Dub Partners popup
Tim Wilson3996f5751a69
diff --git a/apps/web/lib/zod/schemas/workspaces.ts b/apps/web/lib/zod/schemas/workspaces.tsindex 9daf99ddd8..8226d7b89d 100644--- a/apps/web/lib/zod/schemas/workspaces.ts+++ b/apps/web/lib/zod/schemas/workspaces.ts@@ -166,5 +166,6 @@ export const WorkspaceSchemaExtended = WorkspaceSchema.extend({export const workspaceStoreKeys = z.enum(["programOnboarding", // json"conversionsOnboarding", // boolean+ "dubPartnersPopupDismissed", // boolean"dotLinkOfferDismissed", // string]);diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsxindex 1d0622a213..751eec7820 100644--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx@@ -31,6 +31,7 @@ import { Session } from "next-auth";import { useSession } from "next-auth/react";import { useParams, usePathname } from "next/navigation";import { ReactNode, useMemo } from "react";+import { DubPartnersPopup } from "./dub-partners-popup";import { Compass } from "./icons/compass";import { ConnectedDots4 } from "./icons/connected-dots4";import { CursorRays } from "./icons/cursor-rays";@@ -81,6 +82,7 @@ const NAV_GROUPS: SidebarNavGroups<SidebarNavData> = ({icon: ConnectedDots4,href: slug ? `/${slug}/program` : "/program",active: pathname.startsWith(`/${slug}/program`),+ popup: DubPartnersPopup,onClick: defaultProgramId? () => {diff --git a/apps/web/ui/layout/sidebar/dub-partners-popup.tsx b/apps/web/ui/layout/sidebar/dub-partners-popup.tsxnew file mode 100644index 0000000000..2e2937a92f--- /dev/null+++ b/apps/web/ui/layout/sidebar/dub-partners-popup.tsx@@ -0,0 +1,168 @@+"use client";++import { getPlanCapabilities } from "@/lib/plan-capabilities";+import useWorkspace from "@/lib/swr/use-workspace";+import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";+import { X } from "@/ui/shared/icons";+import { BlurImage, useMediaQuery } from "@dub/ui";+import {+ arrow,+ autoUpdate,+ FloatingArrow,+ FloatingPortal,+ offset,+ shift,+ useFloating,+} from "@floating-ui/react";+import { Play } from "lucide-react";+import Link from "next/link";+import { useRef } from "react";++export function DubPartnersPopup({+ referenceElement,+}: {+ referenceElement: HTMLElement | null;+}) {+ const { isMobile } = useMediaQuery();++ const {+ plan,+ defaultProgramId,+ partnersEnabled,+ loading: loadingWorkspace,+ } = useWorkspace({+ swrOpts: { keepPreviousData: true },+ });++ const { canManageProgram } = getPlanCapabilities(plan);++ const [dismissed, setDismissed, { loading: loadingDismissed }] =+ useWorkspaceStore<undefined | boolean>("dubPartnersPopupDismissed");++ if (+ // Loading+ loadingWorkspace ||+ loadingDismissed ||+ // Program/partners status/capabilities+ defaultProgramId ||+ !partnersEnabled ||+ !canManageProgram ||+ // Device+ isMobile ||+ // Dismissed+ dismissed+ )+ return null;++ return (+ <DubPartnersPopupInner+ referenceElement={referenceElement}+ onDismiss={() => setDismissed(true)}+ />+ );+}++function DubPartnersPopupInner({+ referenceElement,+ onDismiss,+}: {+ referenceElement: HTMLElement | null;+ onDismiss: () => void;+}) {+ const arrowRef = useRef<SVGSVGElement>(null);++ const { refs, floatingStyles, context } = useFloating({+ placement: "right",+ strategy: "fixed",+ whileElementsMounted(referenceEl, floatingEl, update) {+ return autoUpdate(referenceEl, floatingEl, update, {+ // Not good for performance but keeps the arrow and floating element in the right spot+ animationFrame: true,+ });+ },+ elements: {+ reference: referenceElement,+ },+ middleware: [+ offset({+ mainAxis: 12,+ crossAxis: -10,+ }),+ shift({+ padding: 32,+ }),+ arrow({+ element: arrowRef,+ }),+ ],+ });++ const { slug } = useWorkspace();++ return (+ <FloatingPortal>+ <div+ ref={refs.setFloating}+ style={floatingStyles}+ className="drop-shadow-sm"+ >+ <div className="animate-slide-up-fade relative flex w-[260px] flex-col rounded-lg border border-neutral-900 bg-neutral-800 p-3 text-left">+ <div className="relative">+ <Link+ href="https://d.to/partners"+ target="_blank"+ className="group relative flex aspect-video w-full items-center justify-center overflow-hidden rounded-md border border-neutral-900 bg-neutral-800"+ >+ <BlurImage+ src="https://assets.dub.co/misc/dub-partners-thumbnail.jpg"+ alt="thumbnail"+ fill+ className="object-cover opacity-60"+ />+ <div className="relative flex size-10 items-center justify-center rounded-full bg-neutral-900 ring-[6px] ring-black/5 transition-all duration-75 group-hover:ring-[8px] group-active:ring-[7px]">+ <Play className="size-4 fill-current text-white" />+ </div>+ </Link>+ <button+ type="button"+ onClick={onDismiss}+ className="absolute right-2 top-2 rounded-md bg-black/30 p-1.5 shadow-sm transition-colors duration-75 hover:bg-black/40"+ >+ <X className="size-4 text-white" strokeWidth={2} />+ </button>+ </div>+ <h2 className="text-content-inverted mt-4 text-sm font-semibold">+ Dub Partners unlocked+ </h2>+ <p className="mt-1.5 text-xs text-neutral-300">+ Create your Partner Program and put revenue on autopilot.+ </p>+ <div className="mt-4 grid w-full grid-cols-2 gap-2">+ <Link+ href="https://dub.co/help/article/dub-partners"+ target="_blank"+ className="flex h-7 items-center justify-center whitespace-nowrap rounded-md bg-white/10 px-2.5 text-xs text-white transition-colors duration-150 hover:bg-white/15"+ >+ Quickstart guide+ </Link>+ <Link+ href={`/${slug}/program/new`}+ className="flex h-7 items-center justify-center whitespace-nowrap rounded-md bg-white px-2.5 text-xs text-black transition-colors duration-150 hover:bg-white/90"+ onClick={onDismiss}+ >+ Create program+ </Link>+ </div>+ <FloatingArrow+ ref={arrowRef}+ context={context}+ className="stroke-neutral-900 text-neutral-800"+ fill="currentColor"+ strokeWidth={1}+ height={10}+ />+ </div>+ </div>+ </FloatingPortal>+ );+}diff --git a/apps/web/ui/layout/sidebar/sidebar-nav.tsx b/apps/web/ui/layout/sidebar/sidebar-nav.tsxindex bb1ffda12f..5efc191404 100644--- a/apps/web/ui/layout/sidebar/sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/sidebar-nav.tsx@@ -12,6 +12,7 @@ import { ChevronDown } from "lucide-react";import Link from "next/link";import { usePathname } from "next/navigation";import {+ ComponentType,PropsWithChildren,ReactNode,Suspense,@@ -41,6 +42,9 @@ export type NavGroupType = {href: string;active: boolean;onClick?: () => void;+ popup?: ComponentType<{+ referenceElement: HTMLElement | null;+ }>;description: string;learnMoreHref?: string;@@ -257,39 +261,45 @@ function NavGroupItem({href,active,onClick,+ popup: Popup,},}: {group: NavGroupType;}) {+ const [element, setElement] = useState<HTMLAnchorElement | null>(null);const [hovered, setHovered] = useState(false);return (- <NavGroupTooltip- name={name}- description={description}- learnMoreHref={learnMoreHref}- >- <div>- <Link- href={href}- onPointerEnter={() => setHovered(true)}- onPointerLeave={() => setHovered(false)}- onClick={onClick}- className={cn(- "flex size-11 items-center justify-center rounded-lg transition-colors duration-150",- "outline-none focus-visible:ring-2 focus-visible:ring-black/50",- active- ? "bg-white"- : "hover:bg-bg-inverted/5 active:bg-bg-inverted/10",- )}- >- <Icon- className="text-content-default size-5"- data-hovered={hovered}- />- </Link>- </div>- </NavGroupTooltip>+ <>+ <NavGroupTooltip+ name={name}+ description={description}+ learnMoreHref={learnMoreHref}+ >+ <div>+ <Link+ ref={Popup ? setElement : undefined}+ href={href}+ onPointerEnter={() => setHovered(true)}+ onPointerLeave={() => setHovered(false)}+ onClick={onClick}+ className={cn(+ "flex size-11 items-center justify-center rounded-lg transition-colors duration-150",+ "outline-none focus-visible:ring-2 focus-visible:ring-black/50",+ active+ ? "bg-white"+ : "hover:bg-bg-inverted/5 active:bg-bg-inverted/10",+ )}+ >+ <Icon+ className="text-content-default size-5"+ data-hovered={hovered}+ />+ </Link>+ </div>+ </NavGroupTooltip>+ {Popup && element && <Popup referenceElement={element} />}+ </>);}diff --git a/apps/web/ui/layout/sidebar/workspace-dropdown.tsx b/apps/web/ui/layout/sidebar/workspace-dropdown.tsxindex b47c8a2ff3..2af3190885 100644--- a/apps/web/ui/layout/sidebar/workspace-dropdown.tsx+++ b/apps/web/ui/layout/sidebar/workspace-dropdown.tsx@@ -11,7 +11,6 @@ import {} from "@dub/ui";import { Check2, Gear, Plus, UserPlus } from "@dub/ui/icons";import { cn, OG_AVATAR_URL } from "@dub/utils";-import { ChevronsUpDown } from "lucide-react";import { useSession } from "next-auth/react";import Link from "next/link";import { useParams, usePathname } from "next/navigation";@@ -113,11 +112,7 @@ export function WorkspaceDropdown() {function WorkspaceDropdownPlaceholder() {return (- <div className="flex w-full animate-pulse items-center gap-x-1.5 rounded-lg p-1.5">- <div className="size-7 animate-pulse rounded-full bg-neutral-200" />- <div className="mb-px mt-0.5 h-8 w-28 grow animate-pulse rounded-md bg-neutral-200" />- <ChevronsUpDown className="h-4 w-4 text-neutral-400" aria-hidden="true" />- </div>+ <div className="flex size-11 animate-pulse items-center gap-x-1.5 rounded-lg bg-neutral-300" />);}