Skip to content

Commit f90d120

Browse files
committed
Front Text unpdate!
1 parent 6cddbd8 commit f90d120

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

Ashif/src/components/hero.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import React from 'react';
22
import Spline from '@splinetool/react-spline';
33
import { ArrowRight } from 'lucide-react';
44
import RotatingText from './RotatingText';
5-
import { SparklesText } from "@/components/ui/sparkles-text";
5+
import { WordRotate } from "@/components/ui/word-rotate";
66

77
/**
88
* A modern, minimal hero section component.
99
*/
1010
export default function Hero() {
1111
const skills = ['UI/UX Designer', 'Frontend Developer', 'Backend Developer', 'Creative Coder'];
12+
const greetings = ["Hello", "Hola", "Ciao", "مرحبا"];
1213

1314
return (
1415
<section className="relative w-full h-screen overflow-hidden">
@@ -24,8 +25,9 @@ export default function Hero() {
2425
{/* Content is aligned to the center */}
2526
<div className="relative z-20 flex items-center justify-center w-full h-full p-8 text-center bg-black/20 pointer-events-none sm:p-16 md:p-24">
2627
<div className="max-w-md pointer-events-auto">
27-
<h1 className="font-pixel text-5xl font-bold text-white whitespace-nowrap md:text-7xl lg:text-8xl [text-shadow:_0_3px_5px_rgb(0_0_0_/_40%)]">
28-
<SparklesText>Hello, I'm</SparklesText>
28+
<h1 className="font-pixel flex items-center justify-center gap-x-2 text-5xl font-bold text-white md:text-7xl lg:text-8xl [text-shadow:_0_3px_5px_rgb(0_0_0_/_40%)]">
29+
<WordRotate words={greetings} />
30+
{", I'm"}
2931
</h1>
3032

3133
{/* Rotating Text for Skills */}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { useEffect, useState } from "react"
2+
import { AnimatePresence, motion, MotionProps } from "motion/react"
3+
4+
import { cn } from "@/lib/utils"
5+
6+
interface WordRotateProps {
7+
words: string[]
8+
duration?: number
9+
motionProps?: MotionProps
10+
className?: string
11+
}
12+
13+
export function WordRotate({
14+
words,
15+
duration = 2500,
16+
motionProps = {
17+
initial: { opacity: 0, y: -50 },
18+
animate: { opacity: 1, y: 0 },
19+
exit: { opacity: 0, y: 50 },
20+
transition: { duration: 0.25, ease: "easeOut" },
21+
},
22+
className,
23+
}: WordRotateProps) {
24+
const [index, setIndex] = useState(0)
25+
26+
useEffect(() => {
27+
const interval = setInterval(() => {
28+
setIndex((prevIndex) => (prevIndex + 1) % words.length)
29+
}, duration)
30+
31+
// Clean up interval on unmount
32+
return () => clearInterval(interval)
33+
}, [words, duration])
34+
35+
return (
36+
<div className="overflow-hidden py-2">
37+
<AnimatePresence mode="wait">
38+
<motion.h1
39+
key={words[index]}
40+
className={cn(className)}
41+
{...motionProps}
42+
>
43+
{words[index]}
44+
</motion.h1>
45+
</AnimatePresence>
46+
</div>
47+
)
48+
}

0 commit comments

Comments
 (0)