Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add `OnlinePresenceCard` + use it on partner sheets

Tim Wilsonfce694238fbf
diff --git a/apps/web/ui/partners/online-presence-card.tsx b/apps/web/ui/partners/online-presence-card.tsx
new file mode 100644
index 0000000000..7717e8090a
--- /dev/null
+++ b/apps/web/ui/partners/online-presence-card.tsx
@@ -0,0 +1,92 @@
+import {
+ ArrowUpRight,
+ BadgeCheck2Fill,
+ Button,
+ Icon,
+ Tooltip,
+ Trash,
+} from "@dub/ui";
+import { cn } from "@dub/utils";
+import { PropsWithChildren } from "react";
+
+export function OnlinePresenceCard({
+ icon: Icon,
+ prefix,
+ value,
+ verified,
+ info,
+ href,
+ onRemove,
+}: {
+ icon: Icon;
+ prefix?: string;
+ value: string;
+ verified?: boolean;
+ info?: string[];
+ href?: string;
+ onRemove?: () => void;
+}) {
+ return (
+ <Container
+ href={href}
+ className={cn(
+ "border-subtle group flex items-center justify-between gap-3 rounded-lg border bg-white p-3",
+ href && "transition-colors hover:bg-neutral-50 active:bg-neutral-100",
+ )}
+ >
+ <div className="flex min-w-0 items-center gap-3">
+ <div className="border-subtle flex size-8 shrink-0 items-center justify-center rounded-full border">
+ <Icon className="size-4" />
+ </div>
+ <div className="flex min-w-0 flex-col text-xs">
+ <div className="flex items-center gap-1">
+ <span className="text-content-emphasis block min-w-0 truncate font-semibold">
+ {prefix}
+ {value}
+ </span>
+ {verified && (
+ <Tooltip content="Verified" disableHoverableContent>
+ <div className="shrink-0">
+ <BadgeCheck2Fill className="size-3.5 text-green-600" />
+ </div>
+ </Tooltip>
+ )}
+ </div>
+ {info && info.length > 0 && (
+ <div className="text-content-subtle min-w-0 truncate font-medium">
+ {info.join(" • ")}
+ </div>
+ )}
+ </div>
+ </div>
+ {href ? (
+ <ArrowUpRight className="text-content-subtle mr-1 size-4 -translate-x-0.5 translate-y-0.5 opacity-0 transition-[opacity,transform] group-hover:translate-x-0 group-hover:translate-y-0 group-hover:opacity-100" />
+ ) : (
+ onRemove && (
+ <div className="flex items-center gap-2">
+ <Button
+ variant="outline"
+ icon={<Trash className="size-4" />}
+ className="text-content-subtle hover:text-content-default size-8 p-0"
+ onClick={onRemove}
+ />
+ </div>
+ )
+ )}
+ </Container>
+ );
+}
+
+const Container = ({
+ href,
+ children,
+ ...rest
+}: PropsWithChildren<{ href?: string; className?: string }>) => {
+ return href ? (
+ <a href={href} target="_blank" rel="noopener noreferrer" {...rest}>
+ {children}
+ </a>
+ ) : (
+ <div {...rest}>{children}</div>
+ );
+};
diff --git a/apps/web/ui/partners/online-presence-form.tsx b/apps/web/ui/partners/online-presence-form.tsx
index cb84b23f60..a055e67d21 100644
--- a/apps/web/ui/partners/online-presence-form.tsx
+++ b/apps/web/ui/partners/online-presence-form.tsx
@@ -12,7 +12,6 @@ import { parseUrlSchemaAllowEmpty } from "@/lib/zod/schemas/utils";
import { DomainVerificationModal } from "@/ui/modals/domain-verification-modal";
import {
AnimatedSizeContainer,
- BadgeCheck2Fill,
Button,
CircleCheckFill,
Globe,
@@ -20,7 +19,6 @@ import {
Instagram,
LinkedIn,
TikTok,
- Trash,
Twitter,
YouTube,
} from "@dub/ui";
@@ -38,6 +36,7 @@ import {
import { toast } from "sonner";
import { mutate } from "swr";
import { z } from "zod";
+import { OnlinePresenceCard } from "./online-presence-card";
const onlinePresenceSchema = z.object({
website: parseUrlSchemaAllowEmpty().optional(),
@@ -551,7 +550,7 @@ function FormRow({
partner.youtubeViewCount > 0
? `${nFormatter(partner.youtubeViewCount)} views`
: null,
- ].filter(Boolean);
+ ].filter(Boolean) as string[];
}
return null;
}, [partner, property, isVerified]);
@@ -569,37 +568,14 @@ function FormRow({
<span className="text-content-emphasis text-sm font-medium">
{label}
</span>
- <div className="border-subtle flex items-center justify-between rounded-lg border bg-white p-3">
- <div className="flex items-center gap-3">
- <div className="border-subtle flex size-8 items-center justify-center rounded-full border">
- <Icon className="size-4" />
- </div>
- <div className="flex flex-col text-xs">
- <div className="flex items-center gap-1">
- <span className="text-content-emphasis block font-semibold">
- {prefix}
- {value}
- </span>
- <BadgeCheck2Fill className="size-3.5 text-green-600" />
- </div>
- {info && info.length > 0 && (
- <div className="text-content-subtle font-medium">
- {info.join(" • ")}
- </div>
- )}
- </div>
- </div>
- <div className="flex items-center gap-2">
- <Button
- variant="outline"
- icon={<Trash className="size-4" />}
- className="text-content-subtle hover:text-content-default size-8 p-0"
- onClick={() => {
- setValue(property, "", { shouldDirty: true });
- }}
- />
- </div>
- </div>
+ <OnlinePresenceCard
+ icon={Icon}
+ prefix={prefix}
+ value={value ?? ""}
+ verified
+ info={info ?? undefined}
+ onRemove={() => setValue(property, "", { shouldDirty: true })}
+ />
</div>
) : (
<label className={cn("flex flex-col gap-1.5")}>
diff --git a/apps/web/ui/partners/online-presence-summary.tsx b/apps/web/ui/partners/online-presence-summary.tsx
index d7708587b0..282fd62bb7 100644
--- a/apps/web/ui/partners/online-presence-summary.tsx
+++ b/apps/web/ui/partners/online-presence-summary.tsx
@@ -1,8 +1,5 @@
import { EnrolledPartnerProps } from "@/lib/types";
-import { Tooltip } from "@dub/ui";
import {
- ArrowUpRight,
- BadgeCheck2Fill,
Globe,
Icon,
Instagram,
@@ -13,6 +10,7 @@ import {
} from "@dub/ui/icons";
import { cn, getPrettyUrl, nFormatter } from "@dub/utils";
import { Fragment } from "react";
+import { OnlinePresenceCard } from "./online-presence-card";
const fields: {
label: string;
@@ -115,36 +113,13 @@ export function OnlinePresenceSummary({
<Fragment key={label}>
<span className="text-content-default font-medium">{label}</span>
<div>
- <a
- target="_blank"
- href={href!}
- rel="noopener noreferrer"
- className="border-border-subtle group flex max-w-full items-center justify-between gap-4 rounded-lg border p-3 text-neutral-600 transition-colors hover:bg-neutral-50 active:bg-neutral-100"
- >
- <div className="flex items-center gap-3">
- <div className="border-border-subtle text-content-default flex size-8 items-center justify-center rounded-full border bg-white">
- <Icon className="size-4" />
- </div>
- <div>
- <div className="flex items-center gap-1">
- <span className="min-w-0 truncate">{value}</span>
- {verified && (
- <Tooltip content="Verified" disableHoverableContent>
- <div>
- <BadgeCheck2Fill className="size-4 text-green-600" />
- </div>
- </Tooltip>
- )}
- </div>
- {info && info.length > 0 && (
- <div className="text-content-subtle text-xs">
- {info.join(" • ")}
- </div>
- )}
- </div>
- </div>
- <ArrowUpRight className="text-content-subtle mr-1 size-4 -translate-x-0.5 translate-y-0.5 opacity-0 transition-[opacity,transform] group-hover:translate-x-0 group-hover:translate-y-0 group-hover:opacity-100" />
- </a>
+ <OnlinePresenceCard
+ icon={Icon}
+ value={value ?? ""}
+ verified={verified}
+ info={info}
+ href={href ?? undefined}
+ />
</div>
</Fragment>
);
diff --git a/apps/web/ui/partners/partner-profile-sheet.tsx b/apps/web/ui/partners/partner-profile-sheet.tsx
index d24cb8319e..349fa8f21e 100644
--- a/apps/web/ui/partners/partner-profile-sheet.tsx
+++ b/apps/web/ui/partners/partner-profile-sheet.tsx
@@ -98,7 +98,7 @@ function PartnerProfileSheetContent({
<h4 className="font-semibold text-neutral-900">
Online presence
</h4>
- <OnlinePresenceSummary partner={partner} className="mt-2" />
+ <OnlinePresenceSummary partner={partner} className="mt-3" />
</div>
</div>
</div>