The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Color picker component
Marcus Farrell23f803dc7932
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-settings.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-settings.tsxindex b24f5e6c41..624f8f6ee8 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-settings.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-settings.tsx@@ -9,8 +9,8 @@ import {DEFAULT_PARTNER_GROUP,updateGroupSchema,} from "@/lib/zod/schemas/groups";-import { GroupColorPicker } from "@/ui/partners/groups/group-color-picker";import { GroupSettingsRow } from "@/ui/partners/groups/group-settings-row";+import { ColorPicker, RESOURCE_COLOR_SWATCHES } from "@/ui/shared/color-picker";import { Button, CopyButton } from "@dub/ui";import { cn } from "@dub/utils";import slugify from "@sindresorhus/slugify";@@ -133,9 +133,13 @@ function GroupSettingsForm({control={control}name="color"render={({ field }) => (- <GroupColorPicker- color={field.value}+ <ColorPicker+ value={field.value ?? null}onChange={field.onChange}+ swatches={RESOURCE_COLOR_SWATCHES}+ showDefault+ variant="swatches"+ className="size-5"/>)}/>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/create-group-modal.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/create-group-modal.tsxindex 1c221c23a6..b468993232 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/create-group-modal.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/create-group-modal.tsx@@ -3,7 +3,7 @@ import { useApiMutation } from "@/lib/swr/use-api-mutation";import useWorkspace from "@/lib/swr/use-workspace";import { createGroupSchema } from "@/lib/zod/schemas/groups";import { RESOURCE_COLORS } from "@/ui/colors";-import { GroupColorPicker } from "@/ui/partners/groups/group-color-picker";+import { ColorPicker, RESOURCE_COLOR_SWATCHES } from "@/ui/shared/color-picker";import { Button, Modal } from "@dub/ui";import { cn } from "@dub/utils";import slugify from "@sindresorhus/slugify";@@ -92,9 +92,13 @@ function CreateGroupModalContent({ setIsOpen }: CreateGroupModalProps) {control={control}name="color"render={({ field }) => (- <GroupColorPicker- color={field.value}+ <ColorPicker+ value={field.value}onChange={field.onChange}+ swatches={RESOURCE_COLOR_SWATCHES}+ showDefault+ variant="swatches"+ className="size-5"/>)}/>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-brand-assets/add-color-modal.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-brand-assets/add-color-modal.tsxindex e8fafb51fb..b46bf7a9a3 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-brand-assets/add-color-modal.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-brand-assets/add-color-modal.tsx@@ -5,6 +5,7 @@ import { updateProgramResourceAction } from "@/lib/actions/partners/program-resoimport useProgramResources from "@/lib/swr/use-program-resources";import useWorkspace from "@/lib/swr/use-workspace";import { ProgramResourceColor } from "@/lib/zod/schemas/program-resources";+import { ColorSelector } from "@/ui/shared/color-picker";import { Button, Modal } from "@dub/ui";import { cn } from "@dub/utils";import { useAction } from "next-safe-action/hooks";@@ -12,11 +13,9 @@ import {Dispatch,SetStateAction,useCallback,- useEffect,useMemo,useState,} from "react";-import { HexColorPicker } from "react-colorful";import { useForm } from "react-hook-form";import { toast } from "sonner";import * as z from "zod/v4";@@ -55,10 +54,6 @@ function ColorModalInner({const { mutate } = useProgramResources();const isEditing = Boolean(existingResource);- const [hexInputValue, setHexInputValue] = useState(- existingResource?.color || "#000000",- );-const {register,handleSubmit,@@ -77,19 +72,6 @@ function ColorModalInner({const selectedColor = watch("color");- // Keep hex input in sync with form value- useEffect(() => setHexInputValue(selectedColor), [selectedColor]);-- const handleHexInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {- const value = e.target.value;- setHexInputValue(value);-- // Only update form value if it's a valid hex color- if (/^#?[0-9A-F]{6}$/i.test(value)) {- setValue("color", value.startsWith("#") ? value : `#${value}`);- }- };-const { executeAsync: executeAdd } = useAction(addProgramResourceAction, {onSuccess: () => {mutate();@@ -160,33 +142,14 @@ function ColorModalInner({<div className="bg-neutral-50 p-4 sm:p-6"><div className="space-y-4"><div>- <span className="mb-1 block text-sm font-medium text-neutral-700">- Color- </span>- <div className="flex justify-center [&_.react-colorful]:h-[180px] [&_.react-colorful]:w-full">- <HexColorPicker- color={selectedColor}- onChange={(color) =>- setValue("color", color, { shouldDirty: true })- }- />- </div>- </div>-- <label className="block">- <span className="mb-1 block text-sm font-medium text-neutral-700">- Hex- </span>- <input- type="text"- value={hexInputValue}- onChange={handleHexInputChange}- className={cn(- "block w-full rounded-md border-neutral-300 shadow-sm focus:border-neutral-500 focus:ring-neutral-500 sm:text-sm",- !/^#[0-9A-F]{6}$/i.test(hexInputValue) &&- "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500",- )}- placeholder="#000000"+ <ColorSelector+ value={selectedColor}+ onChange={(color) =>+ color && setValue("color", color, { shouldDirty: true })+ }+ showPicker+ showHexInput+ className="w-full"/><inputtype="hidden"@@ -197,7 +160,7 @@ function ColorModalInner({{errors.color.message}</p>)}- </label>+ </div><label className="block"><span className="mb-1 block text-sm font-medium text-neutral-700">diff --git a/apps/web/lib/zod/schemas/tags.ts b/apps/web/lib/zod/schemas/tags.tsindex cc9fc26ece..486ace7c3d 100644--- a/apps/web/lib/zod/schemas/tags.ts+++ b/apps/web/lib/zod/schemas/tags.ts@@ -1,4 +1,4 @@-import { RESOURCE_COLORS } from "@/ui/colors";+import { TAG_COLORS } from "@/ui/colors";import * as z from "zod/v4";import { booleanQuerySchema, getPaginationQuerySchema } from "./misc";@@ -40,7 +40,7 @@ export const getTagsCountQuerySchema = getTagsQuerySchema.omit({});// TODO: Remove "pink" after confirming we don't have any pink tags in the database-const tagColors = [...RESOURCE_COLORS, "pink"] as const;+const tagColors = [...TAG_COLORS, "pink"] as const;export const tagColorSchema = z.enum(tagColors, {@@ -59,7 +59,7 @@ export const createTagBodySchema = z.object({name: tagName,color: tagColorSchema.describe(- `The color of the tag. If not provided, a random color will be used from the list: ${RESOURCE_COLORS.join(", ")}.`,+ `The color of the tag. If not provided, a random color will be used from the list: ${TAG_COLORS.join(", ")}.`,),tag: tagName.meta({deprecated: true,diff --git a/apps/web/ui/colors.ts b/apps/web/ui/colors.tsindex 780f4da5ac..869d2aef2f 100644--- a/apps/web/ui/colors.ts+++ b/apps/web/ui/colors.ts@@ -3,38 +3,93 @@ import { ResourceColorsEnum } from "../lib/types";export const RESOURCE_COLORS_DATA = [{color: "red",+ hex: "#FB2C36",tagVariants: "bg-red-100 text-red-600",- groupVariants: "bg-red-600",+ groupVariants: "bg-red-500",+ },+ {+ color: "orange",+ hex: "#FF6900",+ tagVariants: "bg-orange-100 text-orange-600",+ groupVariants: "bg-orange-500",+ },+ {+ color: "amber",+ hex: "#FD9A00",+ tagVariants: "bg-amber-100 text-amber-600",+ groupVariants: "bg-amber-500",},{color: "yellow",+ hex: "#EFB100",tagVariants: "bg-yellow-100 text-yellow-600",- groupVariants: "bg-yellow-600",+ groupVariants: "bg-yellow-500",+ },+ {+ color: "lime",+ hex: "#7CCF00",+ tagVariants: "bg-lime-100 text-lime-600",+ groupVariants: "bg-lime-500",},{color: "green",+ hex: "#00C951",tagVariants: "bg-green-100 text-green-600",- groupVariants: "bg-green-600",+ groupVariants: "bg-green-500",+ },+ {+ color: "teal",+ hex: "#00BBA7",+ tagVariants: "bg-teal-100 text-teal-600",+ groupVariants: "bg-teal-500",+ },+ {+ color: "cyan",+ hex: "#00B8DB",+ tagVariants: "bg-cyan-100 text-cyan-600",+ groupVariants: "bg-cyan-500",},{color: "blue",+ hex: "#2B7FFF",tagVariants: "bg-blue-100 text-blue-600",- groupVariants: "bg-blue-600",+ groupVariants: "bg-blue-500",+ },+ {+ color: "indigo",+ hex: "#615FFF",+ tagVariants: "bg-indigo-100 text-indigo-600",+ groupVariants: "bg-indigo-500",},{color: "purple",+ hex: "#AD46FF",tagVariants: "bg-purple-100 text-purple-600",- groupVariants: "bg-purple-600",+ groupVariants: "bg-purple-500",+ },+ {+ color: "fuchsia",+ hex: "#E12AFB",+ tagVariants: "bg-fuchsia-100 text-fuchsia-600",+ groupVariants: "bg-fuchsia-500",+ },+ {+ color: "pink",+ hex: "#F6339A",+ tagVariants: "bg-pink-100 text-pink-600",+ groupVariants: "bg-pink-500",},{color: "brown",+ hex: "#CA8365",tagVariants: "bg-brown-100 text-brown-600",- groupVariants: "bg-brown-600",+ groupVariants: "bg-brown-500",},{color: "gray",+ hex: "#525252",tagVariants: "bg-gray-100 text-gray-600",- groupVariants: "bg-gray-600",+ groupVariants: "bg-gray-500",},] as const;@@ -42,9 +97,24 @@ export const RESOURCE_COLORS = RESOURCE_COLORS_DATA.map((color) => color.color,) as [string, ...string[]];+// Tags keep the original 7-color set from before the palette was extended to 15+export const TAG_COLORS = [+ "red",+ "yellow",+ "green",+ "blue",+ "purple",+ "brown",+ "gray",+] as const;++export const TAG_COLORS_DATA = RESOURCE_COLORS_DATA.filter(({ color }) =>+ (TAG_COLORS as readonly string[]).includes(color),+);+export const getResourceColorData = (color: ResourceColorsEnum) => {return RESOURCE_COLORS_DATA.find((c) => c.color === color);};export const RAINBOW_CONIC_GRADIENT =- "conic-gradient(in hsl, #ee535d 0deg, #e9d988 90deg, #9fe0b8 180deg, #bf87e4 270deg, #ee535d 360deg)";+ "conic-gradient(from 180deg at 50% 50%, #6AED9F 23.078deg, #97A1F7 72deg, #EF4BD5 144deg, #F94562 216deg, #FCAE6A 288deg, #ECDF59 339.603deg)";diff --git a/apps/web/ui/links/tag-badge.tsx b/apps/web/ui/links/tag-badge.tsxindex 2ff8945c74..08d28f5c80 100644--- a/apps/web/ui/links/tag-badge.tsx+++ b/apps/web/ui/links/tag-badge.tsx@@ -1,5 +1,5 @@import { ResourceColorsEnum } from "@/lib/types";-import { RESOURCE_COLORS } from "@/ui/colors";+import { TAG_COLORS } from "@/ui/colors";import { useMediaQuery } from "@dub/ui";import { cn, randomValue, truncate } from "@dub/utils";import { Tag } from "lucide-react";@@ -50,5 +50,5 @@ export default function TagBadge({}export function randomBadgeColor() {- return randomValue(RESOURCE_COLORS);+ return randomValue([...TAG_COLORS]);}diff --git a/apps/web/ui/modals/add-edit-tag-modal.tsx b/apps/web/ui/modals/add-edit-tag-modal.tsxindex 42234ecbd1..2494f961d2 100644--- a/apps/web/ui/modals/add-edit-tag-modal.tsx+++ b/apps/web/ui/modals/add-edit-tag-modal.tsx@@ -3,7 +3,7 @@ import { mutatePrefix } from "@/lib/swr/mutate";import useTags from "@/lib/swr/use-tags";import useWorkspace from "@/lib/swr/use-workspace";import { ResourceColorsEnum, TagProps } from "@/lib/types";-import { RESOURCE_COLORS_DATA } from "@/ui/colors";+import { TAG_COLORS_DATA } from "@/ui/colors";import {Button,InfoTooltip,@@ -169,7 +169,7 @@ function AddEditTagModal({}}className="mt-2 flex flex-wrap gap-3">- {RESOURCE_COLORS_DATA.map(({ color: colorOption, tagVariants }) => (+ {TAG_COLORS_DATA.map(({ color: colorOption, tagVariants }) => (<div key={colorOption} className="flex items-center"><RadioGroupItemvalue={colorOption}diff --git a/apps/web/ui/modals/link-qr-modal.tsx b/apps/web/ui/modals/link-qr-modal.tsxindex b398c4aa5f..82dd047c78 100644--- a/apps/web/ui/modals/link-qr-modal.tsx+++ b/apps/web/ui/modals/link-qr-modal.tsx@@ -150,8 +150,8 @@ function LinkQRModalInner({onClose={() => setShowLinkQRModal(false)}logoSection={<div>- <div className="flex items-center gap-1.5">- <label className="text-sm font-medium text-neutral-700">+ <div className="flex items-center gap-1">+ <label className="text-sm font-semibold text-neutral-800">Logo</label><InfoTooltip content="Display your logo in the center of the QR code. [Learn more.](https://dub.co/help/article/custom-qr-codes)" />@@ -166,7 +166,9 @@ function LinkQRModalInner({onClick={() => setData((d) => ({ ...d, hideLogo: false }))}disabled={!isPro}>- <span className="text-sm">Show</span>+ <span className="text-sm font-medium text-neutral-800">+ Show+ </span></SegmentTab><SegmentTabactive={!!(data.hideLogo && isPro)}@@ -189,7 +191,9 @@ function LinkQRModalInner({<Crown className="text-content-default mr-1 size-4" /></Tooltip>)}- <span className="text-sm">Hide</span>+ <span className="text-sm font-medium text-neutral-800">+ Hide+ </span></SegmentTab></SegmentedControl></div>diff --git a/apps/web/ui/modals/qr-code-design-fields.tsx b/apps/web/ui/modals/qr-code-design-fields.tsxindex f50a015836..d85d950cc0 100644--- a/apps/web/ui/modals/qr-code-design-fields.tsx+++ b/apps/web/ui/modals/qr-code-design-fields.tsx@@ -1,6 +1,7 @@import { getQRAsCanvas, getQRAsSVGDataUri, getQRData } from "@/lib/qr";import { QRCodeDesign } from "@/lib/qr/types";import { QRLinkProps } from "@/lib/types";+import { ColorPicker } from "@/ui/shared/color-picker";import { QRCode } from "@/ui/shared/qr-code";import {Button,@@ -9,11 +10,10 @@ import {InfoTooltip,Popover,ShimmerDots,- Tooltip,useCopyToClipboard,useMediaQuery,} from "@dub/ui";-import { Check, Check2, Copy, Download, Hyperlink, Photo } from "@dub/ui/icons";+import { Check, Copy, Download, Hyperlink, Photo } from "@dub/ui/icons";import { API_DOMAIN, cn, linkConstructor } from "@dub/utils";import { AnimatePresence, motion } from "motion/react";import {@@ -25,23 +25,10 @@ import {useRef,useState,} from "react";-import { HexColorInput, HexColorPicker } from "react-colorful";import { toast } from "sonner";-import { useDebouncedCallback } from "use-debounce";// ─── Constants ────────────────────────────────────────────────────────────────-export const DEFAULT_COLORS = [- "#000000",- "#C73E33",- "#DF6547",- "#F4B3D7",- "#F6CF54",- "#49A065",- "#2146B7",- "#AE49BF",-];-export const DEFAULT_QR_DESIGN: QRCodeDesign = {fgColor: "#000000",hideLogo: false,@@ -80,17 +67,134 @@ export function QRCodeDesignFields({const id = useId();const { isMobile } = useMediaQuery();- const onColorChange = useDebouncedCallback(- (color: string) => setData((d) => ({ ...d, fgColor: color })),- 500,+ const previewKey = `${data.fgColor}-${data.hideLogo}-${data.dotStyle}-${data.markerCenterStyle}-${data.markerBorderStyle}-${data.markerColor ?? ""}`;++ const dotStyleField = (+ <div>+ <div className="flex items-center gap-1">+ <label className="text-sm font-semibold text-neutral-800">+ Dot style+ </label>+ </div>+ <SegmentedControl+ activeIndex={+ data.dotStyle === "rounded"+ ? 1+ : data.dotStyle === "extra-rounded"+ ? 2+ : 0+ }+ count={3}+ >+ <SegmentTab+ active={!data.dotStyle || data.dotStyle === "square"}+ onClick={() => setData((d) => ({ ...d, dotStyle: "square" }))}+ ariaLabel="Square dots"+ >+ <SquareDotIcon />+ </SegmentTab>+ <SegmentTab+ active={data.dotStyle === "rounded"}+ onClick={() => setData((d) => ({ ...d, dotStyle: "rounded" }))}+ ariaLabel="Rounded dots"+ >+ <RoundedDotIcon />+ </SegmentTab>+ <SegmentTab+ active={data.dotStyle === "extra-rounded"}+ onClick={() => setData((d) => ({ ...d, dotStyle: "extra-rounded" }))}+ ariaLabel="Extra-rounded dots"+ >+ <ExtraRoundedDotIcon />+ </SegmentTab>+ </SegmentedControl>+ </div>);- const onMarkerColorChange = useDebouncedCallback(- (color: string) => setData((d) => ({ ...d, markerColor: color })),- 500,+ const markerCenterField = (+ <div>+ <div className="flex items-center gap-1">+ <label className="text-sm font-semibold text-neutral-800">+ Marker center+ </label>+ </div>+ <SegmentedControl+ activeIndex={data.markerCenterStyle === "circle" ? 1 : 0}+ count={2}+ >+ <SegmentTab+ active={+ !data.markerCenterStyle || data.markerCenterStyle === "square"+ }+ onClick={() =>+ setData((d) => ({ ...d, markerCenterStyle: "square" }))+ }+ ariaLabel="Square marker center"+ >+ <MarkerCenterSquareIcon />+ </SegmentTab>+ <SegmentTab+ active={data.markerCenterStyle === "circle"}+ onClick={() =>+ setData((d) => ({ ...d, markerCenterStyle: "circle" }))+ }+ ariaLabel="Circle marker center"+ >+ <MarkerCenterCircleIcon />+ </SegmentTab>+ </SegmentedControl>+ </div>);- const previewKey = `${data.fgColor}-${data.hideLogo}-${data.dotStyle}-${data.markerCenterStyle}-${data.markerBorderStyle}-${data.markerColor ?? ""}`;+ const markerBorderField = (+ <div>+ <div className="flex items-center gap-1">+ <label className="text-sm font-semibold text-neutral-800">+ Marker border+ </label>+ </div>+ <SegmentedControl+ activeIndex={+ data.markerBorderStyle === "rounded-square"+ ? 1+ : data.markerBorderStyle === "circle"+ ? 2+ : 0+ }+ count={3}+ >+ <SegmentTab+ active={+ !data.markerBorderStyle || data.markerBorderStyle === "square"+ }+ onClick={() =>+ setData((d) => ({ ...d, markerBorderStyle: "square" }))+ }+ ariaLabel="Square marker border"+ >+ <MarkerBorderSquareIcon />+ </SegmentTab>+ <SegmentTab+ active={data.markerBorderStyle === "rounded-square"}+ onClick={() =>+ setData((d) => ({ ...d, markerBorderStyle: "rounded-square" }))+ }+ ariaLabel="Rounded marker border"+ >+ <MarkerBorderRoundedIcon />+ </SegmentTab>+ <SegmentTab+ active={data.markerBorderStyle === "circle"}+ onClick={() =>+ setData((d) => ({ ...d, markerBorderStyle: "circle" }))+ }+ ariaLabel="Circle marker border"+ >+ <MarkerBorderCircleIcon />+ </SegmentTab>+ </SegmentedControl>+ </div>+ );return (<>@@ -153,169 +257,43 @@ export function QRCodeDesignFields({</div></div>- {/* Logo slot + Dot style */}- <div className={cn(logoSection && "grid grid-cols-2 gap-4")}>- {logoSection}- <div>- <div className="flex items-center gap-1.5">- <label className="text-sm font-medium text-neutral-700">- Dot style- </label>- </div>- <SegmentedControl- activeIndex={- data.dotStyle === "rounded"- ? 1- : data.dotStyle === "extra-rounded"- ? 2- : 0- }- count={3}- >- <SegmentTab- active={!data.dotStyle || data.dotStyle === "square"}- onClick={() => setData((d) => ({ ...d, dotStyle: "square" }))}- ariaLabel="Square dots"- >- <SquareDotIcon />- </SegmentTab>- <SegmentTab- active={data.dotStyle === "rounded"}- onClick={() => setData((d) => ({ ...d, dotStyle: "rounded" }))}- ariaLabel="Rounded dots"- >- <RoundedDotIcon />- </SegmentTab>- <SegmentTab- active={data.dotStyle === "extra-rounded"}- onClick={() =>- setData((d) => ({ ...d, dotStyle: "extra-rounded" }))- }- ariaLabel="Extra-rounded dots"- >- <ExtraRoundedDotIcon />- </SegmentTab>- </SegmentedControl>- </div>- </div>-- {/* Marker center + Marker border */}- <div className="grid grid-cols-2 gap-4">- <div>- <div className="flex items-center gap-1.5">- <label className="text-sm font-medium text-neutral-700">- Marker center- </label>- </div>- <SegmentedControl- activeIndex={data.markerCenterStyle === "circle" ? 1 : 0}- count={2}- >- <SegmentTab- active={- !data.markerCenterStyle || data.markerCenterStyle === "square"- }- onClick={() =>- setData((d) => ({ ...d, markerCenterStyle: "square" }))- }- ariaLabel="Square marker center"- >- <MarkerCenterSquareIcon />- </SegmentTab>- <SegmentTab- active={data.markerCenterStyle === "circle"}- onClick={() =>- setData((d) => ({ ...d, markerCenterStyle: "circle" }))- }- ariaLabel="Circle marker center"- >- <MarkerCenterCircleIcon />- </SegmentTab>- </SegmentedControl>- </div>+ {/* Style fields: Logo slot + Marker center, Dot style + Marker border,+ Dot Color + Marker Color (Dot style goes full-width when there's no logo) */}+ <div className="grid grid-cols-2 gap-x-8 gap-y-4">+ {logoSection ? (+ <>+ {logoSection}+ {markerCenterField}+ {dotStyleField}+ </>+ ) : (+ <>+ <div className="col-span-2">{dotStyleField}</div>+ {markerCenterField}+ </>+ )}+ {markerBorderField}++ <ColorSection+ id={`${id}-fg`}+ label="Dot Color"+ color={data.fgColor}+ onChange={(color) =>+ setData((d) => ({ ...d, fgColor: color ?? "#000000" }))+ }+ />- <div>- <div className="flex items-center gap-1.5">- <label className="text-sm font-medium text-neutral-700">- Marker border- </label>- </div>- <SegmentedControl- activeIndex={- data.markerBorderStyle === "rounded-square"- ? 1- : data.markerBorderStyle === "circle"- ? 2- : 0- }- count={3}- >- <SegmentTab- active={- !data.markerBorderStyle || data.markerBorderStyle === "square"- }- onClick={() =>- setData((d) => ({ ...d, markerBorderStyle: "square" }))- }- ariaLabel="Square marker border"- >- <MarkerBorderSquareIcon />- </SegmentTab>- <SegmentTab- active={data.markerBorderStyle === "rounded-square"}- onClick={() =>- setData((d) => ({- ...d,- markerBorderStyle: "rounded-square",- }))- }- ariaLabel="Rounded marker border"- >- <MarkerBorderRoundedIcon />- </SegmentTab>- <SegmentTab- active={data.markerBorderStyle === "circle"}- onClick={() =>- setData((d) => ({ ...d, markerBorderStyle: "circle" }))- }- ariaLabel="Circle marker border"- >- <MarkerBorderCircleIcon />- </SegmentTab>- </SegmentedControl>- </div>+ <ColorSection+ id={`${id}-marker`}+ label="Marker Color"+ tooltip="Set a different color for the finder pattern markers. Defaults to the QR code color."+ color={data.markerColor ?? data.fgColor}+ onChange={(color) =>+ setData((d) => ({ ...d, markerColor: color ?? undefined }))+ }+ /></div>- <ColorSection- id={`${id}-fg`}- label="Dot Color"- color={data.fgColor}- onChange={onColorChange}- onSwatchClick={(color) => setData((d) => ({ ...d, fgColor: color }))}- />-- <ColorSection- id={`${id}-marker`}- label="Marker Color"- tooltip="Set a different color for the finder pattern markers. Defaults to the QR code color."- color={data.markerColor ?? data.fgColor}- onChange={onMarkerColorChange}- onSwatchClick={(color) =>- setData((d) => ({ ...d, markerColor: color }))- }- extraAction={- data.markerColor && data.markerColor !== data.fgColor ? (- <button- type="button"- onClick={() => setData((d) => ({ ...d, markerColor: undefined }))}- className="text-xs text-neutral-400 underline-offset-2 hover:text-neutral-600 hover:underline"- >- Match dot color- </button>- ) : undefined- }- />-<div className="flex items-center justify-end gap-2"><Buttontype="button"@@ -351,18 +329,18 @@ export function SegmentedControl({return (<divclassName={cn(- "relative mt-1 flex h-11 rounded-xl border border-neutral-200 bg-neutral-50 p-1",+ "relative mt-2 flex h-10 rounded-lg bg-neutral-100 p-0.5",disabled && "opacity-50",)}><div- className="pointer-events-none absolute inset-y-1 left-1 rounded-lg bg-white"+ className="pointer-events-none absolute inset-y-0.5 left-0.5 rounded-md bg-white"style={{- width: `calc((100% - 8px) / ${count})`,+ width: `calc((100% - 4px) / ${count})`,transform: `translateX(calc(${activeIndex} * 100%))`,transition: "transform 200ms cubic-bezier(0.23, 1, 0.32, 1)",boxShadow:- "0px 2px 6px 0px rgba(0,0,0,0.10), 0px 0px 2px 0px rgba(0,0,0,0.05)",+ "0px 2px 3px 0px rgba(0,0,0,0.10), 0px 0px 1px 0px rgba(0,0,0,0.05)",}}/>{children}@@ -391,7 +369,7 @@ export function SegmentTab({aria-label={ariaLabel}aria-pressed={active}className={cn(- "relative flex flex-1 items-center justify-center rounded-lg text-neutral-700",+ "relative flex flex-1 items-center justify-center rounded-md px-4 py-2 text-neutral-700",disabled && "cursor-not-allowed",)}>@@ -402,80 +380,36 @@ export function SegmentTab({// ─── Color section ────────────────────────────────────────────────────────────-export function ColorSection({+function ColorSection({id,label,tooltip,color,onChange,- onSwatchClick,- extraAction,}: {id: string;label: string;tooltip?: string;color: string;- onChange: (color: string) => void;- onSwatchClick: (color: string) => void;- extraAction?: React.ReactNode;+ onChange: (color: string | null) => void;}) {return (- <div>- <div className="flex items-center justify-between">- <div className="flex items-center gap-2">- <span className="block text-sm font-medium text-neutral-700">- {label}- </span>- {tooltip && <InfoTooltip content={tooltip} />}- </div>- {extraAction}+ <div className="flex h-10 items-center justify-between gap-2">+ <div className="flex items-center gap-1">+ <label htmlFor={id} className="text-sm font-semibold text-neutral-800">+ {label}+ </label>+ {tooltip && <InfoTooltip content={tooltip} />}</div>- <div className="mt-2 flex gap-6">- <div className="relative flex h-9 w-32 shrink-0 rounded-md shadow-sm">- <Tooltip- content={- <div className="flex max-w-xs flex-col items-center space-y-3 p-5 text-center">- <HexColorPicker color={color} onChange={onChange} />- </div>- }- >- <div- className="h-full w-12 rounded-l-md border"- style={{ backgroundColor: color, borderColor: color }}- />- </Tooltip>- <HexColorInput- id={id}- name={id}- color={color}- onChange={onChange}- prefixed- style={{ borderColor: color }}- className="block w-full rounded-r-md border-2 border-l-0 pl-3 text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-black sm:text-sm"- />- </div>- <div className="mt-1 flex flex-wrap items-center gap-3">- {DEFAULT_COLORS.map((swatch) => {- const isSelected = color === swatch;- return (- <button- key={swatch}- type="button"- aria-pressed={isSelected}- onClick={() => onSwatchClick(swatch)}- className={cn(- "flex size-7 items-center justify-center rounded-full transition-all",- isSelected- ? "ring-1 ring-black ring-offset-[3px]"- : "ring-black/10 hover:ring-4",- )}- style={{ backgroundColor: swatch }}- >- {isSelected && <Check2 className="size-4 text-white" />}- </button>- );- })}- </div>+ <div className="flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-neutral-100">+ <ColorPicker+ id={id}+ value={color}+ onChange={onChange}+ showDefault+ side="top"+ debounceMs={500}+ /></div></div>);@@ -486,8 +420,8 @@ export function ColorSection({export function SquareDotIcon() {return (<svg- width="20"- height="20"+ width="16"+ height="16"viewBox="0 0 20 20"fill="currentColor"aria-hidden="true"@@ -509,8 +443,8 @@ export function SquareDotIcon() {export function RoundedDotIcon() {return (<svg- width="20"- height="20"+ width="16"+ height="16"viewBox="0 0 20 20"fill="currentColor"aria-hidden="true"@@ -532,8 +466,8 @@ export function RoundedDotIcon() {export function ExtraRoundedDotIcon() {return (<svg- width="20"- height="20"+ width="16"+ height="16"viewBox="0 0 20 20"fill="currentColor"aria-hidden="true"@@ -550,8 +484,8 @@ export function ExtraRoundedDotIcon() {export function MarkerCenterSquareIcon() {return (<svg- width="20"- height="20"+ width="16"+ height="16"viewBox="0 0 20 20"fill="none"aria-hidden="true"@@ -562,7 +496,7 @@ export function MarkerCenterSquareIcon() {width="17.5"height="17.5"stroke="currentColor"- strokeOpacity="0.35"+ strokeOpacity="0.5"strokeWidth="2.5"/><rect x="5" y="5" width="10" height="10" fill="currentColor" />@@ -573,8 +507,8 @@ export function MarkerCenterSquareIcon() {export function MarkerCenterCircleIcon() {return (<svg- width="20"- height="20"+ width="16"+ height="16"viewBox="0 0 20 20"fill="none"aria-hidden="true"@@ -585,7 +519,7 @@ export function MarkerCenterCircleIcon() {width="17.5"height="17.5"stroke="currentColor"- strokeOpacity="0.35"+ strokeOpacity="0.5"strokeWidth="2.5"/><path@@ -599,8 +533,8 @@ export function MarkerCenterCircleIcon() {export function MarkerBorderSquareIcon() {return (<svg- width="20"- height="20"+ width="16"+ height="16"viewBox="0 0 20 20"fill="none"aria-hidden="true"@@ -620,8 +554,8 @@ export function MarkerBorderSquareIcon() {export function MarkerBorderRoundedIcon() {return (<svg- width="20"- height="20"+ width="16"+ height="16"viewBox="0 0 20 20"fill="none"aria-hidden="true"@@ -638,8 +572,8 @@ export function MarkerBorderRoundedIcon() {export function MarkerBorderCircleIcon() {return (<svg- width="20"- height="20"+ width="16"+ height="16"viewBox="0 0 20 20"fill="none"aria-hidden="true"diff --git a/apps/web/ui/partners/groups/design/branding-settings-form.tsx b/apps/web/ui/partners/groups/design/branding-settings-form.tsxindex 2c9fa8b3cf..ea755ccebf 100644--- a/apps/web/ui/partners/groups/design/branding-settings-form.tsx+++ b/apps/web/ui/partners/groups/design/branding-settings-form.tsx@@ -2,7 +2,7 @@import { updateGroupBrandingAction } from "@/lib/actions/partners/update-group-branding";import useWorkspace from "@/lib/swr/use-workspace";-import { ProgramColorPicker } from "@/ui/partners/program-color-picker";+import { ColorPicker } from "@/ui/shared/color-picker";import { Button, FileUpload, InfoTooltip } from "@dub/ui";import { Plus } from "@dub/ui/icons";import { cn } from "@dub/utils/src";@@ -145,10 +145,14 @@ export function BrandingSettingsForm() {control={control}name="brandColor"render={({ field }) => (- <ProgramColorPicker- color={field.value}+ <ColorPicker+ value={field.value}onChange={field.onChange}+ showDefault+ side="right"+ align="end"id={id}+ className="size-7"/>)}/>diff --git a/apps/web/ui/partners/groups/group-color-picker.tsx b/apps/web/ui/partners/groups/group-color-picker.tsxdeleted file mode 100644index f47433b280..0000000000--- a/apps/web/ui/partners/groups/group-color-picker.tsx+++ /dev/null@@ -1,111 +0,0 @@-"use client";--import {- getResourceColorData,- RAINBOW_CONIC_GRADIENT,- RESOURCE_COLORS_DATA,-} from "@/ui/colors";-import { Popover, Tooltip } from "@dub/ui";-import { capitalize, cn } from "@dub/utils";-import { useState } from "react";--export function GroupColorPicker({- 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);- };-- const colorClassName = color- ? getResourceColorData(color)?.groupVariants- : undefined;-- return (- <Popover- openPopover={isOpen}- setOpenPopover={setIsOpen}- content={- <div className="flex items-center gap-3 p-2 sm:gap-2">- <div className="sr-only" tabIndex={0}>- Select a color- </div>- <Swatch- name="Rainbow"- colorClassName={null}- onSelect={() => onSelect(null)}- />- {RESOURCE_COLORS_DATA.map(({ color, groupVariants }) => (- <Swatch- key={color}- colorClassName={groupVariants}- name={capitalize(color)!}- onSelect={() => onSelect(color)}- />- ))}- </div>- }- side="bottom"- align="end"- >- <button- id={id}- type="button"- className={cn(- "relative size-5 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",- colorClassName,- )}- >- {!colorClassName && <Rainbow />}- </button>- </Popover>- );-}--function Swatch({- colorClassName,- name,- onSelect,-}: {- colorClassName: 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-7 overflow-hidden rounded-full ring-transparent ring-offset-2 transition-all duration-75 sm:size-5",- "hover:ring-1 hover:ring-[var(--ring-color)]",- "outline-none focus-visible:ring-1 focus-visible:ring-[var(--ring-color)]",- colorClassName,- )}- >- {!colorClassName && <Rainbow />}- </button>- </div>- </Tooltip>- );-}--const Rainbow = () => (- <div- className="absolute -inset-[50%] rounded-full blur-[2px]"- style={{- backgroundImage: RAINBOW_CONIC_GRADIENT,- }}- />-);diff --git a/apps/web/ui/partners/program-color-picker.tsx b/apps/web/ui/partners/program-color-picker.tsxdeleted file mode 100644index 8643cf2b45..0000000000--- a/apps/web/ui/partners/program-color-picker.tsx+++ /dev/null@@ -1,155 +0,0 @@-"use client";--import { RAINBOW_CONIC_GRADIENT } from "@/ui/colors";-import { Popover, Tooltip } from "@dub/ui";-import { cn } from "@dub/utils";-import { CSSProperties, useState } from "react";-import { HexColorInput } from "react-colorful";--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 flex items-center justify-between gap-4">- <Swatch- color={null}- name="Rainbow"- onSelect={() => onSelect(null)}- />- <div className="relative shrink">- <div- className="absolute left-2 top-1/2 size-4 -translate-y-1/2 overflow-hidden rounded-full transition-colors"- style={{- backgroundColor: color ?? undefined,- }}- >- {!color && <Rainbow />}- </div>- <HexColorInput- name="color"- color={color ?? undefined}- onChange={(color) => onChange(color)}- prefixed={!!color}- placeholder="# Default"- style={{}}- size={1}- className="block min-w-32 shrink rounded-md border border-neutral-300 py-1.5 pl-[30px] text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"- />- </div>- </div>- {COLORS.map(({ color, name }) => (- <Swatch- key={color}- color={color}- name={name}- onSelect={() => onSelect(color)}- />- ))}- </div>- }- side="right"- align="end"- >- <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/apps/web/ui/shared/color-picker.tsx b/apps/web/ui/shared/color-picker.tsxnew file mode 100644index 0000000000..ad509ddccb--- /dev/null+++ b/apps/web/ui/shared/color-picker.tsx@@ -0,0 +1,315 @@+"use client";++import { RAINBOW_CONIC_GRADIENT, RESOURCE_COLORS_DATA } from "@/ui/colors";+import { Popover, Tooltip } from "@dub/ui";+import { Check2 } from "@dub/ui/icons";+import { capitalize, cn } from "@dub/utils";+import { ComponentProps, useState } from "react";+import { HexColorInput, HexColorPicker } from "react-colorful";+import { useDebouncedCallback } from "use-debounce";++export type ColorPickerSwatch = {+ // The value passed to onChange when selected (hex code or named color)+ value: string;+ // Tooltip label+ name?: string;+ // Rendered swatch color; falls back to `value`+ hex?: string;+ // Tailwind background class alternative to `hex` (for named colors)+ className?: string;+};++export const COLOR_SWATCHES: ColorPickerSwatch[] = RESOURCE_COLORS_DATA.map(+ ({ color, hex }) => ({+ value: hex,+ name: capitalize(color)!,+ hex,+ }),+);++export const RESOURCE_COLOR_SWATCHES: ColorPickerSwatch[] =+ RESOURCE_COLORS_DATA.map(({ color, groupVariants }) => ({+ value: color,+ name: capitalize(color)!,+ className: groupVariants,+ }));++/**+ * Popover color picker with a circular trigger button.+ *+ * - `variant="full"`: gradient picker + swatches + hex input+ * - `variant="swatches"`: swatches only+ *+ * `showDefault` adds a leading rainbow swatch that selects `null` — callers+ * decide what "default" means (e.g. no brand color, or reset to black).+ */+export function ColorPicker({+ value,+ onChange,+ swatches = COLOR_SWATCHES,+ showDefault = false,+ variant = "full",+ side = "bottom",+ align = "end",+ debounceMs,+ id,+ className,+}: {+ value: string | null;+ onChange: (value: string | null) => void;+ swatches?: ColorPickerSwatch[];+ showDefault?: boolean;+ variant?: "full" | "swatches";+ side?: ComponentProps<typeof Popover>["side"];+ align?: ComponentProps<typeof Popover>["align"];+ debounceMs?: number;+ id?: string;+ className?: string;+}) {+ const [isOpen, setIsOpen] = useState(false);++ const onSelect = (value: string | null) => {+ onChange(value);+ setIsOpen(false);+ };++ const triggerSwatch = value+ ? swatches.find((s) => s.value.toLowerCase() === value.toLowerCase())+ : undefined;+ const triggerHex = triggerSwatch?.className+ ? undefined+ : triggerSwatch?.hex ?? value ?? undefined;++ return (+ <Popover+ openPopover={isOpen}+ setOpenPopover={setIsOpen}+ side={side}+ align={align}+ popoverContentClassName="rounded-2xl"+ // Prevent Radix from refocusing the trigger on close — Chrome treats the+ // programmatic focus as :focus-visible after keyboard input, leaving a+ // stray focus ring on the trigger after picking a color+ onCloseAutoFocus={(e) => e.preventDefault()}+ content={+ <div className="p-4">+ <div className="sr-only" tabIndex={0}>+ Select a color+ </div>+ <ColorSelector+ value={value}+ onChange={onChange}+ onSelect={onSelect}+ swatches={swatches}+ showDefault={showDefault}+ showPicker={variant === "full"}+ showHexInput={variant === "full"}+ debounceMs={debounceMs}+ />+ </div>+ }+ >+ <button+ id={id}+ type="button"+ className={cn(+ "relative size-6 shrink-0 overflow-hidden rounded-full outline-none ring-black/10 transition-all duration-75",+ "shadow-[inset_0_0_0_1px_rgba(0,0,0,0.1)]",+ "hover: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",+ triggerSwatch?.className,+ className,+ )}+ style={triggerHex ? { backgroundColor: triggerHex } : undefined}+ >+ {!value && <Rainbow />}+ </button>+ </Popover>+ );+}++/**+ * The color selector panel body, composable outside the popover+ * (e.g. inline in a modal).+ */+export function ColorSelector({+ value,+ onChange,+ onSelect,+ swatches,+ showDefault = false,+ showPicker = false,+ showHexInput = false,+ debounceMs,+ id,+ className,+}: {+ value: string | null;+ // Continuous changes (gradient drag, hex typing)+ onChange: (value: string | null) => void;+ // Discrete selections (swatch clicks); defaults to onChange+ onSelect?: (value: string | null) => void;+ swatches?: ColorPickerSwatch[];+ showDefault?: boolean;+ showPicker?: boolean;+ showHexInput?: boolean;+ debounceMs?: number;+ id?: string;+ className?: string;+}) {+ const debouncedOnChange = useDebouncedCallback(+ (color: string) => onChange(color),+ debounceMs ?? 0,+ );+ const onPickerChange = debounceMs ? debouncedOnChange : onChange;+ const onSwatchSelect = onSelect ?? onChange;++ const hasSwatches = Boolean(showDefault || swatches?.length);++ return (+ <div className={cn("flex w-[262px] flex-col gap-5", className)}>+ <div className="flex flex-col gap-4">+ {showPicker && (+ <>+ <div+ className={cn(+ // react-colorful's BEM classes contain "__" which breaks+ // Tailwind arbitrary variants, hence the attribute selectors.+ // The hue track's class ends in "last-control"; "$=pointer"+ // matches both drag handles but not their inner pointer-fill.+ "[&_.react-colorful]:h-auto [&_.react-colorful]:w-full [&_.react-colorful]:gap-2.5",+ "[&_[class$=saturation]]:h-[120px] [&_[class$=saturation]]:overflow-hidden [&_[class$=saturation]]:rounded-lg [&_[class$=saturation]]:border-none [&_[class$=saturation]]:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.05)]",+ "[&_[class$=last-control]]:h-2 [&_[class$=last-control]]:rounded-full",+ "[&_[class$=pointer]]:size-3.5 [&_[class$=pointer]]:border-[3px] [&_[class$=pointer]]:border-white [&_[class$=pointer]]:shadow-[0_0_0_2px_rgba(0,0,0,0.15)]",+ )}+ >+ <HexColorPicker+ color={value ?? "#000000"}+ onChange={onPickerChange}+ />+ </div>+ {hasSwatches && <div className="h-px w-full bg-neutral-200" />}+ </>+ )}+ {hasSwatches && (+ <div className="flex flex-wrap gap-2.5">+ {showDefault && (+ <Swatch+ name="Default"+ selected={!value}+ onSelect={() => onSwatchSelect(null)}+ />+ )}+ {swatches?.map((swatch) => (+ <Swatch+ key={swatch.value}+ swatch={swatch}+ name={swatch.name}+ selected={+ !!value && swatch.value.toLowerCase() === value.toLowerCase()+ }+ onSelect={() => onSwatchSelect(swatch.value)}+ />+ ))}+ </div>+ )}+ </div>+ {showHexInput && (+ <HexInputField id={id} value={value} onChange={onPickerChange} />+ )}+ </div>+ );+}++function Swatch({+ swatch,+ name,+ selected,+ onSelect,+}: {+ // Undefined renders the rainbow "default" swatch+ swatch?: ColorPickerSwatch;+ name?: string;+ selected: boolean;+ onSelect: () => void;+}) {+ const button = (+ <button+ type="button"+ onClick={onSelect}+ aria-pressed={selected}+ className={cn(+ "relative flex size-6 items-center justify-center overflow-hidden rounded-full transition-all duration-75",+ "outline-none ring-black/10 hover:ring-4 focus-visible:ring-1 focus-visible:ring-black/40 focus-visible:ring-offset-2",+ swatch?.className,+ )}+ style={+ swatch && !swatch.className+ ? { backgroundColor: swatch.hex ?? swatch.value }+ : undefined+ }+ >+ {!swatch && <Rainbow />}+ {selected && (+ // Check2's path is filled, not stroked — stroking it in currentColor+ // is what thickens the check mark+ <Check2 className="relative size-3.5 stroke-current stroke-[1.5] text-white" />+ )}+ </button>+ );++ return name ? (+ <Tooltip content={name} delayDuration={1000} disableHoverableContent>+ <div className="w-fit rounded-full">{button}</div>+ </Tooltip>+ ) : (+ button+ );+}++export function HexInputField({+ value,+ onChange,+ id,+ className,+}: {+ value: string | null;+ onChange: (color: string) => void;+ id?: string;+ className?: string;+}) {+ return (+ <div+ className={cn(+ "flex h-10 w-full items-center gap-2.5 rounded-lg border border-neutral-200 bg-white px-3",+ "transition-colors focus-within:border-neutral-500",+ className,+ )}+ >+ <div+ className="relative size-4 shrink-0 overflow-hidden rounded-full shadow-[inset_0_0_0_1px_rgba(0,0,0,0.1)]"+ style={value ? { backgroundColor: value } : undefined}+ >+ {!value && <Rainbow />}+ </div>+ <div className="flex min-w-0 grow items-center gap-1 text-sm">+ <span className="text-neutral-400">#</span>+ <HexColorInput+ id={id}+ name={id}+ color={value ?? undefined}+ onChange={onChange}+ placeholder="Default"+ className="w-full min-w-0 border-none bg-transparent p-0 text-sm text-neutral-800 placeholder-neutral-400 outline-none focus:ring-0"+ />+ </div>+ </div>+ );+}++const Rainbow = () => (+ <div+ className="absolute -inset-1/2 rounded-full blur-[2px]"+ style={{ backgroundImage: RAINBOW_CONIC_GRADIENT }}+ />+);