{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion-text-shimmer",
  "title": "Text shimmer",
  "description": "A component that applies a shimmering effect to text.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "components/core/text-shimmer.tsx",
      "content": "'use client';\nimport React, { useMemo } from 'react';\nimport { motion } from 'motion/react';\nimport { motionElementOf } from './motion-elements';\nimport { cn } from '@/lib/utils';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\n\nexport type TextShimmerProps = {\n  children: string;\n  as?: React.ElementType;\n  className?: string;\n  duration?: number;\n  spread?: number;\n};\n\nconst SWEEP = {\n  backgroundPosition: '0% center',\n};\n\nfunction sweepOf(prefersReducedMotion: boolean | null) {\n  if (prefersReducedMotion) {\n    return undefined;\n  }\n  return SWEEP;\n}\n\nfunction TextShimmerComponent({\n  children,\n  as: Component = 'p',\n  className,\n  duration = 2,\n  spread = 2,\n}: TextShimmerProps) {\n  const MotionComponent = motionElementOf(Component) as typeof motion.p;\n  const prefersReducedMotion = usePrefersReducedMotion();\n\n  const dynamicSpread = useMemo(() => {\n    return children.length * spread;\n  }, [children, spread]);\n\n  return (\n    <MotionComponent\n      className={cn(\n        'relative inline-block bg-[length:250%_100%,auto] bg-clip-text',\n        'text-transparent [--base-color:var(--muted-foreground)] [--base-gradient-color:var(--foreground)]',\n        '[background-repeat:no-repeat,padding-box] [--bg:linear-gradient(90deg,transparent_calc(50%-var(--spread)),var(--base-gradient-color),transparent_calc(50%+var(--spread)))]',\n        className\n      )}\n      initial={{ backgroundPosition: '100% center' }}\n      animate={sweepOf(prefersReducedMotion)}\n      transition={{\n        repeat: Infinity,\n        duration,\n        ease: 'linear',\n      }}\n      style={\n        {\n          '--spread': `${dynamicSpread}px`,\n          backgroundImage: `var(--bg), linear-gradient(var(--base-color), var(--base-color))`,\n        } as React.CSSProperties\n      }\n    >\n      {children}\n    </MotionComponent>\n  );\n}\n\nexport const TextShimmer = React.memo(TextShimmerComponent);\n",
      "type": "registry:component",
      "target": "components/core/text-shimmer.tsx"
    },
    {
      "path": "components/core/motion-elements.ts",
      "content": "import { motion } from 'motion/react';\n\nconst MOTION_ELEMENTS = {\n  a: motion.a,\n  article: motion.article,\n  aside: motion.aside,\n  blockquote: motion.blockquote,\n  button: motion.button,\n  code: motion.code,\n  div: motion.div,\n  em: motion.em,\n  figure: motion.figure,\n  footer: motion.footer,\n  h1: motion.h1,\n  h2: motion.h2,\n  h3: motion.h3,\n  h4: motion.h4,\n  h5: motion.h5,\n  h6: motion.h6,\n  header: motion.header,\n  label: motion.label,\n  li: motion.li,\n  main: motion.main,\n  nav: motion.nav,\n  ol: motion.ol,\n  p: motion.p,\n  pre: motion.pre,\n  section: motion.section,\n  small: motion.small,\n  span: motion.span,\n  strong: motion.strong,\n  ul: motion.ul,\n};\n\ntype MotionElementTag = keyof typeof MOTION_ELEMENTS;\n\nfunction isMotionElementTag(tag: unknown): tag is MotionElementTag {\n  const isString = typeof tag === 'string';\n  return isString && tag in MOTION_ELEMENTS;\n}\n\n/**\n * The motion version of an HTML tag. A lookup such as `motion[tag]` is invisible to the bundler,\n * which drops the tags it never sees and breaks the production build, so every tag is listed here.\n */\nexport function motionElementOf(tag: unknown) {\n  if (isMotionElementTag(tag)) {\n    return MOTION_ELEMENTS[tag];\n  }\n  return MOTION_ELEMENTS.div;\n}\n",
      "type": "registry:component",
      "target": "components/core/motion-elements.ts"
    }
  ],
  "categories": [
    "motion"
  ],
  "type": "registry:component"
}