import { readExampleFile } from "@/lib/composition"
import { highlightCode } from "@/lib/highlight-code"
import { Box, BoxProps, HStack, Tabs } from "@chakra-ui/react"
import dynamic from "next/dynamic"
import { CopyButton } from "./copy-button"
import { ErrorBoundary } from "./error-boundary"
import { StackblitzButton } from "./stackblitz-button"
interface Props {
name: string
scope?: "examples" | "ui"
}
function formatComponentName(name: string) {
return name
.replace("charts/", "")
.split(/[-\/]/)
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join("")
}
export const ExamplePreview = (props: Props) => {
const { name, scope = "examples" } = props
const componentName = formatComponentName(name)
const Component = dynamic(() =>
import(`../../compositions/src/${scope}/${name}`).then(
(mod) => mod[componentName],
),
)
return