|
| 1 | +import React, { useState, useEffect } from 'react'; |
| 2 | + |
| 3 | +const ROLES_LIST = ["Software", "Backend"]; |
| 4 | + |
1 | 5 | const Bio = () => { |
| 6 | + const [currentRoleIndex, setCurrentRoleIndex] = useState(0); |
| 7 | + const [displayedText, setDisplayedText] = useState(''); |
| 8 | + const [isDeleting, setIsDeleting] = useState(false); |
| 9 | + const [typingSpeed, setTypingSpeed] = useState(150); |
| 10 | + const pauseDuration = 2000; |
| 11 | + |
| 12 | + useEffect(() => { |
| 13 | + const handleTyping = () => { |
| 14 | + const currentRole = ROLES_LIST[currentRoleIndex]; |
| 15 | + if (isDeleting) { |
| 16 | + setDisplayedText(currentRole.substring(0, displayedText.length - 1)); |
| 17 | + setTypingSpeed(75); |
| 18 | + } else { |
| 19 | + setDisplayedText(currentRole.substring(0, displayedText.length + 1)); |
| 20 | + setTypingSpeed(150); |
| 21 | + } |
| 22 | + |
| 23 | + if (!isDeleting && displayedText === currentRole) { |
| 24 | + setTimeout(() => setIsDeleting(true), pauseDuration); |
| 25 | + } else if (isDeleting && displayedText === '') { |
| 26 | + setIsDeleting(false); |
| 27 | + setCurrentRoleIndex((prevIndex) => (prevIndex + 1) % ROLES_LIST.length); |
| 28 | + } |
| 29 | + }; |
| 30 | + |
| 31 | + const timer = setTimeout(handleTyping, typingSpeed); |
| 32 | + return () => clearTimeout(timer); |
| 33 | + }, [displayedText, isDeleting, currentRoleIndex, typingSpeed, pauseDuration]); |
| 34 | + |
2 | 35 | return ( |
3 | | - <section id="bio" className="py-10 flex items-center justify-center bg-gray-50 dark:bg-gray-900"> |
| 36 | + <section id="bio" className="py-4 pb-0 flex items-center justify-center bg-gray-50 dark:bg-gray-900"> |
4 | 37 | <div className="p-6 max-w-4xl w-full mx-auto shadow-none bg-transparent"> |
5 | 38 | <div className="flex flex-col md:flex-row items-center gap-8"> |
6 | 39 | <div className="flex-1 text-left md:pr-4"> |
7 | 40 | <h1 className="text-4xl font-bold text-gray-900 dark:text-white"> |
8 | 41 | <span className="wave-emoji inline-block mr-2 text-7xl">👋</span> |
9 | 42 | Hi, I'm Jaylord Vhan Fabor |
10 | 43 | </h1> |
11 | | - <p className="text-gray-600 dark:text-gray-400 mt-2 mb-4"> |
12 | | - Software Developer | Backend Developer |
| 44 | + <p className="text-gray-600 dark:text-gray-400 mt-2 mb-4 h-8 text-3xl"> |
| 45 | + <span className="underline font-extrabold">{displayedText}</span> |
| 46 | + <span className="animate-pulse"> Developer</span> |
13 | 47 | </p> |
14 | 48 | <p className="text-gray-700 dark:text-gray-300"> |
15 | 49 | Hey there! I'm more of a backend kind of person — I love setting up a clean, well-structured backend, |
|
0 commit comments