2023-06-28 01:12:17 +00:00
|
|
|
import { Box } from '@chakra-ui/react'
|
2023-06-27 01:18:08 +00:00
|
|
|
import { RainbowText } from './rainbowText'
|
|
|
|
import React from 'react'
|
|
|
|
|
|
|
|
export const TextAnimation1 = props => {
|
|
|
|
const texts = React.useMemo(() => {
|
|
|
|
return [
|
2023-06-27 08:09:21 +00:00
|
|
|
'thingtime',
|
|
|
|
'vibrant',
|
|
|
|
'infinite',
|
2023-06-28 01:12:17 +00:00
|
|
|
'creative',
|
|
|
|
'powerful',
|
2023-06-27 08:09:21 +00:00
|
|
|
'magical',
|
2023-06-28 01:12:17 +00:00
|
|
|
'inspiring',
|
|
|
|
'love',
|
|
|
|
'tt'
|
2023-06-27 01:18:08 +00:00
|
|
|
]
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
const [titleText, setTitleText] = React.useState(texts[0])
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
2023-06-28 01:12:17 +00:00
|
|
|
const newTimeout = Math.random() * 1500 + 2500
|
2023-06-27 08:09:21 +00:00
|
|
|
|
|
|
|
setTimeout(() => {
|
2023-06-28 01:12:17 +00:00
|
|
|
// let newTextIdx = Math.round(Math.random() * (texts.length - 1))
|
|
|
|
let newTextIdx = texts?.indexOf(titleText) + 1
|
|
|
|
// if (newTextIdx === texts.indexOf(titleText)) {
|
|
|
|
// newTextIdx = newTextIdx + 1
|
|
|
|
// }
|
2023-06-27 01:18:08 +00:00
|
|
|
const newText = texts[newTextIdx] || texts[0]
|
|
|
|
setTitleText(newText)
|
2023-06-27 08:09:21 +00:00
|
|
|
}, newTimeout)
|
2023-06-27 01:18:08 +00:00
|
|
|
}, [titleText, texts])
|
|
|
|
|
|
|
|
return <RainbowText>{titleText}</RainbowText>
|
|
|
|
}
|