diff --git a/src/components/stateless/SlideText/index.jsx b/src/components/stateless/SlideText/index.jsx index 65d693d2..948a9f07 100644 --- a/src/components/stateless/SlideText/index.jsx +++ b/src/components/stateless/SlideText/index.jsx @@ -1,6 +1,5 @@ import React, { useEffect, useMemo, useState } from 'react' import { motion } from 'motion/react' -import { MoveRight, PhoneCall } from 'lucide-react' const SlideText = ({ text = [] }) => { const [titleNumber, setTitleNumber] = useState(0) diff --git a/src/components/stateless/SparklesText/index.jsx b/src/components/stateless/SparklesText/index.jsx new file mode 100644 index 00000000..ae4ac1f5 --- /dev/null +++ b/src/components/stateless/SparklesText/index.jsx @@ -0,0 +1,92 @@ +import { CSSProperties, ReactElement, useEffect, useState } from 'react' +import { motion } from 'motion/react' +import clsx from 'clsx' + +const SparklesText = ({ + text, + colors = { first: '#9E7AFF', second: '#FE8BBB' }, + className, + sparklesCount = 10, + ...props +}) => { + const [sparkles, setSparkles] = useState([]) + + useEffect(() => { + const generateStar = () => { + const starX = `${Math.random() * 100}%` + const starY = `${Math.random() * 100}%` + const color = Math.random() > 0.5 ? colors.first : colors.second + const delay = Math.random() * 2 + const scale = Math.random() * 1 + 0.3 + const lifespan = Math.random() * 10 + 5 + const id = `${starX}-${starY}-${Date.now()}` + return { id, x: starX, y: starY, color, delay, scale, lifespan } + } + + const initializeStars = () => { + const newSparkles = Array.from({ length: sparklesCount }, generateStar) + setSparkles(newSparkles) + } + + const updateStars = () => { + setSparkles((currentSparkles) => + currentSparkles.map((star) => { + if (star.lifespan <= 0) { + return generateStar() + } else { + return { ...star, lifespan: star.lifespan - 0.1 } + } + }) + ) + } + + initializeStars() + const interval = setInterval(updateStars, 100) + + return () => clearInterval(interval) + }, [colors.first, colors.second]) + + return ( +
+ + {sparkles.map((sparkle) => ( + + ))} + {text} + +
+ ) +} + +const Sparkle = ({ id, x, y, color, delay, scale }) => { + return ( + + + + ) +} + +export default SparklesText diff --git a/src/pages/home/index.jsx b/src/pages/home/index.jsx index 0ce23096..1796c10b 100644 --- a/src/pages/home/index.jsx +++ b/src/pages/home/index.jsx @@ -50,6 +50,7 @@ import BackgroundBoxes from '@stateless/BackgroundBoxes' import TypeWriter from '@stateless/TypeWriter' import SlideText from '@stateless/SlideText' import SparklesCore from '@stateless/Sparkles' +import SparklesText from '@stateless/SparklesText' import firstImage from '@assets/images/88-300x160.jpg' import secondImage from '@assets/images/2-300x160.jpg' @@ -289,6 +290,10 @@ const Home = () => { This is something +
+ +
+