{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "transition-page-turn",
  "type": "registry:component",
  "title": "Transition Page Turn",
  "description": "The right half of the view lifts at the spine and turns over like a magazine page, with the next view printed on its back. Shading follows the angle of the page as it travels.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "transitions",
    "page turn",
    "book",
    "3d",
    "magazine",
    "transition"
  ],
  "docs": "https://hyperblur.dev/effects/transition-page-turn",
  "files": [
    {
      "path": "registry/hyperblur/transition-page-turn.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/transition-page-turn.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TransitionPageTurnProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  children?: React.ReactNode;\n  from?: React.ReactNode;\n  to?: React.ReactNode;\n  active?: boolean;\n  defaultActive?: boolean;\n  onActiveChange?: (active: boolean) => void;\n  autoPlay?: boolean;\n  interval?: number;\n  duration?: number;\n  paper?: string;\n}\n\nconst css = `\n.hb-vj7 {\n  position: relative;\n  display: grid;\n  grid-template: minmax(0, 1fr) / minmax(0, 1fr);\n  overflow: hidden;\n  isolation: isolate;\n  box-sizing: border-box;\n  font-family: inherit;\n  background: #050506;\n}\n.hb-vj7 *, .hb-vj7 *::before, .hb-vj7 *::after { box-sizing: border-box; }\n.hb-vj7-l {\n  grid-area: 1 / 1;\n  display: grid;\n  min-width: 0;\n  min-height: 0;\n  position: relative;\n  z-index: 3;\n  visibility: hidden;\n  transition: visibility 0s linear 0s;\n}\n.hb-vj7-l[data-on=\"true\"] {\n  visibility: visible;\n  transition: visibility 0s linear var(--hb-vj7-d);\n}\n.hb-vj7-book {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  perspective: 1600px;\n  perspective-origin: 50% 40%;\n  pointer-events: none;\n}\n.hb-vj7-half {\n  position: absolute;\n  inset: 0;\n  display: grid;\n}\n.hb-vj7-half[data-side=\"l\"] { clip-path: inset(0 50% 0 0); }\n.hb-vj7-half[data-side=\"r\"] { clip-path: inset(0 0 0 50%); }\n.hb-vj7-half > .hb-vj7-c, .hb-vj7-face > .hb-vj7-c { display: grid; min-width: 0; min-height: 0; }\n.hb-vj7-shade {\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n  opacity: 0;\n  transition: opacity var(--hb-vj7-d) cubic-bezier(0.45, 0.05, 0.25, 1);\n}\n.hb-vj7-half[data-side=\"l\"] .hb-vj7-shade { background: linear-gradient(90deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.6) 50%); }\n.hb-vj7-half[data-side=\"r\"] .hb-vj7-shade { background: linear-gradient(90deg, rgba(0, 0, 0, 0.75) 50%, rgba(0, 0, 0, 0.15)); opacity: 1; }\n.hb-vj7[data-active=\"true\"] .hb-vj7-half[data-side=\"l\"] .hb-vj7-shade { opacity: 1; }\n.hb-vj7[data-active=\"true\"] .hb-vj7-half[data-side=\"r\"] .hb-vj7-shade { opacity: 0; }\n.hb-vj7-leaf {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 50%;\n  width: 50%;\n  transform-origin: 0% 50%;\n  transform-style: preserve-3d;\n  transform: rotateY(0deg);\n  transition: transform var(--hb-vj7-d) cubic-bezier(0.45, 0.05, 0.25, 1);\n}\n.hb-vj7[data-active=\"true\"] .hb-vj7-leaf { transform: rotateY(-180deg); }\n.hb-vj7-face {\n  position: absolute;\n  inset: 0;\n  overflow: hidden;\n  -webkit-backface-visibility: hidden;\n  backface-visibility: hidden;\n  background: var(--hb-vj7-paper);\n}\n.hb-vj7-face[data-face=\"back\"] { transform: rotateY(180deg); }\n.hb-vj7-face > .hb-vj7-c {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  width: 200%;\n}\n.hb-vj7-face[data-face=\"front\"] > .hb-vj7-c { left: -100%; }\n.hb-vj7-face[data-face=\"back\"] > .hb-vj7-c { left: 0; }\n.hb-vj7-face::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n  transition: opacity var(--hb-vj7-d) cubic-bezier(0.45, 0.05, 0.25, 1);\n}\n.hb-vj7-face[data-face=\"front\"]::after {\n  background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.15) 30%, rgba(255, 255, 255, 0.08) 70%, rgba(0, 0, 0, 0.3));\n  opacity: 0;\n}\n.hb-vj7-face[data-face=\"back\"]::after {\n  background: linear-gradient(270deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.1) 35%, rgba(255, 255, 255, 0.1) 75%, rgba(0, 0, 0, 0.25));\n  opacity: 1;\n}\n.hb-vj7[data-active=\"true\"] .hb-vj7-face[data-face=\"front\"]::after { opacity: 1; }\n.hb-vj7[data-active=\"true\"] .hb-vj7-face[data-face=\"back\"]::after { opacity: 0; }\n.hb-vj7-spine {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 50%;\n  width: 28px;\n  margin-left: -14px;\n  pointer-events: none;\n  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.38) 46%, rgba(255, 255, 255, 0.06) 50%, rgba(0, 0, 0, 0.38) 54%, transparent);\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-vj7-l, .hb-vj7-l[data-on=\"true\"], .hb-vj7-leaf, .hb-vj7-shade, .hb-vj7-face::after { transition: none; }\n}\n`;\n\nfunction useSwap(\n  active: boolean | undefined,\n  defaultActive: boolean,\n  onActiveChange: ((active: boolean) => void) | undefined,\n  autoPlay: boolean,\n  interval: number,\n) {\n  const [inner, setInner] = React.useState(defaultActive);\n  const controlled = active !== undefined;\n  const value = controlled ? active : inner;\n  const set = React.useCallback(\n    (next: boolean) => {\n      if (!controlled) setInner(next);\n      onActiveChange?.(next);\n    },\n    [controlled, onActiveChange],\n  );\n  React.useEffect(() => {\n    if (!autoPlay) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    const id = window.setTimeout(() => set(!value), interval);\n    return () => window.clearTimeout(id);\n  }, [autoPlay, interval, value, set]);\n  return value;\n}\n\nfunction Scene({ tone, kicker, title }: { tone: string; kicker: string; title: string }) {\n  return (\n    <div style={{ display: \"grid\", alignContent: \"end\", gap: 4, padding: 20, minHeight: 180, background: tone, color: \"#ededed\" }}>\n      <span style={{ fontSize: 11, letterSpacing: \"0.14em\", textTransform: \"uppercase\", color: \"rgba(237,237,237,0.6)\" }}>{kicker}</span>\n      <strong style={{ fontSize: 20, fontWeight: 600, letterSpacing: \"-0.01em\" }}>{title}</strong>\n    </div>\n  );\n}\n\nexport function TransitionPageTurn({\n  children,\n  from,\n  to,\n  active,\n  defaultActive = false,\n  onActiveChange,\n  autoPlay = false,\n  interval = 3000,\n  duration = 1100,\n  paper = \"#111111\",\n  className,\n  style,\n  ...rest\n}: TransitionPageTurnProps) {\n  const value = useSwap(active, defaultActive, onActiveChange, autoPlay, interval);\n  const kids = React.Children.toArray(children);\n  const a = from ?? kids[0] ?? <Scene tone=\"linear-gradient(120deg, #1b1a17, #0e0d0b)\" kicker=\"Issue 14\" title=\"Field notes from the coast\" />;\n  const b = to ?? kids[1] ?? <Scene tone=\"linear-gradient(120deg, #17191d, #0b0c0e)\" kicker=\"Page 2\" title=\"Tide tables and maps\" />;\n\n  const vars = { \"--hb-vj7-d\": `${duration}ms`, \"--hb-vj7-paper\": paper } as React.CSSProperties;\n\n  return (\n    <div className={[\"hb-vj7\", className].filter(Boolean).join(\" \")} style={{ ...vars, ...style }} data-active={value} {...rest}>\n      <style href=\"hb-transition-page-turn\" precedence=\"default\">{css}</style>\n      <div className=\"hb-vj7-book\" aria-hidden=\"true\" inert>\n        <div className=\"hb-vj7-half\" data-side=\"l\">\n          <div className=\"hb-vj7-c\">{a}</div>\n          <div className=\"hb-vj7-shade\" />\n        </div>\n        <div className=\"hb-vj7-half\" data-side=\"r\">\n          <div className=\"hb-vj7-c\">{b}</div>\n          <div className=\"hb-vj7-shade\" />\n        </div>\n        <div className=\"hb-vj7-spine\" />\n        <div className=\"hb-vj7-leaf\">\n          <div className=\"hb-vj7-face\" data-face=\"front\">\n            <div className=\"hb-vj7-c\">{a}</div>\n          </div>\n          <div className=\"hb-vj7-face\" data-face=\"back\">\n            <div className=\"hb-vj7-c\">{b}</div>\n          </div>\n        </div>\n      </div>\n      <div className=\"hb-vj7-l\" data-on={!value} aria-hidden={value} inert={value}>{a}</div>\n      <div className=\"hb-vj7-l\" data-on={value} aria-hidden={!value} inert={!value}>{b}</div>\n    </div>\n  );\n}\n"
    }
  ]
}