Skip to content

Commit d3818eb

Browse files
Improved animation of the image on the aboutme nad home page
1 parent b4b7b2a commit d3818eb

File tree

3 files changed

+105
-16
lines changed

3 files changed

+105
-16
lines changed

src/components/AniText.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// AniText.tsx
2+
import React, { useState, useEffect } from "react";
3+
4+
interface AniTextProps {
5+
texts: string[];
6+
typingSpeed?: number; // milliseconds per character
7+
pauseTime?: number; // milliseconds to wait before erasing
8+
}
9+
10+
const AniText: React.FC<AniTextProps> = ({
11+
texts,
12+
typingSpeed = 100,
13+
pauseTime = 1500,
14+
}) => {
15+
const [displayedText, setDisplayedText] = useState("");
16+
const [textIndex, setTextIndex] = useState(0);
17+
const [isDeleting, setIsDeleting] = useState(false);
18+
19+
useEffect(() => {
20+
const currentText = texts[textIndex];
21+
let timer: NodeJS.Timeout;
22+
23+
if (!isDeleting && displayedText.length < currentText.length) {
24+
// Typing
25+
timer = setTimeout(() => {
26+
setDisplayedText(currentText.slice(0, displayedText.length + 1));
27+
}, typingSpeed);
28+
} else if (isDeleting && displayedText.length > 0) {
29+
// Deleting
30+
timer = setTimeout(() => {
31+
setDisplayedText(currentText.slice(0, displayedText.length - 1));
32+
}, typingSpeed / 2); // faster deleting
33+
} else if (!isDeleting && displayedText.length === currentText.length) {
34+
// Pause before deleting
35+
timer = setTimeout(() => setIsDeleting(true), pauseTime);
36+
} else if (isDeleting && displayedText.length === 0) {
37+
// Move to next text
38+
setIsDeleting(false);
39+
setTextIndex((prev) => (prev + 1) % texts.length);
40+
}
41+
42+
return () => clearTimeout(timer);
43+
}, [displayedText, isDeleting, texts, textIndex, typingSpeed, pauseTime]);
44+
45+
return (
46+
<span>
47+
{displayedText}
48+
<span className="animate-blink">|</span>
49+
<style>{`
50+
.animate-blink {
51+
animation: blink 1s step-start infinite;
52+
}
53+
@keyframes blink {
54+
50% { opacity: 0; }
55+
}
56+
`}</style>
57+
</span>
58+
);
59+
};
60+
61+
export default AniText;

src/pages/Home.tsx

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import { Link } from "react-router-dom";
22
import { motion, AnimatePresence } from "framer-motion";
33
import {
4-
BarChart,
5-
Brain,
6-
Code,
74
Github,
85
Linkedin,
96
Mail,
10-
Instagram,
11-
Facebook,
12-
Twitter,
137
ArrowRight,
148
} from "lucide-react";
159
import { SiKaggle, SiMedium } from "react-icons/si";
@@ -22,6 +16,7 @@ import myphoto from "../data/img/me/my_photo2.png";
2216
import TechnicalProficiencies from "../data/skillsData";
2317
import Achievements from "../data/AchievementData";
2418
import ResearchComponent from "../components/research";
19+
import AniText from "../components/AniText";
2520

2621
const Home: React.FC = () => {
2722
const itemVariants = {
@@ -91,7 +86,18 @@ const Home: React.FC = () => {
9186
<p className="text-1xl text-gray-750">IIT Kharagpur | Applied ML & AI Researcher</p>
9287
</div>
9388
<h2 className="text-1xl md:text-1xl text-gray-800 font-semibold mb-2">
94-
Applied ML & Quantitative Finance Enthusiast
89+
<AniText
90+
texts={[
91+
"Data Science & Applied ML Researcher",
92+
"Machine Learning & Optimization Specialist",
93+
"AI-Driven Solutions enthusiast",
94+
"Hackathon & Competition Champion",
95+
"Quantitative Finance Enthusiast",
96+
"Deep Learning Enthusiast",
97+
]}
98+
typingSpeed={50}
99+
pauseTime={1500}
100+
/>
95101
</h2>
96102
<p className="text-1xl md:text-1xl text-gray-700 mb-4 text-sm md:text leading-relaxed">
97103
Building intelligent, data-driven systems that bridge Machine Learning, Engineering, and Quantitative Finance. I specialize in developing scalable AI solutions for prediction, optimization, and decision-making — transforming research into real-world impact.
@@ -226,12 +232,21 @@ const Home: React.FC = () => {
226232
<div className="absolute inset-0 rounded-full bg-gradient-to-tr from-blue-200 via-indigo-200 to-purple-200 blur-3xl opacity-60 animate-pulse"></div>
227233

228234
{/* Profile Image */}
229-
<div className="relative z-10 w-[320px] h-[500px] mx-auto overflow-hidden rounded-[2rem] border-[3px] border-blue-200 shadow-2xl hover:shadow-blue-400/50 transition-all duration-500 hover:scale-[1.03]">
230-
<img
231-
src={myphoto}
232-
alt="Arpit Kumar"
233-
className="w-full h-full object-cover object-center"
234-
/>
235+
<div className="relative w-full aspect-square max-w-sm mx-auto group">
236+
{/* Animated Gradient Ring */}
237+
<div className="absolute inset-0 rounded-[3rem] p-1 bg-[conic-gradient(at_top_right,_var(--tw-gradient-stops))] from-indigo-500 via-blue-500 to-purple-500 group-hover:animate-spin-medium blur-sm" />
238+
239+
{/* Outer Glow */}
240+
<div className="absolute inset-0 rounded-[2rem] bg-indigo-500/10 blur-2xl scale-105 -z-10" />
241+
242+
<div className="relative z-10 rounded-[2rem] overflow-hidden bg-white/40 backdrop-blur-lg shadow-2xl transition-transform duration-500 group-hover:scale-105">
243+
<img
244+
src={myphoto}
245+
alt="Professional headshot of Arpit Kumar"
246+
className="w-full h-full object-cover rounded-[2rem] transition-transform duration-500 group-hover:scale-110"
247+
loading="lazy"
248+
/>
249+
</div>
235250
</div>
236251
</div>
237252
</motion.div>
@@ -256,7 +271,7 @@ const Home: React.FC = () => {
256271
</motion.div>
257272

258273
{/* Research Section */}
259-
<ResearchComponent />
274+
<ResearchComponent />
260275

261276
{/* Experience Section */}
262277
<section className="mb-16">

src/pages/aboutme.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
} from "lucide-react";
1111
import { BiRightArrow } from "react-icons/bi";
1212
import { Link } from "react-router-dom";
13+
import AniText from "../components/AniText";
14+
1315

1416
// SkillTag Component
1517
type SkillTagProps = {
@@ -80,7 +82,7 @@ const AboutMe: React.FC = () => {
8082
>
8183
<div className="relative w-full aspect-square max-w-sm mx-auto group">
8284
{/* Animated Gradient Ring */}
83-
<div className="absolute inset-0 rounded-[2rem] p-1 bg-[conic-gradient(at_top_right,_var(--tw-gradient-stops))] from-indigo-500 via-blue-500 to-purple-500 animate-spin-slow group-hover:animate-spin-medium blur-sm" />
85+
<div className="absolute inset-0 rounded-[3rem] p-1 bg-[conic-gradient(at_top_right,_var(--tw-gradient-stops))] from-indigo-500 via-blue-500 to-purple-500 group-hover:animate-spin-medium blur-sm" />
8486

8587
{/* Outer Glow */}
8688
<div className="absolute inset-0 rounded-[2rem] bg-indigo-500/10 blur-2xl scale-105 -z-10" />
@@ -112,7 +114,18 @@ const AboutMe: React.FC = () => {
112114
Arpit Kumar
113115
</h1>
114116
<p className="mt-2 text-lg font-medium text-indigo-600 tracking-tight">
115-
Applied ML & AI Researcher
117+
<AniText
118+
texts={[
119+
"Data Science & Applied ML Researcher",
120+
"Machine Learning & Optimization Specialist",
121+
"AI-Driven Solutions Enthusiast",
122+
"Hackathon & Competition Champion",
123+
"Quantitative Finance Enthusiast",
124+
"Deep Learning Enthusiast",
125+
]}
126+
typingSpeed={50}
127+
pauseTime={1500}
128+
/>
116129
</p>
117130
</div>
118131

0 commit comments

Comments
 (0)