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.

Side nav / main layout updates

Tim Wilson5448f9ef1086
diff --git a/apps/web/lib/middleware/utils/partners-redirect.ts b/apps/web/lib/middleware/utils/partners-redirect.ts
index 89d04f1593..1f6dc013f7 100644
--- a/apps/web/lib/middleware/utils/partners-redirect.ts
+++ b/apps/web/lib/middleware/utils/partners-redirect.ts
@@ -1,5 +1,6 @@
const PARTNERS_REDIRECTS = {
"/settings": "/profile",
+ "/settings/payouts": "/payouts",
};
export const partnersRedirect = (path: string) => {
diff --git a/apps/web/ui/layout/main-nav.tsx b/apps/web/ui/layout/main-nav.tsx
index 9ae9f680e3..ccfd314954 100644
--- a/apps/web/ui/layout/main-nav.tsx
+++ b/apps/web/ui/layout/main-nav.tsx
@@ -53,14 +53,7 @@ export function MainNav({
}, [pathname]);
return (
- <div
- className="min-h-screen md:grid md:grid-cols-[var(--sidebar-width)_minmax(0,1fr)]"
- style={
- {
- "--sidebar-width": "304px",
- } as React.CSSProperties
- }
- >
+ <div className="min-h-screen md:grid md:grid-cols-[min-content_minmax(0,1fr)]">
{/* Side nav backdrop */}
<div
className={cn(
@@ -79,7 +72,7 @@ export function MainNav({
{/* Side nav */}
<div
className={cn(
- "relative h-full w-[var(--sidebar-width,240px)] max-w-full bg-neutral-200 transition-transform md:translate-x-0",
+ "relative h-full w-min max-w-full bg-neutral-200 transition-transform md:translate-x-0",
!isOpen && "-translate-x-full",
)}
>
diff --git a/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx
index 85215be78b..112c8dea23 100644
--- a/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx
@@ -8,6 +8,7 @@ import {
Gauge6,
Gear2,
GridIcon,
+ MoneyBills2,
ShieldCheck,
SquareUserSparkle2,
} from "@dub/ui/icons";
@@ -37,6 +38,14 @@ const NAV_GROUPS: SidebarNavGroups<SidebarNavData> = ({ pathname }) => [
href: "/programs",
active: pathname.startsWith("/programs"),
},
+ {
+ name: "Payouts",
+ description:
+ "View all your upcoming and previous payouts for all your programs.",
+ icon: MoneyBills2,
+ href: "/payouts",
+ active: pathname.startsWith("/payouts"),
+ },
{
name: "Partner profile",
description:
@@ -123,6 +132,7 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
// Partner profile
profile: () => ({
title: "Partner profile",
+ direction: "left",
content: [
{
items: [
@@ -142,6 +152,22 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
],
}),
+ // Payouts
+ payouts: () => ({
+ title: "Payouts",
+ content: [
+ {
+ items: [
+ {
+ name: "Payouts",
+ icon: MoneyBills2,
+ href: "/payouts",
+ },
+ ],
+ },
+ ],
+ }),
+
// User settings
userSettings: () => ({
title: "Settings",
@@ -189,9 +215,11 @@ export function PartnersSidebarNav({
? "userSettings"
: pathname.startsWith("/profile")
? "profile"
- : isEnrolledProgramPage
- ? "program"
- : "programs";
+ : pathname.startsWith("/payouts")
+ ? null
+ : isEnrolledProgramPage
+ ? "program"
+ : "programs";
}, [pathname, programSlug, isEnrolledProgramPage]);
return (
diff --git a/apps/web/ui/layout/sidebar/sidebar-nav.tsx b/apps/web/ui/layout/sidebar/sidebar-nav.tsx
index 5c55058912..b7bc4a2f57 100644
--- a/apps/web/ui/layout/sidebar/sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/sidebar-nav.tsx
@@ -13,6 +13,7 @@ import Link from "next/link";
import { usePathname } from "next/navigation";
import {
ComponentType,
+ CSSProperties,
PropsWithChildren,
ReactNode,
Suspense,
@@ -69,6 +70,10 @@ export type SidebarNavAreas<T extends Record<any, any>> = Record<
}
>;
+const SIDEBAR_WIDTH = 304;
+const SIDEBAR_GROUPS_WIDTH = 64;
+const SIDEBAR_AREAS_WIDTH = SIDEBAR_WIDTH - SIDEBAR_GROUPS_WIDTH;
+
export function SidebarNav<T extends Record<any, any>>({
groups,
areas,
@@ -81,7 +86,7 @@ export function SidebarNav<T extends Record<any, any>>({
}: {
groups: SidebarNavGroups<T>;
areas: SidebarNavAreas<T>;
- currentArea: string;
+ currentArea: string | null;
data: T;
toolContent?: ReactNode;
newsContent?: ReactNode;
@@ -89,116 +94,137 @@ export function SidebarNav<T extends Record<any, any>>({
bottom?: ReactNode;
}) {
return (
- <ClientOnly className="size-full">
- <nav className="grid size-full grid-cols-[64px_1fr]">
- <div className="flex flex-col items-center justify-between">
- <div className="flex flex-col items-center p-2">
- <div className="pb-1 pt-2">
- <Link
- href="/"
- className="block rounded-lg px-1 py-4 outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-black/50"
- >
- <NavWordmark className="h-5" isInApp />
- </Link>
+ <div
+ className={cn(
+ "h-full w-[var(--sidebar-width)] transition-[width] duration-300",
+ )}
+ style={
+ {
+ "--sidebar-width": `${currentArea === null ? SIDEBAR_GROUPS_WIDTH : SIDEBAR_WIDTH}px`,
+ "--sidebar-groups-width": `${SIDEBAR_GROUPS_WIDTH}px`,
+ "--sidebar-areas-width": `${SIDEBAR_AREAS_WIDTH}px`,
+ } as CSSProperties
+ }
+ >
+ <ClientOnly className="size-full">
+ <nav className="grid size-full grid-cols-[var(--sidebar-groups-width)_1fr]">
+ <div className="flex flex-col items-center justify-between">
+ <div className="flex flex-col items-center p-2">
+ <div className="pb-1 pt-2">
+ <Link
+ href="/"
+ className="block rounded-lg px-1 py-4 outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-black/50"
+ >
+ <NavWordmark className="h-5" isInApp />
+ </Link>
+ </div>
+ {(!currentArea ||
+ !areas[currentArea](data).hideSwitcherIcons) && (
+ <div className="flex flex-col gap-3">
+ {switcher}
+ {groups(data).map((group) => (
+ <NavGroupItem key={group.name} group={group} />
+ ))}
+ </div>
+ )}
</div>
- {!areas[currentArea](data).hideSwitcherIcons && (
- <div className="flex flex-col gap-3">
- {switcher}
- {groups(data).map((group) => (
- <NavGroupItem key={group.name} group={group} />
- ))}
+ <div className="flex flex-col items-center gap-3 py-3">
+ <Suspense fallback={null}>{toolContent}</Suspense>
+ <div className="flex size-12 items-center justify-center">
+ <UserDropdown />
</div>
- )}
- </div>
- <div className="flex flex-col items-center gap-3 py-3">
- <Suspense fallback={null}>{toolContent}</Suspense>
- <div className="flex size-12 items-center justify-center">
- <UserDropdown />
</div>
</div>
- </div>
- <div className="size-full overflow-hidden py-2 pr-2">
- <div className="scrollbar-hide relative flex size-full flex-col overflow-y-auto overflow-x-hidden rounded-xl bg-neutral-100">
- <div className="relative flex grow flex-col p-3 text-neutral-500">
- <div className="relative w-full grow">
- {Object.entries(areas).map(([area, areaConfig]) => {
- const { title, backHref, content, showNews, direction } =
- areaConfig(data);
+ <div
+ className={cn(
+ "size-full overflow-hidden py-2 pr-2 transition-opacity duration-300",
+ currentArea === null && "opacity-0",
+ )}
+ >
+ <div className="scrollbar-hide relative flex h-full w-[calc(var(--sidebar-areas-width)-0.5rem)] flex-col overflow-y-auto overflow-x-hidden rounded-xl bg-neutral-100">
+ <div className="relative flex grow flex-col p-3 text-neutral-500">
+ <div className="relative w-full grow">
+ {Object.entries(areas).map(([area, areaConfig]) => {
+ const { title, backHref, content, showNews, direction } =
+ areaConfig(data);
- const TitleContainer = backHref ? Link : "div";
+ const TitleContainer = backHref ? Link : "div";
- return (
- <Area
- key={area}
- visible={area === currentArea}
- direction={direction ?? "right"}
- >
- {title &&
- (typeof title === "string" ? (
- // @ts-ignore - TS can't handle the conditional Link+href
- <TitleContainer
- {...(backHref ? { href: backHref } : {})}
- className="group mb-2 flex items-center gap-3 px-3 py-2"
- >
- {backHref && (
- <div
- className={cn(
- "text-content-muted bg-bg-emphasis flex size-6 items-center justify-center rounded-lg",
- "group-hover:bg-bg-inverted/10 group-hover:text-content-subtle transition-[transform,background-color,color] duration-150 group-hover:-translate-x-0.5",
- )}
- >
- <ChevronLeft className="size-3 [&_*]:stroke-2" />
- </div>
- )}
- <span className="text-content-emphasis text-lg font-semibold">
- {title}
- </span>
- </TitleContainer>
- ) : (
- title
- ))}
- <div className="flex flex-col gap-8">
- {content.map(({ name, items }, idx) => (
- <div key={idx} className="flex flex-col gap-0.5">
- {name && (
- <div className="mb-2 pl-3 text-sm text-neutral-500">
- {name}
- </div>
- )}
- {items.map((item) => (
- <NavItem key={item.name} item={item} />
- ))}
- </div>
- ))}
- </div>
- <AnimatePresence>
- {showNews && (
- <motion.div
- className="-mx-3 flex grow flex-col justify-end"
- initial={{ opacity: 0, y: 10 }}
- animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0, y: 10 }}
- transition={{
- duration: 0.1,
- ease: "easeInOut",
- }}
- >
- {newsContent}
- </motion.div>
- )}
- </AnimatePresence>
- </Area>
- );
- })}
+ return (
+ <Area
+ key={area}
+ visible={area === currentArea}
+ direction={direction ?? "right"}
+ >
+ {title &&
+ (typeof title === "string" ? (
+ // @ts-ignore - TS can't handle the conditional Link+href
+ <TitleContainer
+ {...(backHref ? { href: backHref } : {})}
+ className="group mb-2 flex items-center gap-3 px-3 py-2"
+ >
+ {backHref && (
+ <div
+ className={cn(
+ "text-content-muted bg-bg-emphasis flex size-6 items-center justify-center rounded-lg",
+ "group-hover:bg-bg-inverted/10 group-hover:text-content-subtle transition-[transform,background-color,color] duration-150 group-hover:-translate-x-0.5",
+ )}
+ >
+ <ChevronLeft className="size-3 [&_*]:stroke-2" />
+ </div>
+ )}
+ <span className="text-content-emphasis text-lg font-semibold">
+ {title}
+ </span>
+ </TitleContainer>
+ ) : (
+ title
+ ))}
+ <div className="flex flex-col gap-8">
+ {content.map(({ name, items }, idx) => (
+ <div key={idx} className="flex flex-col gap-0.5">
+ {name && (
+ <div className="mb-2 pl-3 text-sm text-neutral-500">
+ {name}
+ </div>
+ )}
+ {items.map((item) => (
+ <NavItem key={item.name} item={item} />
+ ))}
+ </div>
+ ))}
+ </div>
+ <AnimatePresence>
+ {showNews && (
+ <motion.div
+ className="-mx-3 flex grow flex-col justify-end"
+ initial={{ opacity: 0, y: 10 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0, y: 10 }}
+ transition={{
+ duration: 0.1,
+ ease: "easeInOut",
+ }}
+ >
+ {newsContent}
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </Area>
+ );
+ })}
+ </div>
</div>
+ {bottom && (
+ <div className="relative flex flex-col justify-end">
+ {bottom}
+ </div>
+ )}
</div>
- {bottom && (
- <div className="relative flex flex-col justify-end">{bottom}</div>
- )}
</div>
- </div>
- </nav>
- </ClientOnly>
+ </nav>
+ </ClientOnly>
+ </div>
);
}