'use client'; import { motion, MotionValue, useScroll, useTransform } from 'framer-motion'; import { FC, ReactNode, useRef } from 'react'; import { cn } 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: MotionValue; range: [number, number]; } const Word: FC = ({ children, progress, range }) => { const opacity = useTransform(progress, range, [0, 1]); return ( {children} {children} ); }; export default TextRevealByWord;