()
| 3 | import React, { useState, useEffect } from 'react' |
| 4 | |
| 5 | const TextScramble: React.FC = () => { |
| 6 | const [text, setText] = useState('') |
| 7 | const finalText = 'SyntaxUI' |
| 8 | const chars = '!<>-_\\/[]{}—=+*^?#________' |
| 9 | |
| 10 | useEffect(() => { |
| 11 | let iteration = 0 |
| 12 | const interval = setInterval(() => { |
| 13 | setText((prevText) => |
| 14 | finalText |
| 15 | .split('') |
| 16 | .map((letter, index) => { |
| 17 | if (index < iteration) { |
| 18 | return finalText[index] |
| 19 | } |
| 20 | return chars[Math.floor(Math.random() * chars.length)] |
| 21 | }) |
| 22 | .join(''), |
| 23 | ) |
| 24 | |
| 25 | if (iteration >= finalText.length) { |
| 26 | clearInterval(interval) |
| 27 | } |
| 28 | |
| 29 | iteration += 1 / 3 |
| 30 | }, 30) |
| 31 | |
| 32 | return () => clearInterval(interval) |
| 33 | }, []) |
| 34 | |
| 35 | return ( |
| 36 | <div className="text-2xl font-semibold tabular-nums tracking-tight"> |
| 37 | <div className="text-center text-red-500">{text}</div> |
| 38 | </div> |
| 39 | ) |
| 40 | } |
| 41 | |
| 42 | export default TextScramble |
nothing calls this directly
no outgoing calls
no test coverage detected