Skip to content

Commit 6ad5b6f

Browse files
committed
scroll bottom button
1 parent 355b255 commit 6ad5b6f

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

src/components/HomePage/Header.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "./header.css";
44
import Link from "@docusaurus/Link";
55
import VanillaTilt from "vanilla-tilt";
66
import { motion } from "framer-motion";
7+
import { FaArrowDown } from 'react-icons/fa';
78

89
/**
910
* Renders the header component of the application.
@@ -27,8 +28,6 @@ const HeaderContent = () => {
2728
>
2829
Level Up Skills with CodeHarborHub
2930
</motion.h1>
30-
{/* <h1 className="gradient__text"
31-
>Level Up Skills with CodeHarborHub</h1> */}
3231
<motion.p
3332
initial={{ opacity: 0, x: -10 }}
3433
whileInView={{ opacity: 1, x: 0 }}
@@ -133,6 +132,16 @@ const HeaderImage = () => {
133132
);
134133
};
135134

135+
/**
136+
* Scrolls the window to the bottom of the page.
137+
*/
138+
const scrollToBottom = () => {
139+
window.scrollTo({
140+
top: document.documentElement.scrollHeight,
141+
behavior: 'smooth',
142+
});
143+
};
144+
136145
/**
137146
* Renders the header component of the application.
138147
* @returns A header component with styling and structure.
@@ -144,6 +153,22 @@ const Header: React.FC = () => {
144153
<HeaderContent />
145154
<HeaderImage />
146155
</div>
156+
<motion.button
157+
initial={{ opacity: 0, y: -10 }}
158+
whileInView={{ opacity: 1, y: 0 }}
159+
viewport={{ once: true }}
160+
transition={{
161+
duration: 1,
162+
type: "spring",
163+
stiffness: 100,
164+
delay: 0.4,
165+
}}
166+
type="button"
167+
className="scroll-to-bottom-button"
168+
onClick={scrollToBottom}
169+
>
170+
<FaArrowDown /> {/* Icon */}
171+
</motion.button>
147172
</div>
148173
);
149174
};

src/components/HomePage/header.css

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,36 @@
316316

317317
.float-animation {
318318
animation: float 2s ease-in-out infinite;
319-
}
319+
}
320+
321+
322+
323+
324+
.scroll-to-bottom-button {
325+
position: absolute;
326+
top: 20px;
327+
right: 20px;
328+
padding: 10px 12px;
329+
background-color: #ff6f61;
330+
color: #fff;
331+
border: none;
332+
border-radius: 10px;
333+
cursor: pointer;
334+
font-size: 16px;
335+
display: flex;
336+
align-items: center;
337+
gap: 5px;
338+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
339+
z-index: 1000;
340+
transition: background-color 0.3s, transform 0.3s;
341+
}
342+
343+
.scroll-to-bottom-button:hover {
344+
background-color: #ff4b3a;
345+
transform: translateY(-2px);
346+
}
347+
348+
.scroll-to-bottom-button:active {
349+
background-color: #e64b3a;
350+
transform: translateY(0);
351+
}

0 commit comments

Comments
 (0)