{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "window-frame-mockup",
  "title": "Window Frame Mockup",
  "description": "A desktop app window to put your product in: drag it around, resize it from the corner, zoom it with a double-click, and send it to the dock and back.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/window-frame-mockup/window-frame-mockup.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface WindowFrameMockupProps extends Omit<\n  React.ComponentPropsWithoutRef<\"div\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  /** Coloured dots on the left, or plain buttons on the right. */\n  controls?: \"dots\" | \"buttons\";\n  /** Height of the desktop area, in pixels. */\n  height?: number;\n  /** Let people move and resize the window. */\n  interactive?: boolean;\n  /** What goes inside the window. Leave out for a sample app. */\n  children?: React.ReactNode;\n}\n\ntype Mode = \"normal\" | \"max\" | \"min\" | \"closed\";\n\ninterface Box {\n  x: number;\n  y: number;\n  w: number;\n  h: number;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst ACCENT = \"#5E6AD2\";\nconst BAR = 38;\nconst DOCK = 56;\nconst MIN_W = 0.3;\nconst MIN_H = 0.42;\nconst START: Box = { x: 0.08, y: 0.07, w: 0.84, h: 0.74 };\n\nconst PALETTES = {\n  dark: {\n    desk: \"#08090A\",\n    glow: \"rgba(94,106,210,0.22)\",\n    window: \"#0F1011\",\n    bar: \"#161718\",\n    side: \"#0B0C0D\",\n    border: \"rgba(255,255,255,0.1)\",\n    block: \"rgba(255,255,255,0.07)\",\n    strong: \"rgba(255,255,255,0.14)\",\n    text: \"#F7F8F8\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    dock: \"rgba(22,23,24,0.86)\",\n    shadow: \"0 30px 80px rgba(0,0,0,0.6), 0 2px 6px rgba(0,0,0,0.4)\",\n  },\n  light: {\n    desk: \"#ECEEF1\",\n    glow: \"rgba(94,106,210,0.18)\",\n    window: \"#FFFFFF\",\n    bar: \"#F7F8F8\",\n    side: \"#FAFAFB\",\n    border: \"rgba(8,9,10,0.1)\",\n    block: \"rgba(8,9,10,0.06)\",\n    strong: \"rgba(8,9,10,0.13)\",\n    text: \"#08090A\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    dock: \"rgba(255,255,255,0.86)\",\n    shadow: \"0 30px 80px rgba(8,9,10,0.18), 0 2px 6px rgba(8,9,10,0.08)\",\n  },\n};\n\nconst DOTS = [\n  { id: \"close\", color: \"#EB5757\", label: \"Close\", icon: \"M5 5l6 6m0-6-6 6\" },\n  { id: \"min\", color: \"#F0BF00\", label: \"Minimise\", icon: \"M4.5 8h7\" },\n  { id: \"max\", color: \"#27A644\", label: \"Zoom\", icon: \"M8 4.5v7M4.5 8h7\" },\n] as const;\n\nconst ROWS = [72, 58, 84, 46, 66, 52];\n\nconst clamp = (v: number, lo: number, hi: number) =>\n  Math.min(hi, Math.max(lo, v));\n\n/** A quiet stand-in app, so the frame reads as a real window before anything is put in it. */\nfunction SampleApp({ c }: { c: (typeof PALETTES)[\"dark\"] }) {\n  return (\n    <div className=\"flex size-full\">\n      <div\n        className=\"hidden w-[30%] max-w-[180px] flex-col gap-2 border-r p-3 @md:flex\"\n        style={{ background: c.side, borderColor: c.border }}\n      >\n        {[60, 44, 52, 38].map((w, i) => (\n          <span\n            key={w}\n            className=\"block h-2 rounded-full\"\n            style={{\n              width: `${w}%`,\n              background: i === 0 ? ACCENT : c.block,\n              opacity: i === 0 ? 0.7 : 1,\n            }}\n          />\n        ))}\n      </div>\n      <div className=\"flex min-w-0 flex-1 flex-col gap-3 p-4\">\n        <span\n          className=\"block h-3 rounded-full\"\n          style={{ width: \"34%\", background: c.strong }}\n        />\n        {ROWS.map((w) => (\n          <span key={w} className=\"flex items-center gap-2\">\n            <span\n              className=\"block size-2.5 shrink-0 rounded-full\"\n              style={{ background: c.block }}\n            />\n            <span\n              className=\"block h-2 rounded-full\"\n              style={{ width: `${w}%`, background: c.block }}\n            />\n          </span>\n        ))}\n      </div>\n    </div>\n  );\n}\n\nexport function WindowFrameMockup({\n  theme = \"dark\",\n  title = \"Inbox\",\n  controls = \"dots\",\n  height = 520,\n  interactive = true,\n  children,\n  className,\n  style,\n  ...rest\n}: WindowFrameMockupProps) {\n  const c = PALETTES[theme];\n  const deskRef = React.useRef<HTMLDivElement>(null);\n  const [box, setBox] = React.useState<Box>(START);\n  const [mode, setMode] = React.useState<Mode>(\"normal\");\n  const [moving, setMoving] = React.useState(false);\n  const grab = React.useRef<{\n    px: number;\n    py: number;\n    from: Box;\n    kind: \"move\" | \"size\";\n  } | null>(null);\n\n  const usable = (height - DOCK) / height;\n  const shown: Box = mode === \"max\" ? { x: 0, y: 0, w: 1, h: usable } : box;\n\n  const begin = (kind: \"move\" | \"size\", e: React.PointerEvent) => {\n    if (!interactive || mode !== \"normal\" || e.button !== 0) return;\n    if ((e.target as HTMLElement).closest(\"[data-control]\")) return;\n    e.currentTarget.setPointerCapture(e.pointerId);\n    grab.current = { px: e.clientX, py: e.clientY, from: box, kind };\n    setMoving(true);\n  };\n\n  const drag = (e: React.PointerEvent) => {\n    const g = grab.current;\n    const desk = deskRef.current?.getBoundingClientRect();\n    if (!g || !desk) return;\n    const dx = (e.clientX - g.px) / desk.width;\n    const dy = (e.clientY - g.py) / desk.height;\n    if (g.kind === \"move\") {\n      setBox({\n        ...g.from,\n        x: clamp(g.from.x + dx, 0, 1 - g.from.w),\n        y: clamp(g.from.y + dy, 0, usable - g.from.h),\n      });\n    } else {\n      setBox({\n        ...g.from,\n        w: clamp(\n          g.from.w + dx,\n          Math.min(1 - g.from.x, Math.max(MIN_W, 240 / desk.width)),\n          1 - g.from.x,\n        ),\n        h: clamp(g.from.h + dy, MIN_H, usable - g.from.y),\n      });\n    }\n  };\n\n  const end = () => {\n    grab.current = null;\n    setMoving(false);\n  };\n\n  const act = (id: (typeof DOTS)[number][\"id\"]) => {\n    if (id === \"close\") setMode(\"closed\");\n    else if (id === \"min\") setMode(\"min\");\n    else setMode(mode === \"max\" ? \"normal\" : \"max\");\n  };\n\n  const nudge = (e: React.KeyboardEvent) => {\n    if (!interactive || mode !== \"normal\") return;\n    const step = e.shiftKey ? 0.06 : 0.02;\n    const map: Record<string, [number, number]> = {\n      ArrowLeft: [-step, 0],\n      ArrowRight: [step, 0],\n      ArrowUp: [0, -step],\n      ArrowDown: [0, step],\n    };\n    const d = map[e.key];\n    if (!d) return;\n    e.preventDefault();\n    setBox((b) => ({\n      ...b,\n      x: clamp(b.x + d[0], 0, 1 - b.w),\n      y: clamp(b.y + d[1], 0, usable - b.h),\n    }));\n  };\n\n  const hidden = mode === \"min\" || mode === \"closed\";\n  const controlButtons =\n    controls === \"dots\" ? (\n      <div className=\"group flex items-center gap-2 pl-3\">\n        {DOTS.map((d) => (\n          <button\n            key={d.id}\n            type=\"button\"\n            data-control={d.id}\n            aria-label={d.id === \"max\" && mode === \"max\" ? \"Restore\" : d.label}\n            onClick={() => act(d.id)}\n            className={`flex cursor-pointer items-center justify-center rounded-full border-0 p-0 ${RING}`}\n            style={{ width: 13, height: 13, background: d.color }}\n          >\n            <svg\n              aria-hidden=\"true\"\n              viewBox=\"0 0 16 16\"\n              width=\"9\"\n              height=\"9\"\n              fill=\"none\"\n              className=\"block opacity-0 group-hover:opacity-100 group-focus-within:opacity-100\"\n            >\n              <path\n                d={d.icon}\n                stroke=\"rgba(0,0,0,0.6)\"\n                strokeWidth=\"2\"\n                strokeLinecap=\"round\"\n              />\n            </svg>\n          </button>\n        ))}\n      </div>\n    ) : null;\n\n  const plainButtons =\n    controls === \"buttons\" ? (\n      <div className=\"flex items-center\">\n        {[DOTS[1], DOTS[2], DOTS[0]].map((d) => (\n          <button\n            key={d.id}\n            type=\"button\"\n            data-control={d.id}\n            aria-label={d.id === \"max\" && mode === \"max\" ? \"Restore\" : d.label}\n            onClick={() => act(d.id)}\n            className={`flex cursor-pointer items-center justify-center border-0 bg-transparent ${RING}`}\n            style={{ width: 42, height: BAR, color: c.sub }}\n          >\n            <svg\n              aria-hidden=\"true\"\n              viewBox=\"0 0 16 16\"\n              width=\"12\"\n              height=\"12\"\n              fill=\"none\"\n              className=\"block\"\n            >\n              {d.id === \"max\" ? (\n                <rect\n                  x=\"3.5\"\n                  y=\"3.5\"\n                  width=\"9\"\n                  height=\"9\"\n                  rx=\"1\"\n                  stroke=\"currentColor\"\n                  strokeWidth=\"1.25\"\n                />\n              ) : (\n                <path\n                  d={d.icon}\n                  stroke=\"currentColor\"\n                  strokeWidth=\"1.25\"\n                  strokeLinecap=\"round\"\n                />\n              )}\n            </svg>\n          </button>\n        ))}\n      </div>\n    ) : null;\n\n  return (\n    <div\n      ref={deskRef}\n      className={`@container relative w-full overflow-hidden rounded-xl ${className ?? \"\"}`}\n      style={{\n        height,\n        fontFamily: FONT,\n        color: c.text,\n        background: `radial-gradient(120% 80% at 50% 0%, ${c.glow}, transparent 60%), ${c.desk}`,\n        ...style,\n      }}\n      {...rest}\n    >\n      <div\n        role=\"group\"\n        aria-label={`${title} window`}\n        aria-hidden={hidden}\n        inert={hidden}\n        className=\"absolute flex flex-col overflow-hidden border\"\n        style={{\n          left: `${shown.x * 100}%`,\n          top: `${shown.y * 100}%`,\n          width: `${shown.w * 100}%`,\n          height: `${shown.h * 100}%`,\n          borderRadius: mode === \"max\" ? 0 : 12,\n          background: c.window,\n          borderColor: c.border,\n          boxShadow: c.shadow,\n          opacity: hidden ? 0 : 1,\n          transformOrigin: \"50% 100%\",\n          transform: hidden\n            ? `translateY(${mode === \"min\" ? 40 : 8}%) scale(${mode === \"min\" ? 0.2 : 0.96})`\n            : \"none\",\n          transition: moving\n            ? \"none\"\n            : \"left 300ms cubic-bezier(0.22,1,0.36,1), top 300ms cubic-bezier(0.22,1,0.36,1), width 300ms cubic-bezier(0.22,1,0.36,1), height 300ms cubic-bezier(0.22,1,0.36,1), transform 300ms cubic-bezier(0.22,1,0.36,1), opacity 220ms, border-radius 300ms\",\n        }}\n      >\n        <div\n          data-titlebar=\"\"\n          tabIndex={interactive ? 0 : -1}\n          aria-label={`${title}. Drag to move, double-click to zoom${interactive ? \", or use the arrow keys\" : \"\"}.`}\n          onPointerDown={(e) => begin(\"move\", e)}\n          onPointerMove={drag}\n          onPointerUp={end}\n          onPointerCancel={end}\n          onDoubleClick={(e) => {\n            if ((e.target as HTMLElement).closest(\"[data-control]\")) return;\n            setMode(mode === \"max\" ? \"normal\" : \"max\");\n          }}\n          onKeyDown={nudge}\n          className={`relative flex shrink-0 touch-none items-center justify-between border-b select-none ${interactive && mode === \"normal\" ? \"cursor-grab active:cursor-grabbing\" : \"\"} outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2] focus-visible:ring-inset`}\n          style={{ height: BAR, background: c.bar, borderColor: c.border }}\n        >\n          {controlButtons ?? <span />}\n          <span\n            className=\"pointer-events-none absolute inset-x-0 truncate px-24 text-center text-[13px] leading-[20px] font-[510] tracking-[-0.011em]\"\n            style={{ color: c.sub }}\n          >\n            {title}\n          </span>\n          {plainButtons}\n        </div>\n        <div className=\"relative min-h-0 flex-1 overflow-hidden\">\n          {children ?? <SampleApp c={c} />}\n        </div>\n        {interactive && mode === \"normal\" && (\n          <div\n            data-resize=\"\"\n            aria-hidden=\"true\"\n            onPointerDown={(e) => begin(\"size\", e)}\n            onPointerMove={drag}\n            onPointerUp={end}\n            onPointerCancel={end}\n            className=\"absolute right-0 bottom-0 touch-none\"\n            style={{ width: 20, height: 20, cursor: \"nwse-resize\" }}\n          >\n            <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" className=\"block\">\n              <path\n                d=\"M15 9 9 15M15 13l-2 2\"\n                stroke={c.faint}\n                strokeWidth=\"1.25\"\n                strokeLinecap=\"round\"\n              />\n            </svg>\n          </div>\n        )}\n      </div>\n\n      {/* The dock brings the window back after it's been minimised or closed. */}\n      <div\n        className=\"absolute bottom-2 left-1/2 flex -translate-x-1/2 items-center gap-2 rounded-2xl border p-1.5 backdrop-blur\"\n        style={{ background: c.dock, borderColor: c.border }}\n      >\n        <button\n          type=\"button\"\n          data-dock=\"\"\n          aria-label={hidden ? `Open ${title}` : `${title} is open`}\n          onClick={() =>\n            setMode(mode === \"closed\" || mode === \"min\" ? \"normal\" : mode)\n          }\n          className={`relative flex cursor-pointer items-center justify-center rounded-xl border-0 text-[15px] leading-[20px] font-[590] ${RING}`}\n          style={{\n            width: 36,\n            height: 36,\n            background: ACCENT,\n            color: \"#FFFFFF\",\n          }}\n        >\n          {title.slice(0, 1)}\n          <svg\n            aria-hidden=\"true\"\n            width=\"4\"\n            height=\"4\"\n            viewBox=\"0 0 4 4\"\n            className=\"absolute block\"\n            style={{ bottom: -6, opacity: mode === \"closed\" ? 0 : 1 }}\n          >\n            <circle cx=\"2\" cy=\"2\" r=\"2\" fill={c.sub} />\n          </svg>\n        </button>\n        {[0, 1].map((i) => (\n          <span\n            key={i}\n            aria-hidden=\"true\"\n            className=\"block rounded-xl\"\n            style={{ width: 36, height: 36, background: c.block }}\n          />\n        ))}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}