()
| 6 | const text = ['Syntax UI', 'UI Library', 'Text Rotate'] |
| 7 | |
| 8 | const TextRotate = () => { |
| 9 | const [index, setIndex] = useState(0) |
| 10 | |
| 11 | useEffect(() => { |
| 12 | const id = setInterval(() => { |
| 13 | setIndex((state) => { |
| 14 | if (state >= text.length - 1) return 0 |
| 15 | return state + 1 |
| 16 | }) |
| 17 | }, 2000) |
| 18 | return () => clearInterval(id) |
| 19 | }, []) |
| 20 | |
| 21 | return ( |
| 22 | <div className="relative flex w-full items-center justify-center py-4 text-center"> |
| 23 | <AnimatePresence> |
| 24 | <motion.div |
| 25 | className="absolute cursor-pointer text-3xl font-semibold tracking-tight text-red-500" |
| 26 | key={index} |
| 27 | initial={{ y: 20, opacity: 0, scale: 0.8 }} |
| 28 | animate={{ y: 0, opacity: 1, scale: 1 }} |
| 29 | exit={{ y: -20, opacity: 0, scale: 0.8 }} |
| 30 | transition={{ ease: 'easeInOut', delay: 0.2, duration: 0.5 }} |
| 31 | whileHover={{ scale: 1.1 }} |
| 32 | > |
| 33 | {text[index]} |
| 34 | </motion.div> |
| 35 | </AnimatePresence> |
| 36 | </div> |
| 37 | ) |
| 38 | } |
| 39 | |
| 40 | export default TextRotate |
nothing calls this directly
no outgoing calls
no test coverage detected