{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reveal",
  "type": "registry:ui",
  "title": "Reveal",
  "description": "Any block that arrives as it scrolls into view: a section heading, a card, a figure, a quote. It fades in and, depending on `effect`, rises a little, comes into focus or grows to size, once. Use it on the few things a reader should notice arriving, not on…",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "decorative",
    "effect"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json",
    "https://ds.interlace.tools/r/motion-token.json",
    "https://ds.interlace.tools/r/use-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/effects/reveal.tsx",
      "target": "components/ui/effects/reveal.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n// @interlace/reveal v1.0.1 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/reveal\n// What changed since: https://ds.interlace.tools/c/reveal#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — Reveal\n *\n * Any block that arrives as it scrolls into view: a section heading, a card, a\n * figure, a quote. It fades in and, depending on `effect`, rises a little,\n * comes into focus or grows to size, once. Use it on the few things a reader\n * should notice arriving, not on every element of a page.\n *\n * ## Content first\n *\n * The content is in the server HTML, fully visible, so a crawler, a reader\n * without scripts and a screen reader all get it. The browser hides it just\n * before the first paint and shows it as it enters the viewport. Nothing is\n * removed, repeated or moved in the reading order, and nothing loops.\n *\n * ## Motion\n *\n * It runs on the Web Animations API, so there are no keyframes to add, and\n * animates only `opacity`, `transform` and (for `blur`) `filter`, which the\n * compositor handles. Under `prefers-reduced-motion: reduce`, without\n * IntersectionObserver, or without `element.animate`, the content is simply\n * there. If anything inside receives focus before its turn, the block shows\n * at once, so focus never lands on something invisible. Blocks already in\n * view on load arrive straight away.\n *\n * ## Composition\n *\n *   Reveal                              (div — data-slot=\"reveal\", data-effect)\n *\n * | Rule | Concept                 | Where in this file                                   |\n * | ---- | ----------------------- | ---------------------------------------------------- |\n * | R4   | Extends native el       | `div` props                                           |\n * | R6   | data-slot per part      | reveal                                                |\n * | R7   | cn + ...rest            | `cn(className)` + `{...props}`                        |\n * | R8   | Enums, not booleans     | `effect`                                              |\n * | R25  | Client component        | the reveal runs in the browser                        |\n * | R26  | A11y from native el     | plain content; focus reveals at once                  |\n */\n\nimport { cn } from \"@/lib/utils\";\nimport { useReducedMotion } from \"@/hooks/use-reduced-motion\";\nimport { motionEase } from \"@/lib/motion-token\";\n\n/** Where each effect starts from. Every one ends at the element's own style. */\nconst FROM = {\n  fade: { opacity: 0 },\n  rise: { opacity: 0, transform: \"translateY(1rem)\" },\n  blur: { opacity: 0, filter: \"blur(0.5rem)\" },\n  scale: { opacity: 0, transform: \"scale(0.96)\" },\n} as const satisfies Record<string, Keyframe>;\n\nconst TO = {\n  fade: { opacity: 1 },\n  rise: { opacity: 1, transform: \"none\" },\n  blur: { opacity: 1, filter: \"none\" },\n  scale: { opacity: 1, transform: \"none\" },\n} as const satisfies Record<keyof typeof FROM, Keyframe>;\n\nexport type RevealEffect = keyof typeof FROM;\n\nexport interface RevealProps extends React.ComponentPropsWithoutRef<\"div\"> {\n  /** How the block arrives. Every effect fades; `rise` also lifts, `blur` sharpens, `scale` grows. @default 'rise' */\n  effect?: RevealEffect;\n  /** Milliseconds to wait after the block enters the viewport. Use it to sequence a few siblings. @default 0 */\n  delay?: number;\n  /** Milliseconds the arrival takes. @default 600 */\n  duration?: number;\n  /** How much of the block must be visible before it arrives, from 0 to 1. @default 0.2 */\n  amount?: number;\n}\n\nexport function Reveal({\n  effect = \"rise\",\n  delay = 0,\n  duration = 600,\n  amount = 0.2,\n  className,\n  children,\n  ...props\n}: RevealProps) {\n  const reduced = useReducedMotion();\n  const ref = React.useRef<HTMLDivElement>(null);\n\n  // Before paint: hide the block, so it can arrive instead of flashing.\n  React.useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el || reduced || typeof el.animate !== \"function\") return;\n    if (typeof IntersectionObserver === \"undefined\") return;\n    // Once played, a prop change (or a Fast Refresh) never plays it again.\n    if (el.dataset.revealed) return;\n    el.style.opacity = \"0\";\n\n    let io: IntersectionObserver | undefined;\n    const reveal = (wait: number) => {\n      if (el.dataset.revealed) return;\n      el.dataset.revealed = \"true\";\n      io?.disconnect();\n      el.style.opacity = \"\";\n      el.animate([FROM[effect], TO[effect]], {\n        duration,\n        delay: wait,\n        easing: motionEase(el, 'enter'),\n        fill: \"backwards\",\n      });\n    };\n    const onFocus = () => reveal(0);\n    el.addEventListener(\"focusin\", onFocus);\n\n    io = new IntersectionObserver(\n      (entries) => {\n        if (entries.some((e) => e.isIntersecting)) reveal(delay);\n      },\n      { threshold: Math.min(1, Math.max(0, amount)) },\n    );\n    io.observe(el);\n\n    return () => {\n      io?.disconnect();\n      el.removeEventListener(\"focusin\", onFocus);\n      el.style.opacity = \"\";\n      for (const a of el.getAnimations?.() ?? []) a.cancel();\n    };\n  }, [reduced, effect, delay, duration, amount]);\n\n  return (\n    <div\n      ref={ref}\n      data-slot=\"reveal\"\n      data-effect={effect}\n      className={cn(className)}\n      {...props}\n    >\n      {children}\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "tier": "effect",
    "client": true,
    "minViewport": null,
    "loading": false,
    "version": "1.0.1",
    "since": "2.0.0"
  },
  "docs": "## @interlace/reveal\n\nInstalled to `components/ui/effects/reveal.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/effects/reveal';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/reveal\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
