(phrase: string, callback: () => void)
| 311 | setIsTyping(true) |
| 312 | |
| 313 | const typePhrase = (phrase: string, callback: () => void) => { |
| 314 | let index = 0 |
| 315 | |
| 316 | const typeNextChar = () => { |
| 317 | if (index < phrase.length) { |
| 318 | setTypingText(phrase.substring(0, index + 1)) |
| 319 | index++ |
| 320 | |
| 321 | // Random typing speed between 50ms and 150ms for realistic effect |
| 322 | const typingSpeed = Math.floor(Math.random() * 100) + 50 |
| 323 | setTimeout(typeNextChar, typingSpeed) |
| 324 | } else { |
| 325 | // Phrase is fully typed, wait before moving to next phrase |
| 326 | setTimeout(callback, 1500) |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | typeNextChar() |
| 331 | } |
| 332 | |
| 333 | const startNextPhrase = () => { |
| 334 | const phrase = PHRASES_TO_TYPE[currentPhraseIndex] |
no test coverage detected