Skip to content

Commit caa843a

Browse files
authored
Merge pull request #81 from assistant-ui/codex/fix-gallery-tooltip-layout
Fix gallery tooltip layout and make tooltip fully clickable
2 parents 2ea855c + 3a2cdda commit caa843a

File tree

3 files changed

+60
-12
lines changed

3 files changed

+60
-12
lines changed

app/docs/_components/gallery-docs-link.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,48 @@
33
import Link from "next/link";
44
import { ArrowRight } from "lucide-react";
55
import { analytics } from "@/lib/analytics";
6+
import { cn } from "@/lib/ui/cn";
67

78
interface GalleryDocsLinkProps {
89
componentId: string;
9-
componentName: string;
10+
label: string;
1011
href: string;
1112
className?: string;
1213
}
1314

1415
export function GalleryDocsLink({
1516
componentId,
16-
componentName,
17+
label,
1718
href,
1819
className,
1920
}: GalleryDocsLinkProps) {
2021
const handleClick = () => {
2122
analytics.gallery.componentClicked(componentId);
22-
analytics.docs.navigationClicked(componentName, href);
23+
analytics.docs.navigationClicked(label, href);
2324
};
2425

2526
return (
26-
<Link href={href} className={className} onClick={handleClick}>
27-
<span>View Docs</span>
28-
<ArrowRight className="size-3" aria-hidden="true" />
27+
<Link
28+
href={href}
29+
className={cn(
30+
"group inline-flex items-center gap-1 whitespace-nowrap hover:no-underline focus-visible:no-underline",
31+
className,
32+
)}
33+
onClick={handleClick}
34+
>
35+
<span className="whitespace-nowrap text-sm font-semibold">{label}</span>
36+
<span
37+
className="text-neutral-400 dark:text-neutral-500"
38+
aria-hidden="true"
39+
>
40+
41+
</span>
42+
<span className="inline-flex items-center gap-1 whitespace-nowrap text-xs">
43+
<span className="underline-offset-2 group-hover:underline group-focus-visible:underline">
44+
View Docs
45+
</span>
46+
<ArrowRight className="size-3" aria-hidden="true" />
47+
</span>
2948
</Link>
3049
);
3150
}

app/docs/gallery/page.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,13 @@ function GalleryPreviewCard({
118118
const componentMeta = galleryComponentDocs[componentId];
119119

120120
return (
121-
<div className={cn("group/gallery-card relative pt-8", className)}>
122-
<div className="pointer-events-none absolute top-0 left-1/2 z-20 -translate-x-1/2 -translate-y-1 rounded-full border border-neutral-700/70 bg-neutral-900/90 px-3 py-1 text-[11px] font-medium tracking-wide text-neutral-100 opacity-0 shadow-sm backdrop-blur-sm transition-all duration-200 group-focus-within/gallery-card:translate-y-0 group-focus-within/gallery-card:opacity-100 group-hover/gallery-card:translate-y-0 group-hover/gallery-card:opacity-100 dark:border-neutral-300/80 dark:bg-neutral-100/90 dark:text-neutral-900">
123-
<span className="text-sm font-semibold">{componentMeta.name}</span>
124-
<span className="mx-1 text-neutral-400 dark:text-neutral-500"></span>
121+
<div className={cn("group/gallery-card relative pt-[44px]", className)}>
122+
<div className="pointer-events-none absolute top-0 left-1/2 z-20 w-fit -translate-x-1/2 -translate-y-1 whitespace-nowrap rounded-xl border border-neutral-700/70 bg-neutral-900/90 px-3 py-2 text-[11px] font-medium tracking-wide text-neutral-100 opacity-0 shadow-sm backdrop-blur-sm transition-all duration-200 group-focus-within/gallery-card:translate-y-0 group-focus-within/gallery-card:opacity-100 group-hover/gallery-card:translate-y-0 group-hover/gallery-card:opacity-100 dark:border-neutral-300/80 dark:bg-neutral-100/90 dark:text-neutral-900">
125123
<GalleryDocsLink
126124
componentId={componentId}
127-
componentName={componentMeta.name}
125+
label={componentMeta.name}
128126
href={componentMeta.docsHref}
129-
className="pointer-events-auto inline-flex items-center gap-1 text-xs text-neutral-200/90 underline-offset-2 hover:text-white hover:underline focus-visible:underline focus-visible:outline-none dark:text-neutral-700 dark:hover:text-neutral-950"
127+
className="pointer-events-auto inline-flex items-center gap-1 whitespace-nowrap text-neutral-200/90 hover:text-white focus-visible:outline-none dark:text-neutral-700 dark:hover:text-neutral-950"
130128
/>
131129
</div>
132130
{children}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import fs from "node:fs";
2+
import path from "node:path";
3+
import { describe, expect, test } from "vitest";
4+
5+
describe("gallery tooltip layout contract", () => {
6+
test("gallery cards keep a single-row clickable tooltip with extended spacing buffer", () => {
7+
const galleryPagePath = path.join(process.cwd(), "app/docs/gallery/page.tsx");
8+
const content = fs.readFileSync(galleryPagePath, "utf8");
9+
10+
expect(content).toContain("group/gallery-card relative pt-[44px]");
11+
expect(content).toContain("label={componentMeta.name}");
12+
expect(content).toContain("pointer-events-auto inline-flex items-center");
13+
});
14+
15+
test("gallery docs link includes a bullet and keeps name unwrapped", () => {
16+
const docsLinkPath = path.join(
17+
process.cwd(),
18+
"app/docs/_components/gallery-docs-link.tsx",
19+
);
20+
const content = fs.readFileSync(docsLinkPath, "utf8");
21+
22+
expect(content).toMatch(/label:\s*string/);
23+
expect(content).toContain("whitespace-nowrap");
24+
expect(content).toContain("•");
25+
expect(content).toContain("group-hover:underline");
26+
expect(content).toContain("group-focus-visible:underline");
27+
expect(content).toContain("hover:no-underline");
28+
expect(content).toContain("{label}");
29+
expect(content).toContain("View Docs");
30+
});
31+
});

0 commit comments

Comments
 (0)