()
| 6 | const text = ['Syntax UI', 'UI Library', 'Text Flip'] |
| 7 | |
| 8 | const TextFlip = () => { |
| 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 mode="wait"> |
| 24 | <motion.div |
| 25 | className="absolute cursor-pointer text-3xl font-semibold tracking-tight text-red-500" |
| 26 | key={index} |
| 27 | initial={{ rotateX: 90, opacity: 0 }} |
| 28 | animate={{ rotateX: 0, opacity: 1 }} |
| 29 | exit={{ rotateX: -90, opacity: 0 }} |
| 30 | transition={{ duration: 0.2 }} |
| 31 | > |
| 32 | {text[index]} |
| 33 | </motion.div> |
| 34 | </AnimatePresence> |
| 35 | </div> |
| 36 | ) |
| 37 | } |
| 38 | |
| 39 | export default TextFlip |
nothing calls this directly
no outgoing calls
no test coverage detected