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.

Try adding hidden "Link"

Tim Wilsonf83ccc03589d
diff --git a/apps/web/ui/links/link-card.tsx b/apps/web/ui/links/link-card.tsx
index 85993d6aed..c3003af5e1 100644
--- a/apps/web/ui/links/link-card.tsx
+++ b/apps/web/ui/links/link-card.tsx
@@ -7,7 +7,7 @@ import {
useMediaQuery,
} from "@dub/ui";
import Link from "next/link";
-import { useRouter, useSearchParams } from "next/navigation";
+import { useSearchParams } from "next/navigation";
import { useContext, useRef } from "react";
import { FolderIcon } from "../folders/folder-icon";
import { LinkDetailsColumn } from "./link-details-column";
@@ -19,7 +19,7 @@ export function LinkCard({ link }: { link: ResponseLink }) {
const { isMobile } = useMediaQuery();
const ref = useRef<HTMLDivElement>(null);
- const router = useRouter();
+ const linkRef = useRef<HTMLAnchorElement>(null);
const searchParams = useSearchParams();
const { slug, defaultFolderId } = useWorkspace();
@@ -32,56 +32,61 @@ export function LinkCard({ link }: { link: ResponseLink }) {
});
return (
- <CardList.Card
- key={link.id}
- onClick={
- isMobile
- ? undefined
- : () => router.push(`/${slug}/links/${link.domain}/${link.key}`)
- }
- innerClassName="flex items-center gap-5 sm:gap-8 md:gap-12 text-sm"
- {...(variant === "loose" &&
- link.folderId &&
- ![defaultFolderId, searchParams.get("folderId")].includes(
- link.folderId,
- ) && {
- banner: (
- <Link
- href={`/${slug}?folderId=${folder?.id}`}
- className="group flex items-center justify-between gap-2 rounded-t-xl border-b border-neutral-100 bg-neutral-50 px-5 py-2 text-xs"
- >
- <div className="flex items-center gap-1.5">
- {folder ? (
- <FolderIcon
- folder={folder}
- shape="square"
- className="rounded"
- innerClassName="p-0.5"
- iconClassName="size-3"
- />
- ) : (
- <div className="size-4 rounded-md bg-neutral-200" />
- )}
- {folder ? (
- <span className="font-medium text-neutral-900">
- {folder.name}
- </span>
- ) : (
- <div className="h-4 w-20 rounded-md bg-neutral-200" />
- )}
- <ExpandingArrow className="invisible -ml-1.5 size-3.5 text-neutral-500 group-hover:visible" />
- </div>
- <p className="text-neutral-500 underline transition-colors group-hover:text-neutral-800">
- Open folder
- </p>
- </Link>
- ),
- })}
- >
- <div ref={ref} className="min-w-0 grow">
- <LinkTitleColumn link={link} />
- </div>
- <LinkDetailsColumn link={link} />
- </CardList.Card>
+ <>
+ {!isMobile && (
+ <Link
+ ref={linkRef}
+ href={`/${slug}/links/${link.domain}/${link.key}`}
+ className="hidden"
+ />
+ )}
+ <CardList.Card
+ key={link.id}
+ onClick={() => linkRef.current?.click()}
+ innerClassName="flex items-center gap-5 sm:gap-8 md:gap-12 text-sm"
+ {...(variant === "loose" &&
+ link.folderId &&
+ ![defaultFolderId, searchParams.get("folderId")].includes(
+ link.folderId,
+ ) && {
+ banner: (
+ <Link
+ href={`/${slug}?folderId=${folder?.id}`}
+ className="group flex items-center justify-between gap-2 rounded-t-xl border-b border-neutral-100 bg-neutral-50 px-5 py-2 text-xs"
+ >
+ <div className="flex items-center gap-1.5">
+ {folder ? (
+ <FolderIcon
+ folder={folder}
+ shape="square"
+ className="rounded"
+ innerClassName="p-0.5"
+ iconClassName="size-3"
+ />
+ ) : (
+ <div className="size-4 rounded-md bg-neutral-200" />
+ )}
+ {folder ? (
+ <span className="font-medium text-neutral-900">
+ {folder.name}
+ </span>
+ ) : (
+ <div className="h-4 w-20 rounded-md bg-neutral-200" />
+ )}
+ <ExpandingArrow className="invisible -ml-1.5 size-3.5 text-neutral-500 group-hover:visible" />
+ </div>
+ <p className="text-neutral-500 underline transition-colors group-hover:text-neutral-800">
+ Open folder
+ </p>
+ </Link>
+ ),
+ })}
+ >
+ <div ref={ref} className="min-w-0 grow">
+ <LinkTitleColumn link={link} />
+ </div>
+ <LinkDetailsColumn link={link} />
+ </CardList.Card>
+ </>
);
}