The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update labels
Tim Wilson7c2b1e5abd1d
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/settings/branding/branding-settings.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/settings/branding/branding-settings.tsxindex f26be0a6e3..e81313604f 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/settings/branding/branding-settings.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/settings/branding/branding-settings.tsx@@ -4,11 +4,12 @@ import { updateProgramAction } from "@/lib/actions/partners/update-program";import useProgram from "@/lib/swr/use-program";import useWorkspace from "@/lib/swr/use-workspace";import { ProgramProps } from "@/lib/types";+import { ProgramColorPicker } from "@/ui/partners/program-color-picker";import { Button, FileUpload } from "@dub/ui";import { LoadingSpinner, Plus } from "@dub/ui/icons";import { useAction } from "next-safe-action/hooks";import { flightRouterStateSchema } from "next/dist/server/app-render/types";-import { PropsWithChildren, useId } from "react";+import { ReactNode, useId } from "react";import { Controller, useForm } from "react-hook-form";import { toast } from "sonner";import { mutate } from "swr";@@ -45,8 +46,6 @@ export function BrandingSettings() {type FormData = Pick<ProgramProps, "logo" | "wordmark" | "brandColor">;function BrandingSettingsForm({ program }: { program: ProgramProps }) {- const id = useId();-const { id: workspaceId } = useWorkspace();const form = useForm<FormData>({@@ -109,25 +108,28 @@ function BrandingSettingsForm({ program }: { program: ProgramProps }) {label="Logo"description="A square logo that will be used in various parts of your program">- <Controller- control={control}- name="logo"- rules={{ required: flightRouterStateSchema }}- render={({ field }) => (- <FileUpload- accept="images"- className="size-14 rounded-lg border border-neutral-300"- iconClassName="size-4 text-neutral-800"- icon={Plus}- variant="plain"- imageSrc={field.value}- readFile- onChange={({ src }) => field.onChange(src)}- content={null}- maxFileSizeMB={2}- />- )}- />+ {(id) => (+ <Controller+ control={control}+ name="logo"+ rules={{ required: flightRouterStateSchema }}+ render={({ field }) => (+ <FileUpload+ id={id}+ accept="images"+ className="size-14 rounded-lg border border-neutral-300"+ iconClassName="size-4 text-neutral-800"+ icon={Plus}+ variant="plain"+ imageSrc={field.value}+ readFile+ onChange={({ src }) => field.onChange(src)}+ content={null}+ maxFileSizeMB={2}+ />+ )}+ />+ )}</FormRow><Divider />@@ -136,25 +138,28 @@ function BrandingSettingsForm({ program }: { program: ProgramProps }) {label="Wordmark"description="A full-sized logo used on the program application form">- <Controller- control={control}- name="wordmark"- rules={{ required: false }}- render={({ field }) => (- <FileUpload- accept="images"- className="h-14 w-36 rounded-lg border border-neutral-300"- iconClassName="size-4 text-neutral-800"- icon={Plus}- variant="plain"- imageSrc={field.value}- readFile- onChange={({ src }) => field.onChange(src)}- content={null}- maxFileSizeMB={2}- />- )}- />+ {(id) => (+ <Controller+ control={control}+ name="wordmark"+ rules={{ required: false }}+ render={({ field }) => (+ <FileUpload+ id={id}+ accept="images"+ className="h-14 w-36 rounded-lg border border-neutral-300"+ iconClassName="size-4 text-neutral-800"+ icon={Plus}+ variant="plain"+ imageSrc={field.value}+ readFile+ onChange={({ src }) => field.onChange(src)}+ content={null}+ maxFileSizeMB={2}+ />+ )}+ />+ )}</FormRow><Divider />@@ -162,7 +167,21 @@ function BrandingSettingsForm({ program }: { program: ProgramProps }) {<FormRowlabel="Theme color"description="Select the color to match your brand"- ></FormRow>+ >+ {(id) => (+ <Controller+ control={control}+ name="brandColor"+ render={({ field }) => (+ <ProgramColorPicker+ color={field.value}+ onChange={field.onChange}+ id={id}+ />+ )}+ />+ )}+ </FormRow><Divider /></div>@@ -192,15 +211,23 @@ function FormRow({label,description,children,-}: PropsWithChildren<{ label: string; description: string }>) {+}: {+ label: string;+ description: string;+ children: (id: string) => ReactNode;+}) {+ const id = useId();+return (- <div className="flex items-center gap-6">+ <div className="flex items-center justify-between gap-6"><div>- <label className="text-sm font-medium text-neutral-800">{label}</label>+ <label className="text-sm font-medium text-neutral-800" htmlFor={id}>+ {label}+ </label><p className="mt-2 text-xs text-neutral-500">{description}</p></div>- <div>{children}</div>+ <div>{children(id)}</div></div>);}diff --git a/apps/web/ui/partners/program-color-picker.tsx b/apps/web/ui/partners/program-color-picker.tsxnew file mode 100644index 0000000000..c6fd5492aa--- /dev/null+++ b/apps/web/ui/partners/program-color-picker.tsx@@ -0,0 +1,135 @@+"use client";++import { Popover, Tooltip } from "@dub/ui";+import { cn } from "@dub/utils";+import { CSSProperties, useState } from "react";++const RAINBOW_CONIC_GRADIENT =+ "conic-gradient(in hsl, #ee535d 0deg, #e9d988 90deg, #9fe0b8 180deg, #bf87e4 270deg, #ee535d 360deg)";++const COLORS = [+ { color: "#737373", name: "Gray" },+ { color: "#FB2C36", name: "Red" },+ { color: "#FF6900", name: "Orange" },+ { color: "#FD9A00", name: "Amber" },+ { color: "#EFB100", name: "Yellow" },+ { color: "#7CCF00", name: "Lime" },+ { color: "#00C951", name: "Green" },+ { color: "#00BC7D", name: "Emerald" },+ { color: "#00BBA7", name: "Teal" },+ { color: "#00B8DB", name: "Cyan" },+ { color: "#00A6F4", name: "Sky" },+ { color: "#2B7FFF", name: "Blue" },+ { color: "#615FFF", name: "Indigo" },+ { color: "#8E51FF", name: "Violet" },+ { color: "#AD46FF", name: "Purple" },+ { color: "#E12AFB", name: "Fuchsia" },+ { color: "#F6339A", name: "Pink" },+ { color: "#FF2056", name: "Rose" },+];++export function ProgramColorPicker({+ color,+ onChange,+ id,+}: {+ color: string | null;+ onChange: (color: string | null) => void;+ id?: string;+}) {+ const [isOpen, setIsOpen] = useState(false);++ const onSelect = (color: string | null) => {+ onChange(color);+ setIsOpen(false);+ };++ return (+ <Popover+ openPopover={isOpen}+ setOpenPopover={setIsOpen}+ popoverContentClassName="-mt-4"+ content={+ <div className="grid grid-cols-6 gap-3 p-4">+ <div className="sr-only" tabIndex={0}>+ Select a color+ </div>+ <div className="col-span-6">+ <Swatch+ color={null}+ name="Rainbow"+ onSelect={() => onSelect(null)}+ />+ </div>+ {COLORS.map(({ color, name }) => (+ <Swatch+ color={color}+ name={name}+ onSelect={() => onSelect(color)}+ />+ ))}+ </div>+ }+ side="right"+ align="start"+ >+ <button+ id={id}+ type="button"+ className={cn(+ "relative size-7 overflow-hidden rounded-full outline-none ring-black/10 transition-all duration-75",+ "hover:ring focus:ring data-[state=open]:ring data-[state=open]:ring-black/20",+ "focus-visible:ring-1 focus-visible:ring-black/40 focus-visible:ring-offset-2",+ )}+ style={{+ backgroundColor: color ?? undefined,+ }}+ >+ {!color && <Rainbow />}+ </button>+ </Popover>+ );+}++function Swatch({+ color,+ name,+ onSelect,+}: {+ color: string | null;+ name: string;+ onSelect: () => void;+}) {+ return (+ <Tooltip content={name} delayDuration={1000} disableHoverableContent>+ <div className="w-fit rounded-full">+ <button+ type="button"+ onClick={onSelect}+ className={cn(+ "relative block size-6 overflow-hidden rounded-full ring-transparent ring-offset-2 transition-all duration-75",+ "hover:ring-1 hover:ring-[var(--ring-color)]",+ "outline-none focus-visible:ring-1 focus-visible:ring-[var(--ring-color)]",+ )}+ style={+ {+ backgroundColor: color ?? undefined,+ "--ring-color": color ?? "#404040",+ } as CSSProperties+ }+ >+ {!color && <Rainbow />}+ </button>+ </div>+ </Tooltip>+ );+}++const Rainbow = () => (+ <div+ className="absolute -inset-[50%] rounded-full blur-[2px]"+ style={{+ backgroundImage: RAINBOW_CONIC_GRADIENT,+ }}+ />+);diff --git a/packages/ui/src/file-upload.tsx b/packages/ui/src/file-upload.tsxindex 4605c54f3e..d7ab0d7d14 100644--- a/packages/ui/src/file-upload.tsx+++ b/packages/ui/src/file-upload.tsx@@ -53,6 +53,7 @@ type FileUploadReadFileProps =};export type FileUploadProps = FileUploadReadFileProps & {+ id?: string;accept: AcceptedFileFormats;className?: string;iconClassName?: string;@@ -108,6 +109,7 @@ export type FileUploadProps = FileUploadReadFileProps & {} & VariantProps<typeof imageUploadVariants>;export function FileUpload({+ id,readFile,onChange,variant,@@ -277,6 +279,7 @@ export function FileUpload({{clickToUpload && (<div className="sr-only mt-1 flex shadow-sm"><input+ id={id}key={fileName} // Gets us a fresh input every time a file is uploadedtype="file"accept={acceptFileTypes[accept].types.join(",")}diff --git a/packages/ui/src/popover.tsx b/packages/ui/src/popover.tsxindex 93ce95e27e..b622ff8027 100644--- a/packages/ui/src/popover.tsx+++ b/packages/ui/src/popover.tsx@@ -14,6 +14,7 @@ export type PopoverProps = PropsWithChildren<{setOpenPopover: (open: boolean) => void;mobileOnly?: boolean;popoverContentClassName?: string;+ onOpenAutoFocus?: PopoverPrimitive.PopoverContentProps["onOpenAutoFocus"];collisionBoundary?: Element | Element[];sticky?: "partial" | "always";onEscapeKeyDown?: (event: KeyboardEvent) => void;@@ -29,6 +30,7 @@ export function Popover({setOpenPopover,mobileOnly,popoverContentClassName,+ onOpenAutoFocus,collisionBoundary,sticky,onEscapeKeyDown,@@ -86,6 +88,7 @@ export function Popover({)}sticky={sticky}collisionBoundary={collisionBoundary}+ onOpenAutoFocus={onOpenAutoFocus}onEscapeKeyDown={onEscapeKeyDown}onWheel={onWheel}>