The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add link settings badge/tooltip
Tim Wilsone0bf45765372
diff --git a/apps/web/ui/links/link-title-column.tsx b/apps/web/ui/links/link-title-column.tsxindex 8c29afc688..1650d6d4d0 100644--- a/apps/web/ui/links/link-title-column.tsx+++ b/apps/web/ui/links/link-title-column.tsx@@ -8,12 +8,24 @@ import {CardList,CopyButton,LinkLogo,+ Switch,Tooltip,TooltipContent,useIntersectionObserver,useMediaQuery,} from "@dub/ui";-import { ArrowRight, Page2 } from "@dub/ui/src/icons";+import {+ Apple,+ ArrowRight,+ Bolt,+ Cards,+ CircleHalfDottedClock,+ EarthPosition,+ EyeSlash,+ InputPassword,+ Page2,+ Robot,+} from "@dub/ui/src/icons";import {cn,fetcher,@@ -26,8 +38,19 @@ import { AnimatePresence, motion } from "framer-motion";import { Mail } from "lucide-react";import { PropsWithChildren, useContext, useRef } from "react";import useSWR from "swr";+import { useAddEditLinkModal } from "../modals/add-edit-link-modal";import { ResponseLink } from "./links-container";+const quickViewSettings = [+ { label: "Custom Social Media Cards", icon: Cards, key: "proxy" },+ { label: "Link Cloaking", icon: EyeSlash, key: "rewrite" },+ { label: "Password Protection", icon: InputPassword, key: "password" },+ { label: "Link Expiration", icon: CircleHalfDottedClock, key: "expiresAt" },+ { label: "iOS Targeting", icon: Apple, key: "ios" },+ { label: "Android Targeting", icon: Robot, key: "android" },+ { label: "Geo Targeting", icon: EarthPosition, key: "geo" },+];+export function LinkTitleColumn({ link }: { link: ResponseLink }) {const { url, domain } = link;const path = link.key === "_root" ? "" : `/${link.key}`;@@ -42,6 +65,8 @@ export function LinkTitleColumn({ link }: { link: ResponseLink }) {const entry = useIntersectionObserver(ref, {});const isVisible = !!entry?.isIntersecting;+ const hasQuickViewSettings = quickViewSettings.some(({ key }) => link?.[key]);+return (<divref={ref}@@ -65,11 +90,13 @@ export function LinkTitleColumn({ link }: { link: ResponseLink }) {<div className="flex items-center gap-2"><div className="min-w-0 text-gray-950"><UnverifiedTooltip link={link}>- <span- className="flex items-center font-medium"- title={`${domain}${path}`}- >- <span className="truncate leading-6">{domain + path}</span>+ <div className="flex items-center font-medium">+ <span+ title={`${domain}${path}`}+ className="truncate leading-6"+ >+ {domain + path}+ </span><AnimatePresence>{(hovered || isMobile) && (@@ -90,6 +117,9 @@ export function LinkTitleColumn({ link }: { link: ResponseLink }) {className="-mt-px ml-1 flex translate-y-px items-center justify-end gap-1 overflow-visible [mask-image:linear-gradient(to_right,transparent,black_4px)]"><div className="w-0" /> {/* Spacer for masking */}+ {hasQuickViewSettings && (+ <SettingsBadge link={link} />+ )}{link.comments && (<CommentsBadge comments={link.comments} />)}@@ -101,7 +131,7 @@ export function LinkTitleColumn({ link }: { link: ResponseLink }) {</motion.div>)}</AnimatePresence>- </span>+ </div></UnverifiedTooltip></div><Details link={link} compact />@@ -145,6 +175,48 @@ function UnverifiedTooltip({);}+function SettingsBadge({ link }: { link: ResponseLink }) {+ const settings = quickViewSettings.filter(({ key }) => link?.[key]);++ const { AddEditLinkModal, setShowAddEditLinkModal } = useAddEditLinkModal({+ props: link,+ });++ return (+ <div className="hidden sm:block">+ <AddEditLinkModal />+ <Tooltip+ content={({ setOpen }) => (+ <div className="flex w-[340px] flex-col p-3 text-sm">+ {settings.map(({ label, icon: Icon }) => (+ <button+ key={label}+ type="button"+ onClick={() => {+ setOpen(false);+ setShowAddEditLinkModal(true);+ }}+ className="flex items-center justify-between gap-4 rounded-lg p-3 transition-colors hover:bg-gray-100"+ >+ <div className="flex items-center gap-3">+ <Icon className="h-4 w-4 text-gray-600" />+ <span className="text-gray-950">{label}</span>+ </div>+ <Switch checked />+ </button>+ ))}+ </div>+ )}+ side="bottom"+ >+ <div className="rounded-full bg-gray-100 p-1 hover:bg-gray-200">+ <Bolt className="h-3.5 w-3.5" />+ </div>+ </Tooltip>+ </div>+ );+}+function CommentsBadge({ comments }: { comments: string }) {return (<div className="hidden sm:block">diff --git a/packages/ui/src/icons/nucleo/apple.tsx b/packages/ui/src/icons/nucleo/apple.tsxnew file mode 100644index 0000000000..e630c6b91c--- /dev/null+++ b/packages/ui/src/icons/nucleo/apple.tsx@@ -0,0 +1,29 @@+import { SVGProps } from "react";++export function Apple(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="18"+ width="18"+ viewBox="0 0 18 18"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <path+ d="M13.964,5.405c-1.595-1.267-3.391-.223-4.909-.223s-3.131-1.107-4.909,.223-1.95,4.687,.025,7.801c1.895,2.989,3.805,1.817,4.886,1.817s2.992,1.174,4.886-1.817c1.973-3.114,1.489-6.639,.021-7.801Z"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <path+ d="M11.5,.25h0c.276,0,.5,.224,.5,.5h0c0,1.38-1.12,2.5-2.5,2.5h0c-.276,0-.5-.224-.5-.5h0c0-1.38,1.12-2.5,2.5-2.5Z"+ fill="currentColor"+ stroke="none"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/icons/nucleo/bolt.tsx b/packages/ui/src/icons/nucleo/bolt.tsxnew file mode 100644index 0000000000..bdc2b19bde--- /dev/null+++ b/packages/ui/src/icons/nucleo/bolt.tsx@@ -0,0 +1,24 @@+import { SVGProps } from "react";++export function Bolt(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="18"+ width="18"+ viewBox="0 0 18 18"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <path+ d="m8.597,16.41l5.872-8.265c.118-.166,0-.395-.204-.395h-5.016l.604-5.98c.037-.26-.299-.394-.451-.18L3.531,9.855c-.118.166,0,.395.204.395h5.016l-.604,5.98c-.037.26.299.394.451.18Z"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/icons/nucleo/cards.tsx b/packages/ui/src/icons/nucleo/cards.tsxnew file mode 100644index 0000000000..86efa7e0cf--- /dev/null+++ b/packages/ui/src/icons/nucleo/cards.tsx@@ -0,0 +1,37 @@+import { SVGProps } from "react";++export function Cards(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="18"+ width="18"+ viewBox="0 0 18 18"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <rect+ height="10.5"+ width="8.5"+ fill="none"+ rx="1"+ ry="1"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x="1.75"+ y="1.75"+ />+ <path+ d="M13,5.258l2.283,.6c.534,.141,.853,.688,.712,1.222l-2.292,8.703c-.141,.534-.688,.853-1.222,.712l-6.491-1.71"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/icons/nucleo/earth-position.tsx b/packages/ui/src/icons/nucleo/earth-position.tsxnew file mode 100644index 0000000000..b097502627--- /dev/null+++ b/packages/ui/src/icons/nucleo/earth-position.tsx@@ -0,0 +1,69 @@+import { SVGProps } from "react";++export function EarthPosition(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="18"+ width="18"+ viewBox="0 0 18 18"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <path+ d="M5.771,9.887c-.044-.065-.855-1.323-.24-2.575,.067-.137,.484-.949,1.344-1.188,1.273-.353,2.203,.919,2.805,.535,.243-.155,.275-.478,.254-.873"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <path+ d="M5.771,9.887c1.589-.439,2.611-.224,3.292,.175,.939,.55,1.006,1.318,1.812,1.469,1.163,.218,1.844-1.227,2.875-1.031,.479,.091,1.062,.542,1.568,2.057"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <path+ d="M8.601,16.23c.148-.579,.234-1.343-.163-1.938-.423-.635-1.021-.517-1.422-1.182-.418-.694,.014-1.185-.297-2.047-.292-.809-.961-1.174-1.463-1.541-.836-.611-1.874-1.711-2.688-3.859"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <path+ d="M15.792,6.459c.296,.791,.458,1.647,.458,2.541,0,4.004-3.246,7.25-7.25,7.25S1.75,13.004,1.75,9C1.75,5.042,4.922,1.825,8.862,1.751"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <circle+ cx="13.25"+ cy="2.75"+ fill="none"+ r="2"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <line+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x1="13.25"+ x2="13.25"+ y1="4.75"+ y2="7.25"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/icons/nucleo/eye-slash.tsx b/packages/ui/src/icons/nucleo/eye-slash.tsxnew file mode 100644index 0000000000..31b2f7cb5b--- /dev/null+++ b/packages/ui/src/icons/nucleo/eye-slash.tsx@@ -0,0 +1,59 @@+import { SVGProps } from "react";++export function EyeSlash(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="18"+ width="18"+ viewBox="0 0 18 18"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <path+ d="M14.938,6.597c.401,.45,.725,.891,.974,1.27,.45,.683,.45,1.582,0,2.265-1.018,1.543-3.262,4.118-6.912,4.118-.549,0-1.066-.058-1.552-.162"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <path+ d="M4.956,13.044c-1.356-.876-2.302-2.053-2.868-2.912-.45-.683-.45-1.582,0-2.265,1.018-1.543,3.262-4.118,6.912-4.118,1.62,0,2.963,.507,4.044,1.206"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <path+ d="M11.579,9.956c-.278,.75-.873,1.345-1.623,1.623"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <path+ d="M7.055,10.945c-.498-.498-.805-1.185-.805-1.945,0-1.519,1.231-2.75,2.75-2.75,.759,0,1.447,.308,1.945,.805"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <line+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x1="2"+ x2="16"+ y1="16"+ y2="2"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.tsindex a71029eb34..6d348ebe76 100644--- a/packages/ui/src/icons/nucleo/index.ts+++ b/packages/ui/src/icons/nucleo/index.ts@@ -1,10 +1,13 @@+export * from "./apple";export * from "./arrow-right";export * from "./arrow-turn-right2";export * from "./arrows-opposite-direction-y";export * from "./blog";+export * from "./bolt";export * from "./book2";export * from "./box-archive";export * from "./bullet-list";+export * from "./cards";export * from "./chart-line";export * from "./circle-check";export * from "./circle-half-dotted-clock";@@ -18,6 +21,8 @@ export * from "./cube";export * from "./cursor-rays";export * from "./desktop";export * from "./download";+export * from "./earth-position";+export * from "./eye-slash";export * from "./filter-bars";export * from "./flag-wavy";export * from "./flag2";@@ -30,6 +35,7 @@ export * from "./grid-layout-rows";export * from "./headset";export * from "./hexadecagon-star";export * from "./hyperlink";+export * from "./input-password";export * from "./invoice-dollar";export * from "./key";export * from "./lines-y";@@ -43,6 +49,7 @@ export * from "./qrcode";export * from "./receipt2";export * from "./referred-via";export * from "./refresh2";+export * from "./robot";export * from "./shield-check";export * from "./sliders";export * from "./stars2";diff --git a/packages/ui/src/icons/nucleo/input-password.tsx b/packages/ui/src/icons/nucleo/input-password.tsxnew file mode 100644index 0000000000..082e898abd--- /dev/null+++ b/packages/ui/src/icons/nucleo/input-password.tsx@@ -0,0 +1,47 @@+import { SVGProps } from "react";++export function InputPassword(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="18"+ width="18"+ viewBox="0 0 18 18"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <path+ d="M7.75,13.25H3.75c-1.105,0-2-.895-2-2V6.75c0-1.105,.895-2,2-2H14.25c1.105,0,2,.895,2,2v.25"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <path+ d="M12.25,12.25v-2c0-.828,.672-1.5,1.5-1.5h0c.828,0,1.5,.672,1.5,1.5v2"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <circle cx="5.5" cy="9" fill="currentColor" r="1" stroke="none" />+ <circle cx="9" cy="9" fill="currentColor" r="1" stroke="none" />+ <rect+ height="4"+ width="6"+ fill="none"+ rx="1"+ ry="1"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x="10.75"+ y="12.25"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/icons/nucleo/robot.tsx b/packages/ui/src/icons/nucleo/robot.tsxnew file mode 100644index 0000000000..ec5f6fd3c6--- /dev/null+++ b/packages/ui/src/icons/nucleo/robot.tsx@@ -0,0 +1,43 @@+import { SVGProps } from "react";++export function Robot(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="18"+ width="18"+ viewBox="0 0 18 18"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <path+ d="M15.25 6.75V14.25C15.25 15.355 14.355 16.25 13.25 16.25H3.75C2.645 16.25 1.75 15.355 1.75 14.25V8.75C1.75 7.645 2.645 6.75 3.75 6.75H15.25Z"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ <path+ d="M7.5,12h2c.276,0,.5,.224,.5,.5h0c0,.828-.672,1.5-1.5,1.5h0c-.828,0-1.5-.672-1.5-1.5h0c0-.276,.224-.5,.5-.5Z"+ fill="currentColor"+ stroke="none"+ />+ <circle cx="5.5" cy="11" fill="currentColor" r="1" stroke="none" />+ <circle cx="11.5" cy="11" fill="currentColor" r="1" stroke="none" />+ <circle cx="5.25" cy="2.5" fill="currentColor" r="1.5" stroke="none" />+ <line+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x1="5.25"+ x2="5.25"+ y1="3.75"+ y2="6.75"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/tooltip.tsx b/packages/ui/src/tooltip.tsxindex 53f733ac7c..c2f628bab0 100644--- a/packages/ui/src/tooltip.tsx+++ b/packages/ui/src/tooltip.tsx@@ -19,7 +19,10 @@ export function TooltipProvider({ children }: { children: ReactNode }) {export interface TooltipProps {children: ReactNode;- content: ReactNode | string;+ content:+ | ReactNode+ | string+ | ((props: { setOpen: (open: boolean) => void }) => ReactNode);side?: "top" | "bottom" | "left" | "right";}@@ -27,7 +30,7 @@ export function Tooltip({ children, content, side = "top" }: TooltipProps) {const [open, setOpen] = useState(false);return (- <TooltipPrimitive.Root open={open} onOpenChange={setOpen}>+ <TooltipPrimitive.Root open={open} onOpenChange={setOpen} delayDuration={0}><TooltipPrimitive.TriggerasChildonClick={() => {@@ -44,11 +47,14 @@ export function Tooltip({ children, content, side = "top" }: TooltipProps) {sideOffset={8}side={side}className="animate-slide-up-fade z-[99] items-center overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm"+ collisionPadding={0}>{typeof content === "string" ? (<span className="block max-w-xs text-pretty px-4 py-2 text-center text-sm text-gray-700">{content}</span>+ ) : typeof content === "function" ? (+ content({ setOpen })) : (content)}