Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-ref] Minor corrections and improvements #29

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 31 additions & 32 deletions personal-portfolio/src/components/Banner.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from "react";
import { useState, useEffect, useMemo } from "react";
import { Container, Row, Col } from "react-bootstrap";
import headerImg from "../assets/img/header-img.svg";
import { ArrowRightCircle } from 'react-bootstrap-icons';
Expand All @@ -11,52 +11,51 @@ export const Banner = () => {
const [text, setText] = useState('');
const [delta, setDelta] = useState(300 - Math.random() * 100);
const [index, setIndex] = useState(1);
const toRotate = [ "Web Developer", "Web Designer", "UI/UX Designer" ];
const memoizedValue = useMemo(() => { return [ "Web Developer", "Web Designer", "UI/UX Designer" ] }, []);
const period = 2000;

useEffect(() => {
let ticker = setInterval(() => {
const tick = () => {
let i = loopNum % memoizedValue.length;
let fullText = memoizedValue[i];
let updatedText = isDeleting ? fullText.substring(0, text.length - 1) : fullText.substring(0, text.length + 1);

setText(updatedText);

if (isDeleting) {
setDelta(prevDelta => prevDelta / 2);
}

if (!isDeleting && updatedText === fullText) {
setIsDeleting(true);
setIndex(prevIndex => prevIndex - 1);
setDelta(period);
} else if (isDeleting && updatedText === '') {
setIsDeleting(false);
setLoopNum(loopNum + 1);
setIndex(1);
setDelta(500);
} else {
setIndex(prevIndex => prevIndex + 1);
}
}
tick();
}, delta);

return () => { clearInterval(ticker) };
}, [text])

const tick = () => {
let i = loopNum % toRotate.length;
let fullText = toRotate[i];
let updatedText = isDeleting ? fullText.substring(0, text.length - 1) : fullText.substring(0, text.length + 1);

setText(updatedText);

if (isDeleting) {
setDelta(prevDelta => prevDelta / 2);
}

if (!isDeleting && updatedText === fullText) {
setIsDeleting(true);
setIndex(prevIndex => prevIndex - 1);
setDelta(period);
} else if (isDeleting && updatedText === '') {
setIsDeleting(false);
setLoopNum(loopNum + 1);
setIndex(1);
setDelta(500);
} else {
setIndex(prevIndex => prevIndex + 1);
}
}
}, [delta, isDeleting, loopNum, text, memoizedValue])


return (
<section className="banner" id="home">
<Container>
<Row className="aligh-items-center">
<Row className="align-items-center">
<Col xs={12} md={6} xl={7}>
<TrackVisibility>
{({ isVisible }) =>
<div className={isVisible ? "animate__animated animate__fadeIn" : ""}>
<span className="tagline">Welcome to my Portfolio</span>
<h1>{`Hi! I'm Judy`} <span className="txt-rotate" dataPeriod="1000" data-rotate='[ "Web Developer", "Web Designer", "UI/UX Designer" ]'><span className="wrap">{text}</span></span></h1>
<h1>{`Hi! I'm Judy`} <span className="txt-rotate" data-period="1000" data-rotate='[ "Web Developer", "Web Designer", "UI/UX Designer" ]'><span className="wrap">{text}</span></span></h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<button onClick={() => console.log('connect')}>Let’s Connect <ArrowRightCircle size={25} /></button>
</div>}
Expand Down
2 changes: 1 addition & 1 deletion personal-portfolio/src/components/Contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const Contact = () => {
<input type="text" value={formDetails.firstName} placeholder="First Name" onChange={(e) => onFormUpdate('firstName', e.target.value)} />
</Col>
<Col size={12} sm={6} className="px-1">
<input type="text" value={formDetails.lasttName} placeholder="Last Name" onChange={(e) => onFormUpdate('lastName', e.target.value)}/>
<input type="text" value={formDetails.lastName} placeholder="Last Name" onChange={(e) => onFormUpdate('lastName', e.target.value)}/>
</Col>
<Col size={12} sm={6} className="px-1">
<input type="email" value={formDetails.email} placeholder="Email Address" onChange={(e) => onFormUpdate('email', e.target.value)} />
Expand Down
2 changes: 1 addition & 1 deletion personal-portfolio/src/components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const NavBar = () => {
<Nav className="ms-auto">
<Nav.Link href="#home" className={activeLink === 'home' ? 'active navbar-link' : 'navbar-link'} onClick={() => onUpdateActiveLink('home')}>Home</Nav.Link>
<Nav.Link href="#skills" className={activeLink === 'skills' ? 'active navbar-link' : 'navbar-link'} onClick={() => onUpdateActiveLink('skills')}>Skills</Nav.Link>
<Nav.Link href="#projects" className={activeLink === 'projects' ? 'active navbar-link' : 'navbar-link'} onClick={() => onUpdateActiveLink('projects')}>Projects</Nav.Link>
<Nav.Link href="#project" className={activeLink === 'projects' ? 'active navbar-link' : 'navbar-link'} onClick={() => onUpdateActiveLink('projects')}>Projects</Nav.Link>
</Nav>
<span className="navbar-text">
<div className="social-icon">
Expand Down