{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"box-reveal","type":"registry:ui","title":"BoxReveal","description":"Reveal animation where a solid color box slides left to right across content on viewport entry, unveiling it as it fades up into place underneath, triggered once via IntersectionObserver","author":"fancy-ui <https://fancy-ui.rama.app>","categories":["text"],"registryDependencies":["https://fancy-ui.rama.app/r/utils.json"],"files":[{"path":"react/src/components/box-reveal/BoxReveal.tsx","content":"\"use client\";\n\nimport { useEffect, useRef, useState, type HTMLAttributes, type ReactNode } from \"react\";\nimport { cn } from \"../../utils\";\n\n/**\n * BoxReveal - Sliding box reveal animation\n *\n * Content fades up while a colored box slides from left to right,\n * revealing the content underneath. Triggers when entering viewport\n * via IntersectionObserver.\n */\nexport interface BoxRevealProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\" | \"children\"> {\n\t/** Color of the reveal box */\n\tcolor?: string;\n\t/** Animation duration in seconds */\n\tduration?: number;\n\t/** Delay before animation starts (seconds) */\n\tdelay?: number;\n\t/** Additional CSS classes */\n\tclassName?: string;\n\tchildren: ReactNode;\n}\n\nexport function BoxReveal({\n\tcolor = \"#5046e6\",\n\tduration = 0.5,\n\tdelay = 0.25,\n\tclassName,\n\tchildren,\n\t...props\n}: BoxRevealProps) {\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\tconst [isInView, setIsInView] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst el = containerRef.current;\n\t\tif (!el) return;\n\n\t\tconst observer = new IntersectionObserver(\n\t\t\t(entries) => {\n\t\t\t\tif (entries[0]?.isIntersecting) {\n\t\t\t\t\tsetIsInView(true);\n\t\t\t\t\tobserver.disconnect();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ threshold: 0.1 }\n\t\t);\n\n\t\tobserver.observe(el);\n\n\t\treturn () => observer.disconnect();\n\t}, []);\n\n\treturn (\n\t\t<div ref={containerRef} className={cn(\"box-reveal relative overflow-hidden\", className)} {...props}>\n\t\t\t{/* Content (fades up) */}\n\t\t\t<div\n\t\t\t\tclassName=\"box-reveal-content\"\n\t\t\t\tstyle={{\n\t\t\t\t\topacity: isInView ? 1 : 0,\n\t\t\t\t\ttransform: `translateY(${isInView ? 0 : 25}px)`,\n\t\t\t\t\ttransition: `opacity ${duration}s ease ${delay * 2}s,transform ${duration}s ease ${delay * 2}s`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\n\t\t\t{/* Sliding box overlay */}\n\t\t\t<div\n\t\t\t\tclassName=\"box-reveal-overlay absolute inset-0 z-20\"\n\t\t\t\tstyle={{\n\t\t\t\t\tbackground: color,\n\t\t\t\t\tleft: isInView ? \"100%\" : \"0%\",\n\t\t\t\t\ttransition: `left ${duration}s ease-in ${delay}s`,\n\t\t\t\t}}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n","type":"registry:ui","target":"@ui/fancy/components/box-reveal/BoxReveal.tsx"},{"path":"react/src/components/box-reveal/index.ts","content":"\"use client\";\n\nexport { BoxReveal } from \"./BoxReveal\";\nexport type { BoxRevealProps } from \"./BoxReveal\";\n","type":"registry:ui","target":"@ui/fancy/components/box-reveal/index.ts"}],"meta":{"license":"MIT","package":"fancy-ui-react","version":"0.7.0","source":"https://fancy-ui.rama.app/docs/components/box-reveal?framework=react"}}