Skip to content

Commit 0ea98e1

Browse files
committed
updated
1 parent 6ad5b6f commit 0ea98e1

File tree

4 files changed

+57
-57
lines changed

4 files changed

+57
-57
lines changed

src/components/HomePage/Header.tsx

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ 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';
87

98
/**
109
* Renders the header component of the application.
@@ -28,6 +27,8 @@ const HeaderContent = () => {
2827
>
2928
Level Up Skills with CodeHarborHub
3029
</motion.h1>
30+
{/* <h1 className="gradient__text"
31+
>Level Up Skills with CodeHarborHub</h1> */}
3132
<motion.p
3233
initial={{ opacity: 0, x: -10 }}
3334
whileInView={{ opacity: 1, x: 0 }}
@@ -132,16 +133,6 @@ const HeaderImage = () => {
132133
);
133134
};
134135

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-
145136
/**
146137
* Renders the header component of the application.
147138
* @returns A header component with styling and structure.
@@ -153,22 +144,6 @@ const Header: React.FC = () => {
153144
<HeaderContent />
154145
<HeaderImage />
155146
</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>
172147
</div>
173148
);
174149
};

src/components/HomePage/header.css

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -321,31 +321,3 @@
321321

322322

323323

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-
}

src/pages/index.module.css

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,24 @@
3333

3434
.section {
3535
padding: 1rem;
36-
}
36+
}
37+
38+
.scrollToBottomButton {
39+
position: fixed;
40+
bottom: 20px;
41+
right: 20px;
42+
top: auto;
43+
background-color: var(--ifm-color-primary);
44+
color: #fff;
45+
border: none;
46+
border-radius: 50%;
47+
padding: 10px;
48+
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
49+
cursor: pointer;
50+
z-index: 1000;
51+
}
52+
53+
.scrollToBottomButton:hover {
54+
background-color: var(--ifm-color-primary);
55+
box-shadow: 0px 6px 8px rgba(0, 0, 0, 0.2);
56+
}

src/pages/index.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import clsx from "clsx";
22
// import Link from "@docusaurus/Link";
3-
import React from "react";
3+
import React, { useState, useEffect } from "react";
44
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
55
import Layout from "@theme/Layout";
66
import Heading from "@theme/Heading";
@@ -12,6 +12,7 @@ import Header from "../components/HomePage/Header";
1212
import Tweet from "../components/Tweet";
1313
import Tweets, { type TweetItem } from "../data/tweets";
1414
import { motion } from "framer-motion";
15+
import { FaArrowDown } from "react-icons/fa";
1516

1617
function TweetsSection(): React.JSX.Element {
1718
const tweetColumns: TweetItem[][] = [[], [], []];
@@ -69,6 +70,29 @@ function TweetsSection(): React.JSX.Element {
6970

7071
export default function Home(): React.JSX.Element {
7172
const { siteConfig } = useDocusaurusContext();
73+
const [showScrollButton, setShowScrollButton] = useState(true);
74+
75+
const scrollToBottom = () => {
76+
window.scrollTo({
77+
top: document.documentElement.scrollHeight,
78+
behavior: "smooth",
79+
});
80+
setShowScrollButton(false);
81+
};
82+
83+
const handleScroll = () => {
84+
if (window.scrollY === 0) {
85+
setShowScrollButton(true);
86+
}
87+
};
88+
89+
useEffect(() => {
90+
window.addEventListener("scroll", handleScroll);
91+
return () => {
92+
window.removeEventListener("scroll", handleScroll);
93+
};
94+
}, []);
95+
7296
return (
7397
<Layout
7498
title={`Hello from ${siteConfig.title}`}
@@ -140,6 +164,15 @@ export default function Home(): React.JSX.Element {
140164
</motion.div>
141165

142166
<TweetsSection />
167+
168+
{showScrollButton && (
169+
<button
170+
onClick={scrollToBottom}
171+
className={styles.scrollToBottomButton}
172+
>
173+
<FaArrowDown />
174+
</button>
175+
)}
143176
</main>
144177
</Layout>
145178
);

0 commit comments

Comments
 (0)