Skip to content

Commit 13b85dd

Browse files
committed
save
1 parent 25ad08b commit 13b85dd

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

src/app/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22
import About from '@/components/About';
3+
import ArrowUp from '@/components/ArrowUp';
34
import Education from '@/components/Education';
45
import Experience from '@/components/Experience';
56
import NavBar from '@/components/NavBar';
@@ -23,6 +24,7 @@ export default function Home() {
2324
<Projects />
2425
</main>
2526
</div>
27+
<ArrowUp />
2628
</>
2729
);
2830
}

src/components/ArrowUp.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { useEffect, useState } from 'react';
2+
// import { FaArrowUp } from 'react-icons/fa';
3+
import { RiArrowUpDoubleLine } from 'react-icons/ri';
4+
import { animateScroll as scroll } from 'react-scroll';
5+
6+
const ArrowUp = () => {
7+
const [isVisible, setIsVisible] = useState(false);
8+
9+
useEffect(() => {
10+
const handleScroll = () => {
11+
if (window.scrollY > 300) {
12+
setIsVisible(true);
13+
} else {
14+
setIsVisible(false);
15+
}
16+
};
17+
18+
window.addEventListener('scroll', handleScroll);
19+
handleScroll();
20+
21+
return () => {
22+
window.removeEventListener('scroll', handleScroll);
23+
};
24+
}, []);
25+
26+
const scrollToTop = () => {
27+
scroll.scrollToTop({
28+
duration: 500,
29+
smooth: true,
30+
});
31+
};
32+
33+
return (
34+
<button
35+
onClick={scrollToTop}
36+
className={`fixed bottom-8 right-8 p-3 rounded-full border border-secondary text-white transition-all duration-300 hover:shadow-border cursor-pointer group hover:bg-background ${
37+
isVisible
38+
? 'opacity-100 translate-y-0'
39+
: 'opacity-0 translate-y-10 pointer-events-none'
40+
}`}
41+
>
42+
<RiArrowUpDoubleLine className="size-6 text-secondary group-hover:text-primary" />
43+
</button>
44+
);
45+
};
46+
47+
export default ArrowUp;

src/components/SocialMedia.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const SocialMediaLink = ({ icon: Icon, href }: SocialMediaLinkProps) => {
3232
return (
3333
<a
3434
href={href}
35-
className="p-2 border rounded-full cursor-pointer group border-secondary hover:shadow-border hover:bg-background"
35+
className="p-3 border rounded-full cursor-pointer group border-secondary hover:shadow-border hover:bg-background"
3636
>
3737
<Icon className="text-lg text-secondary group-hover:text-primary" />
3838
</a>

0 commit comments

Comments
 (0)