Skip to content

Commit 736d9aa

Browse files
committed
Add LinkPreview wrapping to LinksLayer in UnifiedCell
1 parent ceafc10 commit 736d9aa

2 files changed

Lines changed: 34 additions & 18 deletions

File tree

showcase/shell-dashboard/src/components/__tests__/unified-cell.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* 5. Hides badges when health overlay is not active
1111
* 6. Hides depth chip when depth overlay is not active
1212
*/
13+
import React from "react";
1314
import { describe, it, expect, vi, beforeEach } from "vitest";
1415
import { render } from "@testing-library/react";
1516
import { UnifiedCell } from "../unified-cell";
@@ -74,6 +75,16 @@ vi.mock("@/components/command-cell", () => ({
7475
)),
7576
}));
7677

78+
vi.mock("@/components/link-preview", () => ({
79+
LinkPreview: vi.fn(
80+
({ children, href }: { children: React.ReactNode; href: string }) => (
81+
<span data-testid="mock-link-preview" data-href={href}>
82+
{children}
83+
</span>
84+
),
85+
),
86+
}));
87+
7788
vi.mock("@/components/cell-pieces", () => ({
7889
urlsFor: vi.fn(() => ({
7990
demoUrl: "https://demo.test/preview",

showcase/shell-dashboard/src/components/unified-cell.tsx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type { Overlay } from "@/lib/overlay-types";
2222
import { CellDrilldown } from "@/components/cell-drilldown";
2323
import { CommandCell } from "@/components/command-cell";
2424
import { DocsRow, urlsFor } from "@/components/cell-pieces";
25+
import { LinkPreview } from "@/components/link-preview";
2526

2627
// ---------------------------------------------------------------------------
2728
// Props
@@ -82,24 +83,28 @@ function LinksLayer({ ctx }: { ctx: CellContext }) {
8283

8384
return (
8485
<div className="flex items-center justify-center gap-1.5">
85-
<a
86-
href={links.demoUrl}
87-
target="_blank"
88-
rel="noopener noreferrer"
89-
className="whitespace-nowrap text-[var(--accent)] hover:underline"
90-
>
91-
<span className="text-[var(--text-muted)]">Demo</span>{" "}
92-
<span>&#8599;</span>
93-
</a>
94-
<a
95-
href={links.codeUrl}
96-
target="_blank"
97-
rel="noopener noreferrer"
98-
className="whitespace-nowrap text-[var(--accent)] hover:underline"
99-
>
100-
<span className="text-[var(--text-muted)]">Code</span>{" "}
101-
<span>{"</>"}</span>
102-
</a>
86+
<LinkPreview href={links.demoUrl}>
87+
<a
88+
href={links.demoUrl}
89+
target="_blank"
90+
rel="noopener noreferrer"
91+
className="whitespace-nowrap text-[var(--accent)] hover:underline"
92+
>
93+
<span className="text-[var(--text-muted)]">Demo</span>{" "}
94+
<span>&#8599;</span>
95+
</a>
96+
</LinkPreview>
97+
<LinkPreview href={links.codeUrl}>
98+
<a
99+
href={links.codeUrl}
100+
target="_blank"
101+
rel="noopener noreferrer"
102+
className="whitespace-nowrap text-[var(--accent)] hover:underline"
103+
>
104+
<span className="text-[var(--text-muted)]">Code</span>{" "}
105+
<span>{"</>"}</span>
106+
</a>
107+
</LinkPreview>
103108
</div>
104109
);
105110
}

0 commit comments

Comments
 (0)