{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "docs-preview-frame",
  "type": "registry:block",
  "title": "Docs, preview frame",
  "description": "A framed live stage and its code, with Preview and Code tabs when both are present. The stage is a live demo (demo id) or an image; either part may be left out (code-only SKILL.md, preview-only expected result).",
  "categories": [
    "docs"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-a-docs.json",
    "https://ui.klarhimmel.com/r/kit-d-chrome.json",
    "https://ui.klarhimmel.com/r/tabs.json"
  ],
  "files": [
    {
      "path": "src/blocks/docs-preview-frame/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/docs-preview-frame/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, media, t } from '../_shared/schema';\n\nconst schema = z.object({\n  title: t(80),\n  description: t(300),\n  preview: media.optional(),\n  demo: t(80).optional(),\n  filename: t(60).optional(),\n  code: t(2000).optional(),\n});\n\nexport const spec = defineSpec({\n  type: 'docs-preview-frame',\n  aliases: ['docs/preview-frame'],\n  name: 'Docs, preview frame',\n  category: 'docs',\n  role: 'body',\n  description: 'A framed live stage and its code, with Preview and Code tabs when both are present. The stage is a live demo (demo id) or an image; either part may be left out (code-only SKILL.md, preview-only expected result).',\n  schema,\n  defaults: {\n    title: 'Name this use',\n    description: 'Say in one or two sentences how to use it and what to choose for the main case.',\n    preview: { src: '', alt: 'Show the component in its main variants' },\n    demo: 'button-variants',\n    filename: 'example.tsx',\n    code: \"import { Component } from '@your/ui';\\n\\nexport function Actions() {\\n  return (\\n    <div className=\\\"flex gap-3\\\">\\n      <Component>Main action</Component>\\n      <Component option=\\\"second\\\">Second action</Component>\\n    </div>\\n  );\\n}\",\n  },\n});\n"
    },
    {
      "path": "src/blocks/docs-preview-frame/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/docs-preview-frame/index.tsx",
      "content": "import { withHeadingLevel } from '../../editing';\nimport { useId } from 'react';\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '../../ui/tabs';\nimport { Container, Section, SectionHeader, useEditing } from '../_shared/kit';\nimport { CodePanel, Stage, hasMedia } from '../_shared/a-docs-kit';\nimport { useInteractive } from '../_shared/d-chrome-kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\nfunction DocsPreviewFrame({ props }: BlockProps<Props>) {\n  const id = useId();\n  const editing = useEditing();\n  const interactive = useInteractive(); // without JavaScript the tabs cannot switch: stage and code are both shown, no tab buttons\n  const hasStage = !!props.demo || hasMedia(props.preview);\n  const hasCode = !!props.code;\n  const stage = <Stage demoPath={['demo']} demo={props.demo} mediaPath={['preview']} media={props.preview} ratio=\"16 / 7\" />;\n  const code = <CodePanel path={['code']} code={props.code ?? ''} filename={props.filename} filenamePath={['filename']} flush />;\n  return (\n    <Section labelledBy={id} className=\"py-10 @3xl:py-14\">\n      <Container>\n        <SectionHeader id={id} title={props.title} description={props.description} />\n        <div className=\"mt-8 overflow-hidden rounded-kh-xl border border-kh-line bg-kh-surface\">\n          {editing || (!interactive && hasStage && hasCode) ? (\n            <>\n              {stage}\n              <div className=\"border-t border-kh-line\">{code}</div>\n            </>\n          ) : hasStage && hasCode ? (\n            <Tabs defaultValue=\"preview\">\n              <div className=\"flex items-center justify-between gap-4 border-b border-kh-line bg-kh-surface-2 px-3 py-2\">\n                <TabsList label=\"Preview or code\" className=\"bg-kh-surface-3\">\n                  <TabsTrigger value=\"preview\">Preview</TabsTrigger>\n                  <TabsTrigger value=\"code\">Code</TabsTrigger>\n                </TabsList>\n              </div>\n              <TabsContent value=\"preview\" forceMount>{stage}</TabsContent>\n              <TabsContent value=\"code\" forceMount>{code}</TabsContent>\n            </Tabs>\n          ) : hasStage ? (\n            stage\n          ) : (\n            code\n          )}\n        </div>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(DocsPreviewFrame);\n"
    }
  ]
}
