1- import { useMemo , useState } from "react" ;
1+ import { useMemo } from "react" ;
22import { FileTree } from "@/components/file-tree/file-tree" ;
33import { CodeEditor } from "./code-editor" ;
44import { FeatureFile } from "@/types/feature" ;
55import { useURLParams } from "@/contexts/url-params-context" ;
66import { Tabs , TabsContent , TabsList , TabsTrigger } from "@/components/ui/tabs" ;
7+ import { useIsInsideIframe } from "@/utils/use-in-iframe" ;
8+ import { cn } from "@/lib/utils" ;
79
810export default function CodeViewer ( { codeFiles } : { codeFiles : FeatureFile [ ] } ) {
911 const { file, setCodeFile, codeLayout } = useURLParams ( ) ;
12+ const isInsideIframe = useIsInsideIframe ( ) ;
13+ const isInsideCpkFrame = isInsideIframe && ( document . referrer . includes ( "copilotkit.com" ) || document . referrer . includes ( "localhost" ) ) ;
1014
1115 const selectedFile = useMemo (
1216 ( ) => codeFiles . find ( ( f ) => f . name === file ) ?? codeFiles [ 0 ] ,
@@ -38,7 +42,10 @@ export default function CodeViewer({ codeFiles }: { codeFiles: FeatureFile[] })
3842 value = { file . name }
3943 className = "flex-1 mt-0 data-[state=inactive]:hidden"
4044 >
41- < div className = "h-full rounded-xl overflow-hidden border border-b-0 border-cpk-docs-dark-bg/8 dark:border-white/6 -mx-px" >
45+ < div className = { cn (
46+ "h-full border border-b-0 border-cpk-docs-dark-bg/8 dark:border-white/6 -mx-px" ,
47+ isInsideCpkFrame && "rounded-xl overflow-hidden" ,
48+ ) } >
4249 < CodeEditor file = { file } />
4350 </ div >
4451 </ TabsContent >
@@ -49,17 +56,23 @@ export default function CodeViewer({ codeFiles }: { codeFiles: FeatureFile[] })
4956 }
5057
5158 return (
52- < div className = "flex h-full bg-white" >
59+ < div className = "flex h-full w-full bg-white" >
5360 { /* wrapper div to mix the parent bg-white with bg-cpk-docs-dark-bg */ }
54- < div className = "bg-cpk-docs-dark-bg/3 dark:bg-cpk-docs-dark-bg/95" >
61+ < div className = "flex h-full w-full bg-cpk-docs-dark-bg/3 dark:bg-cpk-docs-dark-bg/95" >
5562 < div className = "w-72 border-r border-gray-200 dark:border-neutral-700 flex flex-col" >
5663 < div className = "flex-1 overflow-auto" >
5764 < FileTree files = { codeFiles } selectedFile = { selectedFile } onFileSelect = { setCodeFile } />
5865 </ div >
5966 </ div >
60- < div className = "flex-1 h-full py-5 bg-gray-50 dark:bg-[#1e1e1e] rounded-xl overflow-hidden" >
67+ < div className = { cn (
68+ "flex-1 h-full bg-gray-50 dark:bg-[#1e1e1e]" ,
69+ isInsideCpkFrame && "rounded-xl overflow-hidden" ,
70+ ) } >
6171 { selectedFile ? (
62- < div className = "h-full rounded-xl overflow-hidden border border-b-0 border-cpk-docs-dark-bg/8 dark:border-white/6 -mx-px" >
72+ < div className = { cn (
73+ "h-full border-cpk-docs-dark-bg/8 dark:border-white/6" ,
74+ isInsideCpkFrame && "rounded-xl overflow-hidden" ,
75+ ) } >
6376 < CodeEditor file = { selectedFile } />
6477 </ div >
6578 ) : (
0 commit comments