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.

Adding the marketplace to the nav (#4347)

Marcus Farrelld876907dd5d9
diff --git a/packages/ui/src/content.ts b/packages/ui/src/content.ts
index 356411b535..9b4da99926 100644
--- a/packages/ui/src/content.ts
+++ b/packages/ui/src/content.ts
@@ -17,6 +17,7 @@ import {
Php,
Python,
Ruby,
+ Shop,
Toggle2,
Twitter,
Typescript,
@@ -140,17 +141,17 @@ export const SOLUTIONS: NavItemChildren = [
export const RESOURCES = [
{
- icon: LifeRing,
+ icon: withFillVariant(Book2),
+ title: "Docs",
+ description: "Developer documentation",
+ href: "/docs",
+ },
+ {
+ icon: withFillVariant(LifeRing),
title: "Help Center",
description: "Answers to your questions",
href: "/help",
},
- {
- icon: Book2,
- title: "Docs",
- description: "Platform documentation",
- href: "/docs",
- },
{
icon: withFillVariant(Users),
title: "About",
@@ -158,35 +159,41 @@ export const RESOURCES = [
href: "/about",
},
{
- icon: Briefcase,
+ icon: withFillVariant(Briefcase),
title: "Careers",
description: "Join our global, remote team",
href: "/careers",
},
{
- icon: Feather,
+ icon: withFillVariant(Feather),
title: "Blog",
description: "Insights and stories",
href: "/blog",
},
{
- icon: BulletList,
+ icon: withFillVariant(BulletList),
title: "Changelog",
description: "Releases and updates",
href: "/changelog",
},
{
icon: Logo,
- title: "Brand Guidelines",
+ title: "Dub Brand",
description: "Logos, wordmark, etc.",
href: "/brand",
},
{
- icon: Envelope,
+ icon: withFillVariant(Envelope),
title: "Contact",
description: "Reach out to support or sales",
href: "/contact",
},
+ {
+ icon: withFillVariant(Shop),
+ title: "Program Marketplace",
+ description: "Browse our available partner programs",
+ href: "/marketplace",
+ },
];
export const COMPARE_PAGES = [
diff --git a/packages/ui/src/icons/nucleo/shop.tsx b/packages/ui/src/icons/nucleo/shop.tsx
index f679128926..45124f5fad 100644
--- a/packages/ui/src/icons/nucleo/shop.tsx
+++ b/packages/ui/src/icons/nucleo/shop.tsx
@@ -1,6 +1,9 @@
import { SVGProps } from "react";
-export function Shop(props: SVGProps<SVGSVGElement>) {
+export function Shop({
+ variant = "outline",
+ ...props
+}: SVGProps<SVGSVGElement> & { variant?: "outline" | "fill" }) {
return (
<svg
height="18"
@@ -10,55 +13,72 @@ export function Shop(props: SVGProps<SVGSVGElement>) {
{...props}
>
<g fill="currentColor">
- <line
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="1.5"
- x1="3.75"
- x2="3.75"
- y1="16.25"
- y2="9.5"
- />
- <line
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="1.5"
- x1="14.25"
- x2="14.25"
- y1="9.5"
- y2="16.25"
- />
- <line
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="1.5"
- x1="1.75"
- x2="16.25"
- y1="16.25"
- y2="16.25"
- />
- <path
- d="M13.668,1.75H4.331c-.359,0-.691,.193-.869,.505l-1.706,2.995c.475,1.031,1.51,1.75,2.72,1.75,.908,0,1.712-.412,2.262-1.049,.55,.637,1.354,1.049,2.262,1.049s1.711-.411,2.261-1.048c.55,.637,1.354,1.048,2.261,1.048,1.209,0,2.245-.719,2.72-1.75l-1.704-2.995c-.178-.312-.51-.505-.869-.505Z"
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="1.5"
- />
- <path
- d="M7.25,16v-3c0-.966,.784-1.75,1.75-1.75h0c.966,0,1.75,.784,1.75,1.75v3"
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="1.5"
- />
+ {variant === "fill" ? (
+ <>
+ <path
+ d="M16.25 15.5H15V9.95837C15 9.54437 14.664 9.20837 14.25 9.20837C13.836 9.20837 13.5 9.54437 13.5 9.95837V15.5H11V13C11 11.896 10.105 11 9 11C7.895 11 7 11.896 7 13V15.5H4.5V9.95837C4.5 9.54437 4.164 9.20837 3.75 9.20837C3.336 9.20837 3 9.54437 3 9.95837V15.5H1.75C1.336 15.5 1 15.836 1 16.25C1 16.664 1.336 17 1.75 17H16.25C16.664 17 17 16.664 17 16.25C17 15.836 16.664 15.5 16.25 15.5Z"
+ fill="currentColor"
+ />
+ <path
+ d="M3.098 1.37878C3.23139 1.1446 3.48018 1 3.74968 1H14.2507C14.5203 1 14.7692 1.14475 14.9026 1.37912L16.8939 4.87912C17.0135 5.08929 17.0244 5.34422 16.9232 5.56383C16.3317 6.84764 15.0378 7.75 13.522 7.75C12.6655 7.75 11.8852 7.45793 11.2611 6.97852C10.6372 7.45789 9.8573 7.75 8.99998 7.75C8.14246 7.75 7.36202 7.4572 6.73799 6.97761C6.11397 7.4572 5.33352 7.75 4.476 7.75C2.95904 7.75 1.66621 6.84751 1.0748 5.56383C0.973561 5.34409 0.984544 5.08901 1.10429 4.87878L3.098 1.37878Z"
+ clipRule="evenodd"
+ fill="currentColor"
+ fillRule="evenodd"
+ />
+ </>
+ ) : (
+ <>
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="3.75"
+ x2="3.75"
+ y1="16.25"
+ y2="9.5"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="14.25"
+ x2="14.25"
+ y1="9.5"
+ y2="16.25"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="1.75"
+ x2="16.25"
+ y1="16.25"
+ y2="16.25"
+ />
+ <path
+ d="M13.668,1.75H4.331c-.359,0-.691,.193-.869,.505l-1.706,2.995c.475,1.031,1.51,1.75,2.72,1.75,.908,0,1.712-.412,2.262-1.049,.55,.637,1.354,1.049,2.262,1.049s1.711-.411,2.261-1.048c.55,.637,1.354,1.048,2.261,1.048,1.209,0,2.245-.719,2.72-1.75l-1.704-2.995c-.178-.312-.51-.505-.869-.505Z"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M7.25,16v-3c0-.966,.784-1.75,1.75-1.75h0c.966,0,1.75,.784,1.75,1.75v3"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </>
+ )}
</g>
</svg>
);
diff --git a/packages/ui/src/nav/content/program-marketplace.tsx b/packages/ui/src/nav/content/program-marketplace.tsx
new file mode 100644
index 0000000000..eba1b1bf26
--- /dev/null
+++ b/packages/ui/src/nav/content/program-marketplace.tsx
@@ -0,0 +1,142 @@
+import { cn, createHref } from "@dub/utils";
+import { Link as NavigationMenuLink } from "@radix-ui/react-navigation-menu";
+import { motion, useReducedMotion } from "motion/react";
+import Link from "next/link";
+import { Grid } from "../../grid";
+import { NAV_UTM_PARAMS } from "./shared";
+
+// left, top, size and rotation (in px/deg) within the 614 × 104 logo canvas
+const LOGO_SLOTS = [
+ { left: 405, top: 22, size: 24, rotate: 0, logo: "beehiiv" },
+ { left: 461, top: 1, size: 38, rotate: 0, logo: "wisprflow" },
+ { left: 307.28, top: 24.83, size: 33, rotate: -6.57, logo: "granola" },
+ { left: 342, top: 55, size: 30, rotate: 0, logo: "superhuman" },
+ { left: 410.5, top: 64.5, size: 31, rotate: 0, logo: "polymarket" },
+ { left: 573.5, top: 39.5, size: 39, rotate: 0, logo: "viktor" },
+ { left: 448, top: 31, size: 34, rotate: 0, logo: "framer" },
+ { left: 526.5, top: 26.5, size: 33, rotate: 0, logo: "flora" },
+ { left: 93.5, top: 19.5, size: 41, rotate: 0, logo: "dub" },
+ { left: 162.5, top: 11.5, size: 29, rotate: 0, logo: "superpower" },
+ { left: 2.05, top: 28.03, size: 38, rotate: -6.57, logo: "chatbase" },
+ { left: 36.5, top: 58.5, size: 35, rotate: 0, logo: "copper" },
+ { left: 106, top: 69, size: 34, rotate: 0, logo: "anything" },
+ { left: 268.5, top: 43.5, size: 43, rotate: 0, logo: "tradezella" },
+ { left: 146, top: 38, size: 32, rotate: 0, logo: "buffer" },
+ { left: 225.5, top: 34.5, size: 29, rotate: 0, logo: "coderabbit" },
+];
+
+const LOGO_SIZES = LOGO_SLOTS.map(({ size }) => size);
+const MIN_LOGO_SIZE = Math.min(...LOGO_SIZES);
+const MAX_LOGO_SIZE = Math.max(...LOGO_SIZES);
+
+function getDepth(size: number) {
+ return (size - MIN_LOGO_SIZE) / (MAX_LOGO_SIZE - MIN_LOGO_SIZE);
+}
+
+// deterministic (so it matches between server and client) per-slot drift, to
+// make the logos bob around like they're floating in water – the closer a logo
+// is, the more it moves, which sells the parallax
+function getDrift(index: number, depth: number) {
+ const amplitude = 0.6 + depth * 0.8;
+ const x = Math.sin(index * 12.9898) * 6 * amplitude;
+ const y = Math.cos(index * 78.233) * 4.5 * amplitude;
+
+ return {
+ x: [0, x, -x * 0.6, 0],
+ y: [0, y, -y, 0],
+ duration: 9 + (index % 5),
+ delay: -(1.5 + index * 0.7),
+ };
+}
+
+function ProgramMarketplaceLogos() {
+ const reducedMotion = useReducedMotion();
+
+ return (
+ <div
+ aria-hidden
+ className="pointer-events-none absolute right-6 top-1/2 h-[104px] w-[614px] -translate-y-1/2"
+ >
+ {LOGO_SLOTS.map(({ left, top, size, rotate, logo }, index) => {
+ const depth = getDepth(size);
+ const { x, y, duration, delay } = getDrift(index, depth);
+
+ return (
+ <motion.div
+ key={index}
+ className="absolute"
+ style={{ left, top, width: size, height: size }}
+ animate={reducedMotion ? undefined : { x, y }}
+ transition={{
+ duration,
+ delay,
+ repeat: Infinity,
+ ease: "easeInOut",
+ }}
+ >
+ <div
+ className="relative size-full overflow-hidden rounded-full border border-neutral-50 bg-neutral-200 dark:border-white/10 dark:bg-white/10"
+ style={{
+ // closer logos get a slightly stronger (but still faint) shadow
+ boxShadow: `0 ${1 + depth}px ${4 + depth * 4}px rgba(0,0,0,${(0.02 + depth * 0.05).toFixed(3)})`,
+ ...(rotate ? { transform: `rotate(${rotate}deg)` } : {}),
+ }}
+ >
+ <img
+ src={`https://assets.dub.co/companies/icons/${logo}.svg`}
+ alt={`${logo} logo`}
+ decoding="async"
+ className="size-full object-cover"
+ />
+ <div className="pointer-events-none absolute inset-0 rounded-full border-[0.5px] border-white/30" />
+ </div>
+ </motion.div>
+ );
+ })}
+ </div>
+ );
+}
+
+export function ProgramMarketplaceSection({ domain }: { domain: string }) {
+ return (
+ <NavigationMenuLink asChild>
+ <Link
+ href={createHref("/marketplace", domain, {
+ ...NAV_UTM_PARAMS,
+ utm_campaign: domain,
+ utm_content: "Program Marketplace",
+ })}
+ className={cn(
+ "group relative isolate flex items-center overflow-hidden bg-neutral-50 px-6 py-3 transition-colors duration-75",
+ "hover:bg-neutral-100 dark:border-white/[0.15] dark:bg-white/[0.03] dark:hover:bg-white/[0.06]",
+ )}
+ >
+ {/* offset so a horizontal cell edge sits just below the middle of the bar */}
+ <Grid
+ cellSize={60}
+ patternOffset={[-12, -32]}
+ className="text-neutral-200/60 [mask-image:linear-gradient(90deg,transparent_20%,black)] dark:text-white/10"
+ />
+
+ <ProgramMarketplaceLogos />
+
+ <div className="relative flex flex-col justify-center">
+ <div className="flex items-center gap-1.5">
+ <span className="text-sm font-semibold text-neutral-900 dark:text-white">
+ Program Marketplace
+ </span>
+ <span className="flex h-4 items-center rounded-md bg-blue-100 px-1 text-xs font-semibold text-blue-600 dark:bg-blue-500/20 dark:text-blue-300">
+ NEW
+ </span>
+ </div>
+ <p className="text-xs font-medium text-neutral-500 dark:text-white/60">
+ Browse our available affiliate programs{" "}
+ <span className="inline-block transition-transform duration-150 group-hover:translate-x-0.5">
+ →
+ </span>
+ </p>
+ </div>
+ </Link>
+ </NavigationMenuLink>
+ );
+}
diff --git a/packages/ui/src/nav/content/resources-content.tsx b/packages/ui/src/nav/content/resources-content.tsx
index 1dc6b7011e..139260976f 100644
--- a/packages/ui/src/nav/content/resources-content.tsx
+++ b/packages/ui/src/nav/content/resources-content.tsx
@@ -1,142 +1,73 @@
import { cn, createHref } from "@dub/utils";
-import { Link as NavigationMenuLink } from "@radix-ui/react-navigation-menu";
-import Link from "next/link";
import { RESOURCES } from "../../content";
-import { Grid } from "../../grid";
-import { Book2, LifeRing } from "../../icons";
+import { ProgramMarketplaceSection } from "./program-marketplace";
import {
ContentLinkCard,
NAV_UTM_PARAMS,
contentHeadingClassName,
} from "./shared";
-const mainLinks = [
+const COLUMNS = [
{
- icon: Book2,
- title: "Docs",
- description: "Platform documentation",
- thumbnail: "https://assets.dub.co/misc/docs-thumbnail.jpg",
- href: "/docs",
+ heading: "Help and Support",
+ titles: ["Docs", "Help Center", "Contact"],
},
{
- icon: LifeRing,
- title: "Help Center",
- description: "Answers to your questions",
- thumbnail: "https://assets.dub.co/misc/help-thumbnail.jpg",
- href: "/help",
+ heading: "Company",
+ titles: ["About", "Careers", "Dub Brand"],
+ },
+ {
+ heading: "Updates",
+ titles: ["Blog", "Changelog"],
},
];
export function ResourcesContent({ domain }: { domain: string }) {
return (
- <div className="grid w-[1020px] grid-cols-[0.9fr,0.55fr,0.55fr] divide-x divide-neutral-200 dark:divide-white/20">
- <div className="flex h-full flex-col p-4">
- <p className={cn(contentHeadingClassName, "mb-4 ml-2")}>Explore</p>
- <div className="grid grow grid-cols-2 gap-4">
- {mainLinks.map(({ icon: Icon, title, description, href }) => (
- <NavigationMenuLink key={title} asChild>
- <Link
- key={title}
- href={createHref(href, domain, {
- ...NAV_UTM_PARAMS,
- utm_campaign: domain,
- utm_content: title,
- })}
- className={cn(
- "group relative isolate z-0 flex flex-col justify-between overflow-hidden rounded-xl border border-neutral-100 bg-neutral-50 px-5 py-4 transition-colors duration-75",
- "dark:border-white/20 dark:bg-neutral-900",
- )}
- >
- <div className="absolute inset-0 opacity-0 transition-opacity duration-150 group-hover:opacity-100">
- <div className="absolute -inset-[25%] -skew-y-12 [mask-image:linear-gradient(225deg,black,transparent_50%)]">
- <Grid
- cellSize={46}
- patternOffset={[0, -14]}
- className="translate-y-2 text-[#ad1f3288] transition-transform duration-150 ease-out group-hover:translate-y-0"
+ <div className="w-[1020px] bg-neutral-50 dark:bg-white/[0.03]">
+ <div className="relative">
+ <div className="grid grid-cols-3 divide-x divide-neutral-200 rounded-b-[20px] bg-white dark:divide-white/20 dark:bg-black">
+ {COLUMNS.map(({ heading, titles }) => (
+ <div key={heading} className="px-6 py-4">
+ <p className={cn(contentHeadingClassName, "mb-2")}>{heading}</p>
+ <div className="flex flex-col gap-0.5">
+ {RESOURCES.filter(({ title }) => titles.includes(title)).map(
+ ({ icon: Icon, title, description, href }) => (
+ <ContentLinkCard
+ key={href}
+ className="-mx-2"
+ href={createHref(href, domain, {
+ ...NAV_UTM_PARAMS,
+ utm_campaign: domain,
+ utm_content: title,
+ })}
+ icon={
+ <div className="shrink-0 rounded-md border border-neutral-200 bg-white/50 p-2 dark:border-white/20 dark:bg-white/10">
+ <Icon
+ variant="fill"
+ className="size-4 text-neutral-600 transition-colors dark:text-white/60"
+ />
+ </div>
+ }
+ title={title}
+ description={description}
/>
- </div>
- <div
- className={cn(
- "absolute -inset-[10%] opacity-10 blur-[50px] dark:brightness-150",
- "bg-[conic-gradient(#F35066_0deg,#F35066_117deg,#9071F9_180deg,#5182FC_240deg,#F35066_360deg)]",
- )}
- />
- </div>
- <Icon
- variant="fill"
- className="relative size-5 text-neutral-700 dark:text-white/60"
- />
- <div className="relative">
- <span className="text-sm font-medium text-neutral-900 dark:text-white">
- {title}
- </span>
- <p className="mt-2 text-xs text-neutral-500 dark:text-white/60">
- {description}
- </p>
- </div>
- </Link>
- </NavigationMenuLink>
+ ),
+ )}
+ </div>
+ </div>
))}
</div>
- </div>
- <div className="px-6 py-4">
- <p className={cn(contentHeadingClassName, "mb-2")}>Company</p>
- <div className="flex flex-col gap-0.5">
- {RESOURCES.filter(({ title }) =>
- ["About", "Careers", "Brand Guidelines", "Contact"].includes(title),
- ).map(({ icon: Icon, title, description, href }) => (
- <ContentLinkCard
- key={href}
- className="-mx-2"
- href={createHref(href, domain, {
- ...NAV_UTM_PARAMS,
- utm_campaign: domain,
- utm_content: title,
- })}
- icon={
- <div className="shrink-0 rounded-md border border-neutral-200 bg-white/50 p-2.5 dark:border-white/20 dark:bg-white/10">
- <Icon
- variant="fill"
- className="size-4 text-neutral-600 transition-colors dark:text-white/60"
- />
- </div>
- }
- title={title}
- description={description}
- />
- ))}
+ {/* bottom hairline drawn as a clipped full border, so it keeps full
+ strength around the curled corners (border-b alone tapers there);
+ kept outside the grid so divide-x doesn't add a border to it */}
+ <div className="pointer-events-none absolute -inset-x-px bottom-0 h-5 overflow-hidden">
+ <div className="absolute inset-x-0 bottom-0 h-10 rounded-b-[21px] border border-neutral-200 dark:border-white/20" />
</div>
</div>
- <div className="px-6 py-4">
- <p className={cn(contentHeadingClassName, "mb-2")}>Updates</p>
- <div className="flex flex-col gap-0.5">
- {RESOURCES.filter(({ title }) =>
- ["Blog", "Changelog"].includes(title),
- ).map(({ icon: Icon, title, description, href }) => (
- <ContentLinkCard
- key={href}
- className="-mx-2"
- href={createHref(href, domain, {
- ...NAV_UTM_PARAMS,
- utm_campaign: domain,
- utm_content: title,
- })}
- icon={
- <div className="shrink-0 rounded-md border border-neutral-200 bg-white/50 p-2.5 dark:border-white/20 dark:bg-white/10">
- <Icon
- variant="fill"
- className="size-4 text-neutral-600 transition-colors dark:text-white/60"
- />
- </div>
- }
- title={title}
- description={description}
- />
- ))}
- </div>
- </div>
+ <ProgramMarketplaceSection domain={domain} />
</div>
);
}
diff --git a/packages/ui/src/nav/nav.tsx b/packages/ui/src/nav/nav.tsx
index 4b3298d4af..7426ba7ddb 100644
--- a/packages/ui/src/nav/nav.tsx
+++ b/packages/ui/src/nav/nav.tsx
@@ -83,6 +83,7 @@ export const navItems: NavItem[] = [
"/blog",
"/changelog",
"/contact",
+ "/marketplace",
],
},
{
@@ -229,9 +230,8 @@ export function Nav({
className="group/nav relative flex"
onMouseLeave={() => {
const list = navListRef.current;
- const openTrigger = list?.querySelector<HTMLElement>(
- "[data-state=open]",
- );
+ const openTrigger =
+ list?.querySelector<HTMLElement>("[data-state=open]");
// Keep the pill on the open trigger so it doesn't flicker into the dropdown
if (list && openTrigger) {
setHoverStyle(getHoverStyle(list, openTrigger));
@@ -297,7 +297,10 @@ export function Nav({
className={cn(
"relative flex origin-top justify-start overflow-hidden rounded-[20px] border border-neutral-200 bg-white shadow-md dark:border-white/[0.15] dark:bg-black",
"data-[state=closed]:animate-scale-out-content data-[state=open]:animate-scale-in-content",
- "h-[var(--radix-navigation-menu-viewport-height)] w-[var(--radix-navigation-menu-viewport-width)] transition-[width,height]",
+ // +2px: Radix measures the content's border-box, but this element's
+ // 1px borders eat into it (border-box sizing), clipping fixed-width
+ // content by 2px on the right/bottom
+ "h-[calc(var(--radix-navigation-menu-viewport-height)_+_2px)] w-[calc(var(--radix-navigation-menu-viewport-width)_+_2px)] transition-[width,height]",
)}
/>
</div>