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.

make interactive true by default, improve timestamp copy UX

Steven Teyc65cbbfaed0b
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
index f9281a7525..df503af581 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
@@ -83,7 +83,6 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
timestamp={row.original.createdAt}
side="right"
rows={["local"]}
- interactive
>
<span>{formatDateTimeSmart(row.original.createdAt)}</span>
</TimestampTooltip>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/campaign-events-columns.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/campaign-events-columns.tsx
index 80f6aea2eb..6f6b7d50bd 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/campaign-events-columns.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/campaign-events-columns.tsx
@@ -49,7 +49,6 @@ export const campaignEventsColumns = [
timestamp={timestamp}
side="top"
rows={["local", "utc", "unix"]}
- interactive
>
<div
className="text-content-subtle flex h-8 shrink-0 items-center justify-end text-xs font-medium"
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx
index 0822b98d12..e25e104695 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx
@@ -95,7 +95,6 @@ const CommissionTableInner = memo(
side="right"
rows={["local", "utc", "unix"]}
delayDuration={150}
- interactive
>
<p>{formatDateTimeSmart(row.original.createdAt)}</p>
</TimestampTooltip>
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index 9d9b36896d..bcfdd58f62 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -189,7 +189,6 @@ export default function EventsTable({
timestamp={getValue()}
side="right"
rows={["local", "utc", "unix"]}
- interactive
>
<span className="select-none truncate">
{formatDateTimeSmart(getValue())}
diff --git a/apps/web/ui/customers/customer-activity-list.tsx b/apps/web/ui/customers/customer-activity-list.tsx
index 16d393ef6c..5fdf629cb8 100644
--- a/apps/web/ui/customers/customer-activity-list.tsx
+++ b/apps/web/ui/customers/customer-activity-list.tsx
@@ -140,7 +140,6 @@ export function CustomerActivityList({
timestamp={event.timestamp}
side="right"
rows={["local", "utc", "unix"]}
- interactive
>
<span className="shrink-0 truncate text-sm text-neutral-500">
{formatDateTimeSmart(event.timestamp)}
diff --git a/apps/web/ui/customers/customer-sales-table.tsx b/apps/web/ui/customers/customer-sales-table.tsx
index 15ccb314e9..438220e644 100644
--- a/apps/web/ui/customers/customer-sales-table.tsx
+++ b/apps/web/ui/customers/customer-sales-table.tsx
@@ -42,7 +42,6 @@ export function CustomerSalesTable({
timestamp={getValue()}
side="right"
rows={["local", "utc", "unix"]}
- interactive
>
<span>{formatDateTimeSmart(getValue())}</span>
</TimestampTooltip>
diff --git a/apps/web/ui/links/link-builder/link-creator-info.tsx b/apps/web/ui/links/link-builder/link-creator-info.tsx
index 6f833760f0..986ecfb8f0 100644
--- a/apps/web/ui/links/link-builder/link-creator-info.tsx
+++ b/apps/web/ui/links/link-builder/link-creator-info.tsx
@@ -32,7 +32,6 @@ export function LinkCreatorInfo({ link }: { link: ExpandedLinkProps }) {
timestamp={link.createdAt}
rows={["local", "utc", "unix"]}
delayDuration={150}
- interactive
>
<span className="select-none">{timeAgo(link.createdAt)}</span>
</TimestampTooltip>
diff --git a/packages/ui/src/timestamp-tooltip.tsx b/packages/ui/src/timestamp-tooltip.tsx
index d64cd3c53c..e526945c2a 100644
--- a/packages/ui/src/timestamp-tooltip.tsx
+++ b/packages/ui/src/timestamp-tooltip.tsx
@@ -28,7 +28,7 @@ function getLocalTimeZone(): string {
export function TimestampTooltip({
timestamp,
rows,
- interactive,
+ interactive = true,
...tooltipProps
}: TimestampTooltipProps) {
if (!timestamp || new Date(timestamp).toString() === "Invalid Date")
@@ -52,7 +52,7 @@ export function TimestampTooltip({
function TimestampTooltipContent({
timestamp,
rows = ["local", "utc"],
- interactive = false,
+ interactive,
}: Pick<TimestampTooltipProps, "timestamp" | "rows" | "interactive">) {
if (!timestamp)
throw new Error("Falsy timestamp not permitted in TimestampTooltipContent");
@@ -95,6 +95,7 @@ function TimestampTooltipContent({
const items: {
label: string;
shortLabel?: string;
+ successMessageLabel: string;
value: string;
valueMono?: boolean;
}[] = useMemo(
@@ -107,12 +108,14 @@ function TimestampTooltipContent({
shortLabel: new Date()
.toLocaleTimeString("en-US", { timeZoneName: "short" })
.split(" ")[2],
+ successMessageLabel: "local timestamp",
value: date.toLocaleString("en-US", commonFormat),
},
utc: {
label: "UTC",
shortLabel: "UTC",
+ successMessageLabel: "UTC timestamp",
value: new Date(date.getTime()).toLocaleString("en-US", {
...commonFormat,
timeZone: "UTC",
@@ -121,6 +124,7 @@ function TimestampTooltipContent({
unix: {
label: "UNIX Timestamp",
+ successMessageLabel: "UNIX timestamp",
value: (date.getTime() / 1000).toString(),
valueMono: true,
},
@@ -149,17 +153,24 @@ function TimestampTooltipContent({
key={idx}
className={cn(
interactive &&
- "before:bg-bg-emphasis relative select-none before:absolute before:-inset-x-1 before:inset-y-0 before:rounded before:opacity-0 before:content-[''] hover:cursor-pointer hover:before:opacity-60 active:before:opacity-100",
+ "before:bg-bg-emphasis relative select-none before:absolute before:-inset-x-1 before:inset-y-0 before:rounded before:opacity-0 before:content-[''] hover:cursor-copy hover:before:opacity-60 active:before:opacity-100",
)}
onClick={
interactive
? async () => {
try {
await navigator.clipboard.writeText(row.value);
- toast.success("Copied to clipboard");
+ toast.success(
+ `Copied ${row.successMessageLabel} to clipboard`,
+ );
} catch (e) {
- toast.error("Failed to copy to clipboard");
- console.error("Failed to copy to clipboard", e);
+ toast.error(
+ `Failed to copy ${row.successMessageLabel} to clipboard`,
+ );
+ console.error(
+ `Failed to copy ${row.successMessageLabel} to clipboard`,
+ e,
+ );
}
}
: undefined