The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Pull out common layout + make header sticky
Tim Wilsonba91f2e847cf
diff --git a/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/header.tsx b/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/header.tsxnew file mode 100644index 0000000000..21835f9f39--- /dev/null+++ b/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/header.tsx@@ -0,0 +1,43 @@+"use client";++import { Button, useScroll, Wordmark } from "@dub/ui";+import { cn } from "@dub/utils";+import { Program } from "@prisma/client";++export function Header({+ program,+}: {+ program: Pick<Program, "wordmark" | "logo">;+}) {+ const scrolled = useScroll(0);++ return (+ <header+ className={+ "sticky top-0 mx-px flex items-center justify-between bg-white/90 px-6 py-4 backdrop-blur-sm"+ }+ >+ {/* Bottom border when scrolled */}+ <div+ className={cn(+ "absolute inset-x-0 bottom-0 h-px bg-neutral-200 opacity-0 transition-opacity duration-300 [mask-image:linear-gradient(90deg,transparent,black,transparent)]",+ scrolled && "opacity-100",+ )}+ />++ {program.wordmark || program.logo ? (+ <img+ className="h-7 max-w-32"+ src={(program.wordmark ?? program.logo) as string}+ />+ ) : (+ <Wordmark className="h-7" />+ )}+ <Button+ type="button"+ text="Apply"+ className="h-8 w-fit border-[var(--brand)] bg-[var(--brand)] hover:bg-[var(--brand)] hover:ring-[var(--brand-ring)]"+ />+ </header>+ );+}diff --git a/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/layout.tsx b/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/layout.tsxnew file mode 100644index 0000000000..fe5c76b6ae--- /dev/null+++ b/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/layout.tsx@@ -0,0 +1,47 @@+import { Wordmark } from "@dub/ui";+import { PropsWithChildren } from "react";++export default function ApplyLayout({ children }: PropsWithChildren) {+ return (+ <div className="relative">+ <div className="relative z-10 mx-auto min-h-screen w-full max-w-screen-sm bg-white">+ <div className="pointer-events-none absolute left-0 top-0 h-screen w-full border-x border-gray-200 [mask-image:linear-gradient(black,transparent)]" />+ {children}+ {/* Footer */}+ <footer className="mt-14 flex flex-col items-center gap-4 py-6 text-center text-xs text-neutral-500">+ <span className="flex items-center gap-1.5">+ Powered by <Wordmark className="h-3.5" />+ </span>+ <span className="flex items-center gap-2">+ <a+ href="https://dub.co/legal/terms"+ target="_blank"+ className="transition-colors duration-75 hover:text-neutral-600"+ >+ Terms of Service+ </a>+ <span className="text-base text-neutral-200">•</span>+ <a+ href="https://dub.co/legal/privacy"+ target="_blank"+ className="transition-colors duration-75 hover:text-neutral-600"+ >+ Privacy Policy+ </a>+ </span>+ </footer>+ </div>++ {/* Background grid */}+ <div className="absolute inset-0 flex h-fit w-full items-center justify-center">+ <img+ src="https://assets.dub.co/misc/program-apply-grid.svg"+ alt=""+ width={1280}+ height={480}+ className="[mask-image:radial-gradient(70%_100%_at_50%_0%,black_30%,transparent)]"+ />+ </div>+ </div>+ );+}diff --git a/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/page.tsx b/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/page.tsxindex ebdfb62036..0054a67f7c 100644--- a/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/page.tsx+++ b/apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/page.tsx@@ -7,11 +7,12 @@ import { AccordionBlock } from "@/ui/partners/lander-blocks/AccordionBlock";import { FilesBlock } from "@/ui/partners/lander-blocks/FilesBlock";import { ImageBlock } from "@/ui/partners/lander-blocks/ImageBlock";import { TextBlock } from "@/ui/partners/lander-blocks/TextBlock";-import { Button, Calendar6, MoneyBills2, Wordmark } from "@dub/ui";+import { Button, Calendar6, MoneyBills2 } from "@dub/ui";import { currencyFormatter } from "@dub/utils";import { notFound } from "next/navigation";import { CSSProperties } from "react";import { z } from "zod";+import { Header } from "./header";const BLOCK_COMPONENTS: Record<z.infer<typeof programLanderBlockSchema>["type"],@@ -30,6 +31,16 @@ export default async function ApplyPage({}) {const { programSlug } = params;const program = await prisma.program.findUnique({+ select: {+ lander: true,+ name: true,+ logo: true,+ wordmark: true,+ brandColor: true,+ commissionType: true,+ commissionAmount: true,+ isLifetimeRecurring: true,+ },where: {slug: programSlug,},@@ -50,38 +61,22 @@ export default async function ApplyPage({} as CSSProperties}>- <div className="relative z-10 mx-auto min-h-screen w-full max-w-screen-sm bg-white">- <div className="pointer-events-none absolute left-0 top-0 h-screen w-full border-x border-gray-200 [mask-image:linear-gradient(black,transparent)]" />- <div className="flex items-center justify-between p-6">- {program.wordmark || program.logo ? (- <img- className="h-7 max-w-32"- src={(program.wordmark ?? program.logo) as string}- />- ) : (- <Wordmark className="h-7" />- )}- <Button- type="button"- text="Apply"- className="h-8 w-fit border-[var(--brand)] bg-[var(--brand)] hover:bg-[var(--brand)] hover:ring-[var(--brand-ring)]"- />- </div>- <div className="p-6">- {/* Hero section */}- <div className="grid grid-cols-1 gap-5 sm:pt-20">- <p className="font-mono text-xs font-medium uppercase text-[var(--brand)]">- Affiliate Program- </p>- <h1 className="text-4xl font-semibold">- Join the {program.name} affiliate program- </h1>- <p className="text-base text-neutral-700">- Share {program.name} with your audience and for each subscription- generated through your referral, you'll earn a share of the- revenue on any plans they purchase.- </p>- {/* <p className="text-xs text-neutral-500">+ <Header program={{ logo: program.logo, wordmark: program.wordmark }} />+ <div className="p-6">+ {/* Hero section */}+ <div className="grid grid-cols-1 gap-5 sm:pt-20">+ <p className="font-mono text-xs font-medium uppercase text-[var(--brand)]">+ Affiliate Program+ </p>+ <h1 className="text-4xl font-semibold">+ Join the {program.name} affiliate program+ </h1>+ <p className="text-base text-neutral-700">+ Share {program.name} with your audience and for each subscription+ generated through your referral, you'll earn a share of the revenue+ on any plans they purchase.+ </p>+ {/* <p className="text-xs text-neutral-500">Read our{" "}<ahref="#"@@ -91,93 +86,57 @@ export default async function ApplyPage({</a>{" "}for more details.</p> */}- </div>+ </div>- {/* Program details grid */}- <div className="mt-10 grid grid-cols-1 gap-4 sm:grid-cols-2">- {[- {- icon: MoneyBills2,- title: "Commission",- value:- program.commissionType === "percentage"- ? `${program.commissionAmount}%`- : currencyFormatter(program.commissionAmount / 100, {- minimumFractionDigits: 2,- maximumFractionDigits: 2,- }),- },- {- icon: Calendar6,- title: "Duration",- value: program.isLifetimeRecurring ? "Lifetime" : "Recurring",- },- ].map(({ icon: Icon, title, value }) => (- <div className="rounded-xl bg-neutral-100 p-4">- <Icon className="size-5 text-gray-500" />- <div className="mt-6">- <p className="font-mono text-xl text-neutral-900">{value}</p>- <p className="mt-0.5 text-sm text-gray-500">{title}</p>- </div>+ {/* Program details grid */}+ <div className="mt-10 grid grid-cols-1 gap-4 sm:grid-cols-2">+ {[+ {+ icon: MoneyBills2,+ title: "Commission",+ value:+ program.commissionType === "percentage"+ ? `${program.commissionAmount}%`+ : currencyFormatter(program.commissionAmount / 100, {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ }),+ },+ {+ icon: Calendar6,+ title: "Duration",+ value: program.isLifetimeRecurring ? "Lifetime" : "Recurring",+ },+ ].map(({ icon: Icon, title, value }) => (+ <div className="rounded-xl bg-neutral-100 p-4">+ <Icon className="size-5 text-gray-500" />+ <div className="mt-6">+ <p className="font-mono text-xl text-neutral-900">{value}</p>+ <p className="mt-0.5 text-sm text-gray-500">{title}</p></div>- ))}- </div>-- {/* Buttons */}- <div className="mt-10 flex flex-col gap-2">- <Button- type="button"- text="Apply today"- className="border-[var(--brand)] bg-[var(--brand)] hover:bg-[var(--brand)] hover:ring-[var(--brand-ring)]"- />- {/* <Button type="button" variant="secondary" text="Learn more" /> */}- </div>-- {/* Content blocks */}- <div className="mt-16 grid grid-cols-1 gap-10">- {lander.blocks.map((block, idx) => {- const Component = BLOCK_COMPONENTS[block.type];- return Component ? (- <Component key={idx} block={block} logo={program.logo} />- ) : null;- })}- </div>+ </div>+ ))}</div>- {/* Footer */}- <footer className="mt-14 flex flex-col items-center gap-4 py-6 text-center text-xs text-neutral-500">- <span className="flex items-center gap-1.5">- Powered by <Wordmark className="h-3.5" />- </span>- <span className="flex items-center gap-2">- <a- href="https://dub.co/legal/terms"- target="_blank"- className="transition-colors duration-75 hover:text-neutral-600"- >- Terms of Service- </a>- <span className="text-base text-neutral-200">•</span>- <a- href="https://dub.co/legal/privacy"- target="_blank"- className="transition-colors duration-75 hover:text-neutral-600"- >- Privacy Policy- </a>- </span>- </footer>- </div>+ {/* Buttons */}+ <div className="mt-10 flex flex-col gap-2">+ <Button+ type="button"+ text="Apply today"+ className="border-[var(--brand)] bg-[var(--brand)] hover:bg-[var(--brand)] hover:ring-[var(--brand-ring)]"+ />+ {/* <Button type="button" variant="secondary" text="Learn more" /> */}+ </div>- {/* Background grid */}- <div className="absolute inset-0 flex h-fit w-full items-center justify-center">- <img- src="https://assets.dub.co/misc/program-apply-grid.svg"- alt=""- width={1280}- height={480}- className="[mask-image:radial-gradient(70%_100%_at_50%_0%,black_30%,transparent)]"- />+ {/* Content blocks */}+ <div className="mt-16 grid grid-cols-1 gap-10">+ {lander.blocks.map((block, idx) => {+ const Component = BLOCK_COMPONENTS[block.type];+ return Component ? (+ <Component key={idx} block={block} logo={program.logo} />+ ) : null;+ })}+ </div></div></div>);