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.

Improve performance

Tim Wilson851752e92484
diff --git a/apps/web/ui/links/link-controls.tsx b/apps/web/ui/links/link-controls.tsx
index 5cee2edfae..8131985078 100644
--- a/apps/web/ui/links/link-controls.tsx
+++ b/apps/web/ui/links/link-controls.tsx
@@ -8,13 +8,12 @@ import {
PenWriting,
Popover,
SimpleTooltipContent,
- useIntersectionObserver,
} from "@dub/ui";
import { CircleCheck, Copy, QRCode } from "@dub/ui/src/icons";
import { cn, isDubDomain, nanoid, punycode } from "@dub/utils";
import { Archive, CopyPlus, Delete, FolderInput } from "lucide-react";
import { useParams } from "next/navigation";
-import { useRef, useState } from "react";
+import { useState } from "react";
import { toast } from "sonner";
import { mutate } from "swr";
import { useTransferLinkModal } from "../modals/transfer-link-modal";
@@ -24,10 +23,6 @@ import { ResponseLink } from "./links-container";
export function LinkControls({ link }: { link: ResponseLink }) {
const { slug } = useParams() as { slug?: string };
- const ref = useRef<HTMLDivElement>(null);
- const entry = useIntersectionObserver(ref, {});
- const isVisible = !!entry?.isIntersecting;
-
const [openPopover, setOpenPopover] = useState(false);
const [copiedLinkId, setCopiedLinkId] = useState(false);
@@ -75,7 +70,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {
});
return (
- <div ref={ref} className="flex justify-end sm:w-[124px]">
+ <div className="flex justify-end sm:w-[124px]">
<div
className={cn(
"flex items-center justify-end divide-x divide-gray-200 overflow-hidden rounded-md border border-gray-200",
@@ -83,16 +78,12 @@ export function LinkControls({ link }: { link: ResponseLink }) {
"w-[30px] transition-[width] duration-300 sm:w-[43px] sm:group-hover/row:w-[124px]",
)}
>
- {isVisible && (
- <>
- <LinkQRModal />
- <AddEditLinkModal />
- <DuplicateLinkModal />
- <ArchiveLinkModal />
- <TransferLinkModal />
- <DeleteLinkModal />
- </>
- )}
+ <LinkQRModal />
+ <AddEditLinkModal />
+ <DuplicateLinkModal />
+ <ArchiveLinkModal />
+ <TransferLinkModal />
+ <DeleteLinkModal />
<Button
icon={<PenWriting className={cn("h-4 w-4 shrink-0")} />}
variant="outline"
diff --git a/apps/web/ui/links/link-details-column.tsx b/apps/web/ui/links/link-details-column.tsx
index 4cff4f6d6f..fa39133e32 100644
--- a/apps/web/ui/links/link-details-column.tsx
+++ b/apps/web/ui/links/link-details-column.tsx
@@ -42,55 +42,66 @@ export function LinkDetailsColumn({ link }: { link: ResponseLink }) {
return (
<div ref={ref} className="flex items-center justify-end gap-2 sm:gap-5">
- {primaryTag && (
- <Tooltip
- content={
- <div className="flex flex-wrap gap-1.5 p-3">
- {tags.map((tag) => (
- <TagBadge key={tag.id} {...tag} />
+ {isVisible && (
+ <>
+ {primaryTag && (
+ <Tooltip
+ content={
+ <div className="flex flex-wrap gap-1.5 p-3">
+ {tags.map((tag) => (
+ <TagBadge key={tag.id} {...tag} />
+ ))}
+ </div>
+ }
+ side="bottom"
+ >
+ <div className="cursor-default transition-transform hover:scale-105">
+ <TagBadge
+ withIcon
+ {...primaryTag}
+ plus={additionalTags.length}
+ />
+ </div>
+ </Tooltip>
+ )}
+ <Link
+ href={`/${slug}/analytics?domain=${domain}&key=${key}`}
+ className="rounded-md bg-gray-100 px-2 py-0.5 text-sm text-gray-950 transition-colors hover:bg-gray-200"
+ >
+ <LinesY className="my-0.5 block h-4 w-4 text-gray-600 sm:hidden" />
+ <div className="hidden items-center gap-3 sm:flex">
+ {[
+ { id: "clicks", icon: CursorRays, value: totalEvents?.clicks },
+ ...(trackConversion
+ ? [
+ {
+ id: "sales",
+ icon: Crosshairs,
+ value: totalEvents?.sales,
+ className: "hidden sm:flex",
+ },
+ {
+ id: "leads",
+ icon: InvoiceDollar,
+ value: totalEvents?.leads,
+ className: "hidden sm:flex",
+ },
+ ]
+ : []),
+ ].map(({ id, icon: Icon, value, className }) => (
+ <div
+ key={id}
+ className={cn("flex items-center gap-1", className)}
+ >
+ <Icon className="h-4 w-4 shrink-0 text-gray-600" />
+ {nFormatter(value)}
+ </div>
))}
</div>
- }
- side="bottom"
- >
- <div className="cursor-default transition-transform hover:scale-105">
- <TagBadge withIcon {...primaryTag} plus={additionalTags.length} />
- </div>
- </Tooltip>
+ </Link>
+ <LinkControls link={link} />
+ </>
)}
- <Link
- href={`/${slug}/analytics?domain=${domain}&key=${key}`}
- className="rounded-md bg-gray-100 px-2 py-0.5 text-sm text-gray-950 transition-colors hover:bg-gray-200"
- >
- <LinesY className="my-0.5 block h-4 w-4 text-gray-600 sm:hidden" />
- <div className="hidden items-center gap-3 sm:flex">
- {[
- { id: "clicks", icon: CursorRays, value: totalEvents?.clicks },
- ...(trackConversion
- ? [
- {
- id: "sales",
- icon: Crosshairs,
- value: totalEvents?.sales,
- className: "hidden sm:flex",
- },
- {
- id: "leads",
- icon: InvoiceDollar,
- value: totalEvents?.leads,
- className: "hidden sm:flex",
- },
- ]
- : []),
- ].map(({ id, icon: Icon, value, className }) => (
- <div key={id} className={cn("flex items-center gap-1", className)}>
- <Icon className="h-4 w-4 shrink-0 text-gray-600" />
- {nFormatter(value)}
- </div>
- ))}
- </div>
- </Link>
- <LinkControls link={link} />
</div>
);
}
diff --git a/packages/ui/src/table/table.tsx b/packages/ui/src/table/table.tsx
index e0415c6d78..9e2c5e5427 100644
--- a/packages/ui/src/table/table.tsx
+++ b/packages/ui/src/table/table.tsx
@@ -106,7 +106,7 @@ const tableRowVariants = cva("group/row", {
});
const tablePaginationVariants = cva(
- "-mt-px sticky flex mx-auto items-center border-gray-200 justify-between bg-white px-4 py-3.5 text-sm leading-6 text-gray-600 transition-[width,bottom,filter]",
+ "-mt-px sticky flex mx-auto items-center border-gray-200 justify-between bg-white px-4 py-3.5 text-sm leading-6 text-gray-600 transition-[max-width,width,bottom,filter]",
{
variants: {
variant: {
@@ -118,7 +118,7 @@ const tablePaginationVariants = cva(
compoundVariants: [
{
variant: ["default", "compact-list"],
- className: "rounded-b-[inherit] bottom-0 w-full border-t",
+ className: "rounded-b-[inherit] bottom-0 w-full border-t max-w-full",
},
],
},