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.

Start adding new nav

Tim Wilsonbcc62d47b080
diff --git a/packages/ui/src/content.ts b/packages/ui/src/content.ts
index 5e3a740bdf..7041016a8c 100644
--- a/packages/ui/src/content.ts
+++ b/packages/ui/src/content.ts
@@ -1,28 +1,35 @@
-import { Airplay, BarChart, Link2, QrCode, Users, Webhook } from "lucide-react";
+import {
+ ChartLine,
+ Hyperlink,
+ Paintbrush,
+ QRCode,
+ Users,
+ WindowSettings,
+} from "./icons";
export const FEATURES_LIST = [
{
title: "Powerful Analytics For The Modern Marketer",
shortTitle: "Advanced Analytics",
- icon: BarChart,
+ icon: ChartLine,
slug: "features/analytics",
},
{
title: "Branded Links That Stand Out",
shortTitle: "Branded Links",
- icon: Airplay,
+ icon: Hyperlink,
slug: "features/branded-links",
},
{
title: "Gorgeous QR codes for your links",
shortTitle: "QR Codes",
- icon: QrCode,
+ icon: QRCode,
slug: "features/qr-codes",
},
{
title: "Personalize Your Short Links",
shortTitle: "Personalization",
- icon: Link2,
+ icon: Paintbrush,
slug: "features/personalization",
},
{
@@ -34,7 +41,7 @@ export const FEATURES_LIST = [
{
title: "Programmatic Link Creation",
shortTitle: "API",
- icon: Webhook,
+ icon: WindowSettings,
slug: "docs/api-reference/introduction",
},
];
diff --git a/packages/ui/src/icons/nucleo/chart-line.tsx b/packages/ui/src/icons/nucleo/chart-line.tsx
new file mode 100644
index 0000000000..35707951b7
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/chart-line.tsx
@@ -0,0 +1,18 @@
+import { SVGProps } from "react";
+
+export function ChartLine(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" {...props}>
+ <g
+ fill="none"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="1.5"
+ stroke="currentColor"
+ >
+ <path d="M2.75 10.75L6.396 7.10401C6.591 6.90901 6.908 6.90901 7.103 7.10401L10.396 10.397C10.591 10.592 10.908 10.592 11.103 10.397L15.249 6.25101"></path>{" "}
+ <path d="M2.75 2.75V12.75C2.75 13.855 3.645 14.75 4.75 14.75H15.25"></path>
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index f2b71e0a84..7890fcd58b 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -1,3 +1,4 @@
+export * from "./chart-line";
export * from "./crosshairs";
export * from "./cube";
export * from "./cursor-rays";
@@ -12,11 +13,14 @@ export * from "./hyperlink";
export * from "./invoice-dollar";
export * from "./mobile-phone";
export * from "./office-building";
+export * from "./paintbrush";
export * from "./qrcode";
export * from "./referred-via";
export * from "./sliders";
export * from "./tablet";
export * from "./tag";
export * from "./tv";
+export * from "./users";
export * from "./watch";
export * from "./window";
+export * from "./window-settings";
diff --git a/packages/ui/src/icons/nucleo/paintbrush.tsx b/packages/ui/src/icons/nucleo/paintbrush.tsx
new file mode 100644
index 0000000000..b8accd6fda
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/paintbrush.tsx
@@ -0,0 +1,26 @@
+import { SVGProps } from "react";
+
+export function Paintbrush(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" {...props}>
+ <g fill="currentColor">
+ <path
+ d="M6.956,9.044L13.534,2.466c.621-.621,1.629-.621,2.25,0h0c.621,.621,.621,1.629,0,2.25l-6.578,6.578"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M1.75,14.706c2.703,.812,4.896,.88,6.689-.955,1.081-1.085,1.081-2.845,0-3.931s-2.826-1.102-3.916,0c-1.773,1.792-.225,3.494-2.773,4.886Z"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/users.tsx b/packages/ui/src/icons/nucleo/users.tsx
new file mode 100644
index 0000000000..217dcea6a6
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/users.tsx
@@ -0,0 +1,51 @@
+import { SVGProps } from "react";
+
+export function Users(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <g fill="currentColor">
+ <circle
+ cx="5.75"
+ cy="6.25"
+ fill="none"
+ r="2"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <circle
+ cx="12"
+ cy="3.75"
+ fill="none"
+ r="2"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M9.609,15.122c.523-.175,.83-.744,.636-1.259-.685-1.818-2.436-3.112-4.494-3.112s-3.809,1.294-4.494,3.112c-.194,.516,.113,1.085,.636,1.259,.962,.321,2.281,.628,3.859,.628s2.897-.307,3.858-.628Z"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M12.749,13.227c1.248-.077,2.304-.336,3.109-.605,.523-.175,.83-.744,.636-1.259-.685-1.818-2.436-3.112-4.494-3.112-.977,0-1.885,.292-2.643,.793"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/window-settings.tsx b/packages/ui/src/icons/nucleo/window-settings.tsx
new file mode 100644
index 0000000000..e058b6379e
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/window-settings.tsx
@@ -0,0 +1,108 @@
+import { SVGProps } from "react";
+
+export function WindowSettings(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" {...props}>
+ <g fill="currentColor">
+ <path
+ d="M4.25 6C4.66421 6 5 5.66421 5 5.25C5 4.83579 4.66421 4.5 4.25 4.5C3.83579 4.5 3.5 4.83579 3.5 5.25C3.5 5.66421 3.83579 6 4.25 6Z"
+ fill="currentColor"
+ stroke="none"
+ />
+ <path
+ d="M6.75 6C7.16421 6 7.5 5.66421 7.5 5.25C7.5 4.83579 7.16421 4.5 6.75 4.5C6.33579 4.5 6 4.83579 6 5.25C6 5.66421 6.33579 6 6.75 6Z"
+ fill="currentColor"
+ stroke="none"
+ />
+ <path
+ d="M1.75 7.75H16.25"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M16.25 8.984V4.75C16.25 3.646 15.355 2.75 14.25 2.75H3.75C2.645 2.75 1.75 3.646 1.75 4.75V13.25C1.75 14.354 2.645 15.25 3.75 15.25H8.512"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M13.75 10.5V11.75"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M16.048 11.452L15.164 12.336"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M17 13.75H15.75"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M16.048 16.0479L15.164 15.1639"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M13.75 17V15.75"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M11.452 16.0479L12.336 15.1639"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M10.5 13.75H11.75"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M11.452 11.452L12.336 12.336"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M13.75 15.5C14.7165 15.5 15.5 14.7165 15.5 13.75C15.5 12.7835 14.7165 12 13.75 12C12.7835 12 12 12.7835 12 13.75C12 14.7165 12.7835 15.5 13.75 15.5Z"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/index.tsx b/packages/ui/src/index.tsx
index 01618b6eec..936b4630dc 100644
--- a/packages/ui/src/index.tsx
+++ b/packages/ui/src/index.tsx
@@ -30,7 +30,6 @@ export * from "./background";
export * from "./footer";
export * from "./max-width-wrapper";
export * from "./nav";
-export * from "./nav-mobile";
// content
export * from "./content";
diff --git a/packages/ui/src/nav.tsx b/packages/ui/src/nav.tsx
deleted file mode 100644
index 959a3265a9..0000000000
--- a/packages/ui/src/nav.tsx
+++ /dev/null
@@ -1,232 +0,0 @@
-"use client";
-
-import { APP_DOMAIN, HIDE_BACKGROUND_SEGMENTS, cn, fetcher } from "@dub/utils";
-import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
-import va from "@vercel/analytics";
-import { ChevronDown } from "lucide-react";
-import Link from "next/link";
-import { useParams, useSelectedLayoutSegment } from "next/navigation";
-import { createContext } from "react";
-import useSWR from "swr";
-import { FEATURES_LIST } from "./content";
-import { useScroll } from "./hooks";
-import { MaxWidthWrapper } from "./max-width-wrapper";
-import { NavLogo } from "./nav-logo";
-
-export type NavTheme = "light" | "dark";
-
-export const NavContext = createContext<{ theme: NavTheme }>({
- theme: "light",
-});
-
-export const navItems = [
- {
- name: "Customers",
- slug: "customers",
- },
- {
- name: "Pricing",
- slug: "pricing",
- },
- // {
- // name: "Enterprise",
- // slug: "enterprise",
- // },
- {
- name: "Blog",
- slug: "blog",
- },
- {
- name: "Changelog",
- slug: "changelog",
- },
- {
- name: "Help Center",
- slug: "help",
- },
-];
-
-export function Nav({ theme = "light" }: { theme?: NavTheme }) {
- const { domain = "dub.co" } = useParams() as { domain: string };
- const createHref = (href: string) =>
- domain === "dub.co" ? href : `https://dub.co${href}`;
-
- const scrolled = useScroll(80);
- const selectedLayout = useSelectedLayoutSegment();
- const { data: session, isLoading } = useSWR(
- domain === "dub.co" && "/api/auth/session",
- fetcher,
- {
- dedupingInterval: 60000,
- },
- );
-
- return (
- <NavContext.Provider value={{ theme }}>
- <div
- className={cn(
- `sticky inset-x-0 top-0 z-30 w-full transition-all`,
- theme === "dark" && "dark",
- )}
- >
- <div
- className={cn(
- "-z-1 absolute inset-0 border-transparent transition-all",
- {
- "border-b border-black/10 bg-white/75 backdrop-blur-lg dark:border-white/10 dark:bg-black/75":
- scrolled,
- "border-b border-black/10 bg-white dark:border-white/10 dark:bg-black":
- selectedLayout &&
- HIDE_BACKGROUND_SEGMENTS.includes(selectedLayout),
- },
- )}
- />
- <MaxWidthWrapper className="relative">
- <div className="flex h-14 items-center justify-between">
- <div className="flex items-center space-x-12">
- <Link
- href={createHref("/")}
- {...(domain !== "dub.co" && {
- onClick: () => {
- va.track("Referred from custom domain", {
- domain,
- medium: "logo",
- });
- },
- })}
- >
- <NavLogo />
- </Link>
- <NavigationMenuPrimitive.Root
- delayDuration={0}
- className="relative hidden lg:block"
- >
- <NavigationMenuPrimitive.List className="flex flex-row space-x-2 p-4">
- <NavigationMenuPrimitive.Item>
- <NavigationMenuPrimitive.Trigger className="group flex items-center space-x-2 rounded-md px-3 py-2 text-sm font-medium hover:bg-gray-100 focus:outline-none dark:hover:bg-white/10">
- <p
- className={cn(
- "text-sm font-medium text-gray-500 transition-colors ease-out group-hover:text-black dark:text-white/70 dark:group-hover:text-white",
- {
- "text-black dark:text-white":
- selectedLayout === "features",
- },
- )}
- >
- Features
- </p>
- <ChevronDown className="h-4 w-4 text-black transition-all group-data-[state=open]:rotate-180 dark:text-white" />
- </NavigationMenuPrimitive.Trigger>
-
- <NavigationMenuPrimitive.Content>
- <div className="grid w-[32rem] grid-cols-2 gap-1 p-3">
- {FEATURES_LIST.map(
- ({ slug, icon: Icon, title, shortTitle }) => (
- <Link
- key={slug}
- href={createHref(`/${slug}`)}
- {...(domain !== "dub.co" && {
- onClick: () => {
- va.track("Referred from custom domain", {
- domain,
- medium: `navbar item (/${slug})`,
- });
- },
- })}
- className="rounded-lg p-3 transition-colors hover:bg-gray-100 active:bg-gray-200 dark:hover:bg-white/[0.15] dark:active:bg-white/20"
- >
- <div className="flex items-center space-x-2">
- <Icon className="h-4 w-4 text-gray-700 dark:text-white/80" />
- <p className="text-sm font-medium text-gray-700 dark:text-white">
- {shortTitle}
- </p>
- </div>
- <p className="mt-1 line-clamp-1 text-sm text-gray-500 dark:text-white/60">
- {title}
- </p>
- </Link>
- ),
- )}
- </div>
- </NavigationMenuPrimitive.Content>
- </NavigationMenuPrimitive.Item>
-
- {navItems.map(({ name, slug }) => (
- <NavigationMenuPrimitive.Item key={slug} asChild>
- <Link
- id={`nav-${slug}`}
- key={slug}
- href={createHref(`/${slug}`)}
- {...(domain !== "dub.co" && {
- onClick: () => {
- va.track("Referred from custom domain", {
- domain,
- medium: `navbar item (${slug})`,
- });
- },
- })}
- className={cn(
- "rounded-md px-3 py-2 text-sm font-medium text-gray-500 transition-colors ease-out hover:text-black dark:text-white/70 dark:hover:text-white",
- {
- "text-black dark:text-white":
- selectedLayout === slug,
- },
- )}
- >
- {name}
- </Link>
- </NavigationMenuPrimitive.Item>
- ))}
- </NavigationMenuPrimitive.List>
-
- <NavigationMenuPrimitive.Viewport className="data-[state=closed]:animate-scale-out-content data-[state=open]:animate-scale-in-content absolute left-0 top-full flex w-[var(--radix-navigation-menu-viewport-width)] origin-[top_center] justify-start rounded-lg border border-gray-200 bg-white shadow-lg dark:border-white/[0.15] dark:bg-black" />
- </NavigationMenuPrimitive.Root>
- </div>
-
- <div className="hidden lg:block">
- {session && Object.keys(session).length > 0 ? (
- <Link
- href={APP_DOMAIN}
- className="animate-fade-in rounded-full border border-black bg-black px-4 py-1.5 text-sm text-white transition-all hover:bg-gray-800 hover:ring-4 hover:ring-gray-200 dark:border-white dark:bg-white dark:text-gray-600 dark:hover:bg-white dark:hover:text-gray-800 dark:hover:hover:shadow-[0_0_25px_5px_rgba(256,256,256,0.2)] dark:hover:ring-0"
- >
- Dashboard
- </Link>
- ) : !isLoading ? (
- <>
- <Link
- href={`${APP_DOMAIN}/login`}
- {...(domain !== "dub.co" && {
- onClick: () => {
- va.track("Referred from custom domain", {
- domain,
- medium: `navbar item (login)`,
- });
- },
- })}
- className="animate-fade-in rounded-full px-4 py-1.5 text-sm font-medium text-gray-500 transition-colors ease-out hover:text-black dark:text-white dark:hover:text-white/70"
- >
- Log in
- </Link>
- <Link
- href={`${APP_DOMAIN}/register`}
- {...(domain !== "dub.co" && {
- onClick: () => {
- va.track("Referred from custom domain", {
- domain,
- medium: `navbar item (signup)`,
- });
- },
- })}
- className="animate-fade-in rounded-full border border-black bg-black px-4 py-1.5 text-sm text-white transition-all hover:bg-gray-800 hover:ring-4 hover:ring-gray-200 dark:border-white dark:bg-white dark:text-gray-600 dark:hover:bg-white dark:hover:text-gray-800 dark:hover:hover:shadow-[0_0_25px_5px_rgba(256,256,256,0.2)] dark:hover:ring-0"
- >
- Sign Up
- </Link>
- </>
- ) : null}
- </div>
- </div>
- </MaxWidthWrapper>
- </div>
- </NavContext.Provider>
- );
-}
diff --git a/packages/ui/src/nav/index.ts b/packages/ui/src/nav/index.ts
new file mode 100644
index 0000000000..355a41a5a5
--- /dev/null
+++ b/packages/ui/src/nav/index.ts
@@ -0,0 +1,2 @@
+export * from "./nav";
+export * from "./nav-mobile";
diff --git a/packages/ui/src/nav-mobile.tsx b/packages/ui/src/nav/nav-mobile.tsx
similarity index 89%
rename from packages/ui/src/nav-mobile.tsx
rename to packages/ui/src/nav/nav-mobile.tsx
index f58b70be88..8cd2f87bd1 100644
--- a/packages/ui/src/nav-mobile.tsx
+++ b/packages/ui/src/nav/nav-mobile.tsx
@@ -6,8 +6,19 @@ import Link from "next/link";
import { useParams } from "next/navigation";
import { useEffect, useState } from "react";
import useSWR from "swr";
-import { FEATURES_LIST } from "./content";
-import { navItems, type NavTheme } from "./nav";
+import { FEATURES_LIST } from "../content";
+import { type NavTheme } from "./nav";
+
+export const navItems = [
+ {
+ name: "Product",
+ href: "/",
+ },
+ {
+ name: "Pricing",
+ href: "/pricing",
+ },
+];
export function NavMobile({ theme = "light" }: { theme?: NavTheme }) {
const { domain = "dub.co" } = useParams() as { domain: string };
@@ -35,7 +46,7 @@ export function NavMobile({ theme = "light" }: { theme?: NavTheme }) {
<button
onClick={() => setOpen(!open)}
className={cn(
- "fixed right-3 top-3 z-40 rounded-full p-2 transition-colors duration-200 hover:bg-gray-200 focus:outline-none active:bg-gray-300 dark:hover:bg-white/20 dark:active:bg-white/30 lg:hidden",
+ "fixed right-3 top-3 z-40 rounded-full p-2 transition-colors duration-200 hover:bg-gray-200 focus:outline-none active:bg-gray-300 lg:hidden dark:hover:bg-white/20 dark:active:bg-white/30",
open && "hover:bg-gray-100 active:bg-gray-200",
)}
>
@@ -47,7 +58,7 @@ export function NavMobile({ theme = "light" }: { theme?: NavTheme }) {
</button>
<nav
className={cn(
- "fixed inset-0 z-20 hidden w-full bg-white px-5 py-16 dark:bg-black dark:text-white/70 lg:hidden",
+ "fixed inset-0 z-20 hidden w-full bg-white px-5 py-16 lg:hidden dark:bg-black dark:text-white/70",
open && "block",
)}
>
@@ -85,12 +96,10 @@ export function NavMobile({ theme = "light" }: { theme?: NavTheme }) {
</div>
)}
</li>
- {navItems.map(({ name, slug }) => (
- <li key={slug} className="py-3">
+ {navItems.map(({ name, href }) => (
+ <li key={href} className="py-3">
<Link
- href={
- domain === "dub.co" ? `/${slug}` : `https://dub.co/${slug}`
- }
+ href={domain === "dub.co" ? href : `https://dub.co${href}`}
onClick={() => setOpen(false)}
className="flex w-full font-semibold capitalize"
>
diff --git a/packages/ui/src/nav/nav.tsx b/packages/ui/src/nav/nav.tsx
new file mode 100644
index 0000000000..ba749b5cdc
--- /dev/null
+++ b/packages/ui/src/nav/nav.tsx
@@ -0,0 +1,262 @@
+"use client";
+
+import { APP_DOMAIN, HIDE_BACKGROUND_SEGMENTS, cn, fetcher } from "@dub/utils";
+import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
+import va from "@vercel/analytics";
+import { cva } from "class-variance-authority";
+import Link from "next/link";
+import { useParams, useSelectedLayoutSegment } from "next/navigation";
+import { PropsWithChildren, createContext } from "react";
+import useSWR from "swr";
+import { FEATURES_LIST } from "../content";
+import { useScroll } from "../hooks";
+import { MaxWidthWrapper } from "../max-width-wrapper";
+import { NavLogo } from "../nav-logo";
+
+export type NavTheme = "light" | "dark";
+
+export const NavContext = createContext<{ theme: NavTheme }>({
+ theme: "light",
+});
+
+export const navItems = [
+ {
+ name: "Product",
+ href: "/",
+ content: ProductContent,
+ },
+ {
+ name: "Solutions",
+ },
+ {
+ name: "Pricing",
+ href: "/pricing",
+ },
+ {
+ name: "Resources",
+ },
+];
+
+const navItemStyles = cva(
+ [
+ "block rounded-md px-3 py-1.5 text-sm text-gray-900/60 hover:text-gray-900/80",
+ "dark:text-white/70 dark:hover:text-white",
+ "transition-colors ease-out",
+ ],
+ {
+ variants: {
+ isActive: {
+ true: "text-gray-900/80 dark:text-white",
+ },
+ },
+ },
+);
+
+const createHref = (href: string, domain: string) =>
+ domain === "dub.co" ? href : `https://dub.co${href}`;
+
+export function Nav({ theme = "light" }: { theme?: NavTheme }) {
+ const { domain = "dub.co" } = useParams() as { domain: string };
+
+ const scrolled = useScroll(80);
+ const selectedLayout = useSelectedLayoutSegment();
+ const { data: session, isLoading } = useSWR(
+ domain === "dub.co" && "/api/auth/session",
+ fetcher,
+ {
+ dedupingInterval: 60000,
+ },
+ );
+
+ return (
+ <NavContext.Provider value={{ theme }}>
+ <div
+ className={cn(
+ `sticky inset-x-0 top-0 z-30 w-full transition-all`,
+ theme === "dark" && "dark",
+ )}
+ >
+ <div
+ className={cn(
+ "-z-1 absolute inset-0 border-transparent transition-all",
+ {
+ // "bg-white/75 backdrop-blur-lg dark:bg-black/75": scrolled,
+ // "bg-white dark:bg-black":
+ // selectedLayout &&
+ // HIDE_BACKGROUND_SEGMENTS.includes(selectedLayout),
+ },
+ )}
+ />
+ <MaxWidthWrapper className="relative">
+ <div className="flex h-14 items-center justify-between">
+ <Link
+ className="grow basis-0"
+ href={createHref("/", domain)}
+ {...(domain !== "dub.co" && {
+ onClick: () => {
+ va.track("Referred from custom domain", {
+ domain,
+ medium: "logo",
+ });
+ },
+ })}
+ >
+ <NavLogo />
+ </Link>
+ <NavigationMenuPrimitive.Root
+ delayDuration={0}
+ className="relative hidden lg:block"
+ >
+ <NavigationMenuPrimitive.List className="relative flex flex-row gap-2 px-2 py-0.5">
+ <div className="absolute inset-0 -z-[1]">
+ <div
+ className={cn(
+ "absolute left-1/2 top-1/2 h-full w-full -translate-x-1/2 -translate-y-1/2 rounded-full border border-gray-200 bg-white drop-shadow-sm transition-all dark:border-white/10 dark:bg-black",
+ scrolled && [
+ "h-14 w-screen rounded-none drop-shadow-none",
+ (!selectedLayout ||
+ !HIDE_BACKGROUND_SEGMENTS.includes(selectedLayout)) &&
+ "bg-white/75 backdrop-blur-lg dark:bg-black/75",
+ ],
+ )}
+ />
+ </div>
+ {navItems.map(({ name, href, content: Content }) => {
+ const isActive = href === `/${selectedLayout}`;
+ console.log(href);
+ return (
+ <NavigationMenuPrimitive.Item key={href}>
+ <WithTrigger trigger={!!Content}>
+ {href !== undefined ? (
+ <Link
+ id={`nav-${href}`}
+ key={href}
+ href={createHref(href, domain) ?? "/test"}
+ className={navItemStyles({ isActive })}
+ {...(domain !== "dub.co" && {
+ onClick: () => {
+ va.track("Referred from custom domain", {
+ domain,
+ medium: `navbar item (${href})`,
+ });
+ },
+ })}
+ >
+ {name}
+ </Link>
+ ) : (
+ <span className={navItemStyles({ isActive })}>
+ {name}
+ </span>
+ )}
+ </WithTrigger>
+
+ {Content && (
+ <NavigationMenuPrimitive.Content>
+ <Content domain={domain} />
+ </NavigationMenuPrimitive.Content>
+ )}
+ </NavigationMenuPrimitive.Item>
+ );
+ })}
+ </NavigationMenuPrimitive.List>
+
+ <NavigationMenuPrimitive.Viewport className="data-[state=closed]:animate-scale-out-content data-[state=open]:animate-scale-in-content absolute left-0 top-full mt-3 flex w-[var(--radix-navigation-menu-viewport-width)] origin-[top_center] justify-start rounded-[20px] border border-gray-200 bg-white/80 shadow-md backdrop-blur-md dark:border-white/[0.15] dark:bg-black/40" />
+ </NavigationMenuPrimitive.Root>
+
+ <div className="hidden grow basis-0 justify-end lg:flex">
+ {session && Object.keys(session).length > 0 ? (
+ <Link
+ href={APP_DOMAIN}
+ className="animate-fade-in rounded-full border border-black bg-black px-4 py-1.5 text-sm text-white transition-all hover:bg-gray-800 hover:ring-4 hover:ring-gray-200 dark:border-white dark:bg-white dark:text-gray-600 dark:hover:bg-white dark:hover:text-gray-800 dark:hover:hover:shadow-[0_0_25px_5px_rgba(256,256,256,0.2)] dark:hover:ring-0"
+ >
+ Dashboard
+ </Link>
+ ) : !isLoading ? (
+ <>
+ <Link
+ href={`${APP_DOMAIN}/login`}
+ {...(domain !== "dub.co" && {
+ onClick: () => {
+ va.track("Referred from custom domain", {
+ domain,
+ medium: `navbar item (login)`,
+ });
+ },
+ })}
+ className="animate-fade-in rounded-full px-4 py-1.5 text-sm font-medium text-gray-500 transition-colors ease-out hover:text-black dark:text-white dark:hover:text-white/70"
+ >
+ Log in
+ </Link>
+ <Link
+ href={`${APP_DOMAIN}/register`}
+ {...(domain !== "dub.co" && {
+ onClick: () => {
+ va.track("Referred from custom domain", {
+ domain,
+ medium: `navbar item (signup)`,
+ });
+ },
+ })}
+ className="animate-fade-in rounded-full border border-black bg-black px-4 py-1.5 text-sm text-white transition-all hover:bg-gray-800 hover:ring-4 hover:ring-gray-200 dark:border-white dark:bg-white dark:text-gray-600 dark:hover:bg-white dark:hover:text-gray-800 dark:hover:hover:shadow-[0_0_25px_5px_rgba(256,256,256,0.2)] dark:hover:ring-0"
+ >
+ Sign Up
+ </Link>
+ </>
+ ) : null}
+ </div>
+ </div>
+ </MaxWidthWrapper>
+ </div>
+ </NavContext.Provider>
+ );
+}
+
+function WithTrigger({
+ trigger,
+ children,
+}: PropsWithChildren<{ trigger: boolean }>) {
+ return trigger ? (
+ <NavigationMenuPrimitive.Trigger asChild>
+ {children}
+ </NavigationMenuPrimitive.Trigger>
+ ) : (
+ children
+ );
+}
+
+function ProductContent({ domain }: { domain: string }) {
+ return (
+ <div className="grid w-[32rem] grid-cols-2 gap-1 p-3">
+ {FEATURES_LIST.map(({ slug, icon: Icon, title, shortTitle }) => (
+ <Link
+ key={slug}
+ href={createHref(`/${slug}`, domain)}
+ {...(domain !== "dub.co" && {
+ onClick: () => {
+ va.track("Referred from custom domain", {
+ domain,
+ medium: `navbar item (/${slug})`,
+ });
+ },
+ })}
+ className="group rounded-[8px] p-2 transition-colors hover:bg-gray-100 active:bg-gray-200 dark:hover:bg-white/[0.15] dark:active:bg-white/20"
+ >
+ <div className="flex items-center gap-2">
+ <div className="shrink-0 rounded-[10px] border border-gray-200 bg-white/50 p-3">
+ <Icon className="h-4 w-4 text-black transition-transform group-hover:scale-110 dark:text-white/80" />
+ </div>
+ <div>
+ <p className="text-sm font-medium text-gray-700 dark:text-white">
+ {shortTitle}
+ </p>
+ <p className="line-clamp-1 text-xs text-gray-500/80 dark:text-white/60">
+ {title}
+ </p>
+ </div>
+ </div>
+ </Link>
+ ))}
+ </div>
+ );
+}