The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
WIP embed preview
Tim Wilson11c450af74a4
diff --git a/apps/web/ui/partners/design/branding-form.tsx b/apps/web/ui/partners/design/branding-form.tsxindex 761e5694be..bc493d760c 100644--- a/apps/web/ui/partners/design/branding-form.tsx+++ b/apps/web/ui/partners/design/branding-form.tsx@@ -15,7 +15,7 @@ import {useLocalStorage,useRouterStuff,} from "@dub/ui";-import { cn, PARTNERS_DOMAIN } from "@dub/utils";+import { cn } from "@dub/utils";import { AnimatePresence, motion } from "framer-motion";import { ChevronDown } from "lucide-react";import { useAction } from "next-safe-action/hooks";@@ -26,7 +26,7 @@ import { toast } from "sonner";import { KeyedMutator } from "swr";import { z } from "zod";import { BrandingSettingsForm } from "./branding-settings-form";-import { PreviewWindow } from "./preview-window";+import { EmbedPreview } from "./previews/embed-preview";import { LanderPreview } from "./previews/lander-preview";import { PortalPreview } from "./previews/portal-preview";@@ -72,12 +72,6 @@ export function BrandingForm() {);}-const Placeholder = ({ program }: { program: ProgramWithLanderDataProps }) => (- <PreviewWindow url={`${PARTNERS_DOMAIN}/${program?.slug}`}>- <div className="flex justify-center py-8">WIP</div>- </PreviewWindow>-);-const PREVIEW_TABS = [{value: "landing",@@ -92,7 +86,7 @@ const PREVIEW_TABS = [{value: "embed",label: "Embed",- component: Placeholder,+ component: EmbedPreview,},];diff --git a/apps/web/ui/partners/design/preview-window.tsx b/apps/web/ui/partners/design/preview-window.tsxindex 22544d52d0..3ddebf6084 100644--- a/apps/web/ui/partners/design/preview-window.tsx+++ b/apps/web/ui/partners/design/preview-window.tsx@@ -8,12 +8,14 @@ import { toast } from "sonner";export function PreviewWindow({url,scrollRef,+ showViewButton = true,className,contentClassName,children,}: PropsWithChildren<{url: string;scrollRef?: RefObject<HTMLDivElement>;+ showViewButton?: boolean;className?: string;contentClassName?: string;}>) {@@ -56,17 +58,19 @@ export function PreviewWindow({</div></button><div className="flex grow basis-0 justify-end">- <Link- href={url}- target="_blank"- className={cn(- buttonVariants({ variant: "secondary" }),- "flex h-7 w-fit items-center gap-1 rounded-md border px-2 text-sm",- )}- >- View- <ArrowUpRight className="size-3" />- </Link>+ {showViewButton && (+ <Link+ href={url}+ target="_blank"+ className={cn(+ buttonVariants({ variant: "secondary" }),+ "flex h-7 w-fit items-center gap-1 rounded-md border px-2 text-sm",+ )}+ >+ View+ <ArrowUpRight className="size-3" />+ </Link>+ )}</div></div><divdiff --git a/apps/web/ui/partners/design/previews/embed-preview.tsx b/apps/web/ui/partners/design/previews/embed-preview.tsxnew file mode 100644index 0000000000..9915584b47--- /dev/null+++ b/apps/web/ui/partners/design/previews/embed-preview.tsx@@ -0,0 +1,50 @@+"use client";++import { ProgramWithLanderDataProps } from "@/lib/types";+import { CSSProperties, useId } from "react";+import { useWatch } from "react-hook-form";+import { useBrandingFormContext } from "../branding-form";+import { PreviewWindow } from "../preview-window";++export function EmbedPreview({+ program,+}: {+ program: ProgramWithLanderDataProps;+}) {+ const id = useId();++ const { getValues } = useBrandingFormContext();+ const { brandColor, logo } = {+ ...useWatch(),+ ...getValues(),+ };++ return (+ <div className="scrollbar-hide -mx-2 h-full w-auto overflow-y-auto px-2 pb-4">+ <PreviewWindow+ url={`https://${program.domain}`}+ showViewButton={false}+ className="h-auto rounded-b-xl bg-neutral-100"+ contentClassName="overflow-y-hidden"+ >+ <div+ className="relative z-0 mx-auto w-full select-none text-[var(--brand)]"+ style={+ {+ "--brand": brandColor || "#000000",+ } as CSSProperties+ }+ role="presentation"+ >+ {/* <svg+ xmlns="http://www.w3.org/2000/svg"+ xmlnsXlink="http://www.w3.org/1999/xlink"+ fill="none"+ viewBox="0 0 869 690"+ className="h-auto w-full [&_*]:tracking-[-0.035em]"+ > */}+ </div>+ </PreviewWindow>+ </div>+ );+}diff --git a/apps/web/ui/partners/design/previews/portal-preview.tsx b/apps/web/ui/partners/design/previews/portal-preview.tsxindex b028ff1064..cabd4f65f9 100644--- a/apps/web/ui/partners/design/previews/portal-preview.tsx+++ b/apps/web/ui/partners/design/previews/portal-preview.tsx@@ -21,21 +21,19 @@ export function PortalPreview({};return (- <div- className="scrollbar-hide -mx-2 h-full w-auto overflow-y-auto px-2 pb-4 text-[var(--brand)]"- style={- {- "--brand": brandColor || "#000000",- } as CSSProperties- }- >+ <div className="scrollbar-hide -mx-2 h-full w-auto overflow-y-auto px-2 pb-4"><PreviewWindowurl={`${PARTNERS_DOMAIN}/programs/${program?.slug}`}className="h-auto rounded-b-xl bg-neutral-100"contentClassName="overflow-y-hidden"><div- className="relative z-0 mx-auto w-full select-none"+ className="relative z-0 mx-auto w-full select-none text-[var(--brand)]"+ style={+ {+ "--brand": brandColor || "#000000",+ } as CSSProperties+ }role="presentation"><svg