'use client' import { motion, useScroll, useTransform } from 'framer-motion' import type { FC, ReactNode } from 'react' import { useRef } from 'react' import { ny } from '@/lib/utils' interface TextRevealByWordProps { text: string className?: string } export const TextRevealByWord: FC = ({ text, className, }) => { const targetRef = useRef(null) const { scrollYProgress } = useScroll({ target: targetRef, }) const words = text.split(' ') return (

{words.map((word, i) => { const start = i / words.length const end = start + 1 / words.length return ( {word} ) })}

) } interface WordProps { children: ReactNode progress: any range: [number, number] } const Word: FC = ({ children, progress, range }) => { const opacity = useTransform(progress, range, [0, 1]) return ( {children} {children} ) } export default TextRevealByWord