{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "domain-switch-focus-demo",
  "type": "registry:block",
  "title": "Domain Switch: Focus Mode",
  "description": "Dark Mode Toggle example, Focus Mode: A writing app. Focus opens a calm, dark domain in which the sidebar and toolbar, wrapped in `DomainSwitchAside`, dissolve, and the document in `DomainSwitchMain` comes forward. One `Editor` renders both worlds. Esc leaves. A take on the toggle (switch). Fits navbar and app UI sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "navbar",
    "app-ui",
    "toggle",
    "theme",
    "transition",
    "canvas"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/domain-switch#domain-switch-focus-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/domain-switch.json"
  ],
  "files": [
    {
      "path": "components/domain-switch-focus-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\nimport {\n  DomainSwitch,\n  DomainSwitchAside,\n  DomainSwitchMain,\n  DomainSwitchScope,\n  DomainSwitchToggle,\n  useDomainSwitch,\n} from \"@/components/ui/domain-switch\";\n\nconst drafts = [\"On slow software\", \"Field notes, March\", \"The case for less\", \"Interview: K. Ito\"];\n\nexport function DomainSwitchFocusDemo() {\n  const [focus, setFocus] = React.useState(false);\n\n  React.useEffect(() => {\n    if (!focus) return;\n    const onKeyDown = (event: KeyboardEvent) => {\n      if (event.key === \"Escape\") setFocus(false);\n    };\n    window.addEventListener(\"keydown\", onKeyDown);\n    return () => window.removeEventListener(\"keydown\", onKeyDown);\n  }, [focus]);\n\n  return (\n    <div className=\"w-full overflow-hidden rounded-xl border border-zinc-200 dark:border-zinc-800\">\n      <DomainSwitch checked={focus} onCheckedChange={setFocus}>\n        <DomainSwitchScope className=\"h-[var(--demo-height,560px)]\" seamClassName=\"text-stone-950\">\n          <Editor />\n        </DomainSwitchScope>\n      </DomainSwitch>\n    </div>\n  );\n}\n\n// One editor for both worlds; it reads which one it's in.\nfunction Editor() {\n  const { world } = useDomainSwitch();\n  const calm = world === \"inside\";\n\n  return (\n    <div\n      className={cn(\n        \"flex h-full\",\n        calm ? \"bg-[#141311] text-stone-300\" : \"bg-white text-stone-800\",\n      )}\n    >\n      <DomainSwitchAside\n        className={cn(\n          \"hidden w-52 shrink-0 flex-col gap-1 border-r p-3 sm:flex\",\n          calm ? \"border-white/5\" : \"border-stone-200 bg-stone-50\",\n        )}\n      >\n        <p className=\"px-2 pt-1 pb-2 text-xs font-medium text-stone-400\">Drafts</p>\n        {drafts.map((draft, i) => (\n          <span\n            key={draft}\n            className={cn(\n              \"truncate rounded-md px-2 py-1.5 text-sm\",\n              i === 0 ? (calm ? \"bg-white/5 text-stone-200\" : \"bg-white text-stone-900 shadow-xs\") : \"text-stone-500\",\n            )}\n          >\n            {draft}\n          </span>\n        ))}\n      </DomainSwitchAside>\n\n      <div className=\"flex min-w-0 flex-1 flex-col\">\n        <div\n          className={cn(\n            \"flex items-center gap-1 border-b px-3 py-2\",\n            calm ? \"border-transparent\" : \"border-stone-200\",\n          )}\n        >\n          <DomainSwitchAside className=\"flex items-center gap-1\">\n            {[\"B\", \"I\", \"U\"].map((mark) => (\n              <span\n                key={mark}\n                className={cn(\n                  \"grid size-8 place-items-center rounded-md text-sm text-stone-500\",\n                  mark === \"B\" && \"font-bold\",\n                  mark === \"I\" && \"italic\",\n                  mark === \"U\" && \"underline\",\n                )}\n              >\n                {mark}\n              </span>\n            ))}\n            <span className=\"mx-1 h-4 w-px bg-stone-200\" />\n            <span className=\"grid h-8 place-items-center rounded-md px-2 text-sm text-stone-500\">H1</span>\n            <span className=\"hidden h-8 place-items-center rounded-md px-2 text-sm text-stone-500 sm:grid\">Quote</span>\n          </DomainSwitchAside>\n          {calm && <span className=\"ml-1 text-xs text-stone-500\">Esc to leave</span>}\n          <DomainSwitchToggle\n            className={cn(\n              \"ml-auto h-8 gap-1.5 rounded-full px-3 text-xs font-medium\",\n              calm\n                ? \"bg-amber-200/10 text-amber-100 hover:bg-amber-200/15\"\n                : \"bg-stone-900 text-white hover:bg-stone-800\",\n            )}\n          >\n            <FocusIcon />\n            {calm ? \"Leave focus\" : \"Focus\"}\n          </DomainSwitchToggle>\n        </div>\n\n        <div className=\"min-h-0 flex-1 overflow-hidden px-6 pt-8 sm:px-10 sm:pt-12\">\n          <DomainSwitchMain className=\"mx-auto max-w-[34rem] origin-top\">\n            <p className={cn(\"text-xs\", calm ? \"text-stone-500\" : \"text-stone-400\")}>Essay · 412 words</p>\n            <h2\n              className={cn(\n                \"mt-2 font-serif text-3xl tracking-tight sm:text-4xl\",\n                calm ? \"text-stone-100\" : \"text-stone-900\",\n              )}\n            >\n              On slow software\n            </h2>\n            <div className=\"mt-5 space-y-4 font-serif text-[15px]/7 sm:text-base/7\">\n              <p>\n                The best tools I use don&apos;t ask for my attention. They wait. A text editor that opens before\n                I&apos;ve finished the thought, a calendar that doesn&apos;t blink.\n              </p>\n              <p>\n                Most software is built to be noticed. Badges, banners, a tour on every release. Each one is\n                small, and together they are the reason I can&apos;t finish a paragraph\n                <span\n                  className={cn(\n                    \"ml-0.5 inline-block h-[1.1em] w-px translate-y-[3px] animate-pulse\",\n                    calm ? \"bg-amber-200\" : \"bg-stone-900\",\n                  )}\n                />\n              </p>\n            </div>\n          </DomainSwitchMain>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nfunction FocusIcon() {\n  return (\n    <svg viewBox=\"0 0 16 16\" className=\"size-3.5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" aria-hidden>\n      <circle cx=\"8\" cy=\"8\" r=\"2.25\" />\n      <path d=\"M2 5V3a1 1 0 0 1 1-1h2M11 2h2a1 1 0 0 1 1 1v2M14 11v2a1 1 0 0 1-1 1h-2M5 14H3a1 1 0 0 1-1-1v-2\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n"
    }
  ]
}