Skip to content

Commit 646a058

Browse files
committed
feat(shell-docs): add IframeSwitcher component for demo+code tabs
Several MDX files import `IframeSwitcher` from `@/components/content` (prebuilt-components, frontend-tools, interactive, tool-rendering, plus integration overrides), but the component file was missing. This adds it as a thin wrapper around the existing `<Tabs>` component, rendering a demo iframe and a code iframe in a Tabs strip. Props: `exampleUrl`, `codeUrl`, `exampleLabel` (default "Demo"), `codeLabel` (default "Code"), `height` (default "600px"). Both iframes are sandboxed and lazy-loaded. Matches the upstream IframeSwitcher pattern used on docs.copilotkit.ai to render embedded feature-viewer demos alongside their backing code.
1 parent 1de9052 commit 646a058

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"use client";
2+
3+
import { Tabs, Tab } from "../docs-tabs";
4+
5+
interface IframeSwitcherProps {
6+
id?: string;
7+
exampleUrl: string;
8+
codeUrl: string;
9+
exampleLabel?: string;
10+
codeLabel?: string;
11+
height?: string;
12+
}
13+
14+
export function IframeSwitcher({
15+
exampleUrl,
16+
codeUrl,
17+
exampleLabel = "Demo",
18+
codeLabel = "Code",
19+
height = "600px",
20+
}: IframeSwitcherProps) {
21+
const iframeStyle = {
22+
width: "100%",
23+
height,
24+
border: "none",
25+
borderRadius: "0.375rem",
26+
background: "var(--bg-surface)",
27+
};
28+
29+
return (
30+
<Tabs items={[exampleLabel, codeLabel]}>
31+
<Tab value={exampleLabel}>
32+
<iframe
33+
src={exampleUrl}
34+
style={iframeStyle}
35+
sandbox="allow-scripts allow-same-origin allow-forms allow-popups"
36+
loading="lazy"
37+
/>
38+
</Tab>
39+
<Tab value={codeLabel}>
40+
<iframe
41+
src={codeUrl}
42+
style={iframeStyle}
43+
sandbox="allow-scripts allow-same-origin allow-forms allow-popups"
44+
loading="lazy"
45+
/>
46+
</Tab>
47+
</Tabs>
48+
);
49+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { IframeSwitcher } from "./iframe-switcher";

0 commit comments

Comments
 (0)