{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "transition-diagonal-slice",
  "type": "registry:component",
  "title": "Transition Diagonal Slice",
  "description": "The next view arrives cut into slanted bands that slide in along their own angle, alternating from top and bottom. The view behind recedes and dims while the bands lock together.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "transitions",
    "slice",
    "diagonal",
    "bands",
    "stagger",
    "transition"
  ],
  "docs": "https://hyperblur.dev/effects/transition-diagonal-slice",
  "files": [
    {
      "path": "registry/hyperblur/transition-diagonal-slice.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/transition-diagonal-slice.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TransitionDiagonalSliceProps 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  stagger?: number;\n  slices?: number;\n  slant?: number;\n  accent?: string;\n}\n\nconst css = `\n.hb-vj2 {\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-vj2 *, .hb-vj2 *::before, .hb-vj2 *::after { box-sizing: border-box; }\n.hb-vj2-l {\n  grid-area: 1 / 1;\n  display: grid;\n  min-width: 0;\n  min-height: 0;\n}\n.hb-vj2-from {\n  z-index: 0;\n  transform-origin: 50% 50%;\n  transition: transform var(--hb-vj2-t) cubic-bezier(0.22, 1, 0.36, 1), filter var(--hb-vj2-t) cubic-bezier(0.22, 1, 0.36, 1);\n}\n.hb-vj2[data-active=\"true\"] .hb-vj2-from {\n  transform: scale(0.94) translateX(-3%);\n  filter: brightness(0.4) saturate(0.6);\n}\n.hb-vj2-to {\n  position: relative;\n  z-index: 2;\n  visibility: hidden;\n  transition: visibility 0s linear 0s;\n}\n.hb-vj2[data-active=\"true\"] .hb-vj2-to {\n  visibility: visible;\n  transition: visibility 0s linear var(--hb-vj2-t);\n}\n.hb-vj2-band {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  display: grid;\n  pointer-events: none;\n  will-change: transform;\n  transform: translate(var(--hb-vj2-tx), var(--hb-vj2-ty));\n  transition: transform var(--hb-vj2-d) cubic-bezier(0.76, 0, 0.18, 1) var(--hb-vj2-out);\n}\n.hb-vj2[data-active=\"true\"] .hb-vj2-band {\n  transform: translate(0, 0);\n  transition-delay: var(--hb-vj2-in);\n}\n.hb-vj2-band > .hb-vj2-c {\n  display: grid;\n  min-width: 0;\n  min-height: 0;\n}\n.hb-vj2-edge {\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--hb-vj2-acc) 90%, #ffffff), transparent);\n  opacity: 0;\n}\n.hb-vj2[data-ran=\"true\"][data-active=\"true\"] .hb-vj2-edge { animation: hb-vj2-glint-a var(--hb-vj2-d) cubic-bezier(0.76, 0, 0.18, 1) var(--hb-vj2-in) both; }\n.hb-vj2[data-ran=\"true\"][data-active=\"false\"] .hb-vj2-edge { animation: hb-vj2-glint-b var(--hb-vj2-d) cubic-bezier(0.76, 0, 0.18, 1) var(--hb-vj2-out) both; }\n@keyframes hb-vj2-glint-a { 0% { opacity: 0; } 35% { opacity: 0.95; } 100% { opacity: 0; } }\n@keyframes hb-vj2-glint-b { 0% { opacity: 0; } 50% { opacity: 0.7; } 100% { opacity: 0; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-vj2-from, .hb-vj2-band, .hb-vj2-to, .hb-vj2[data-active=\"true\"] .hb-vj2-to, .hb-vj2[data-active=\"true\"] .hb-vj2-band { transition: none; }\n  .hb-vj2[data-ran=\"true\"] .hb-vj2-edge { animation: 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\nconst pct = (n: number) => `${n.toFixed(2)}%`;\n\nexport function TransitionDiagonalSlice({\n  children,\n  from,\n  to,\n  active,\n  defaultActive = false,\n  onActiveChange,\n  autoPlay = false,\n  interval = 2600,\n  duration = 720,\n  stagger = 70,\n  slices = 5,\n  slant = 24,\n  accent = \"#2f7bff\",\n  className,\n  style,\n  ...rest\n}: TransitionDiagonalSliceProps) {\n  const value = useSwap(active, defaultActive, onActiveChange, autoPlay, interval);\n  const [prev, setPrev] = React.useState(value);\n  const [ran, setRan] = React.useState(false);\n  if (prev !== value) {\n    setPrev(value);\n    setRan(true);\n  }\n  const kids = React.Children.toArray(children);\n  const a = from ?? kids[0] ?? <Scene tone=\"linear-gradient(150deg, #1f2937, #0b0d12)\" kicker=\"Drop 01\" title=\"Field jacket, olive\" />;\n  const b = to ?? kids[1] ?? <Scene tone=\"linear-gradient(150deg, #312e81, #0b0a1a)\" kicker=\"Drop 02\" title=\"Trail shell, indigo\" />;\n  const n = Math.max(2, Math.round(slices));\n  const s = Math.max(0, slant);\n  const w = (100 + s) / n;\n  const total = duration + (n - 1) * stagger;\n\n  const vars = {\n    \"--hb-vj2-d\": `${duration}ms`,\n    \"--hb-vj2-t\": `${total}ms`,\n    \"--hb-vj2-acc\": accent,\n  } as React.CSSProperties;\n\n  const bands = Array.from({ length: n }, (_, i) => {\n    const l = i * w - 0.25;\n    const r = (i + 1) * w + 0.25;\n    const clip = `polygon(${pct(l)} 0%, ${pct(r)} 0%, ${pct(r - s)} 100%, ${pct(l - s)} 100%)`;\n    const edge = `polygon(${pct(l)} 0%, ${pct(l + 0.9)} 0%, ${pct(l + 0.9 - s)} 100%, ${pct(l - s)} 100%)`;\n    const up = i % 2 === 0;\n    const bandVars = {\n      clipPath: clip,\n      \"--hb-vj2-tx\": up ? pct(s) : pct(-s),\n      \"--hb-vj2-ty\": up ? \"-101%\" : \"101%\",\n      \"--hb-vj2-in\": `${i * stagger}ms`,\n      \"--hb-vj2-out\": `${(n - 1 - i) * stagger}ms`,\n    } as React.CSSProperties;\n    return (\n      <div key={i} className=\"hb-vj2-band\" style={bandVars} aria-hidden=\"true\" inert>\n        <div className=\"hb-vj2-c\">{b}</div>\n        <div className=\"hb-vj2-edge\" style={{ clipPath: edge }} />\n      </div>\n    );\n  });\n\n  return (\n    <div className={[\"hb-vj2\", className].filter(Boolean).join(\" \")} style={{ ...vars, ...style }} data-active={value} data-ran={ran} {...rest}>\n      <style href=\"hb-transition-diagonal-slice\" precedence=\"default\">{css}</style>\n      <div className=\"hb-vj2-l hb-vj2-from\" aria-hidden={value} inert={value}>{a}</div>\n      {bands}\n      <div className=\"hb-vj2-l hb-vj2-to\" aria-hidden={!value} inert={!value}>{b}</div>\n    </div>\n  );\n}\n"
    }
  ]
}