Skip to content

Commit

Permalink
Added Back To Top Navigation (subhadipbhowmik#139)
Browse files Browse the repository at this point in the history
* added hover card effect

* aligned footer to center

* modified tablet view of the footer

* add scroollToTop button

---------

Co-authored-by: Shubhadip Bhowmik <[email protected]>
  • Loading branch information
m3kvt and subhadipbhowmik authored Jun 3, 2024
1 parent 77762e5 commit 6510d3a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/components/HomepageFeatures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import clsx from 'clsx';
import Heading from '@theme/Heading';
import styles from './styles.module.css';
import ScrollToTopButton from '../ScrollToTop/ScrollToTopButton';

const FeatureList = [
{
Expand Down Expand Up @@ -91,6 +92,7 @@ export default function HomepageFeatures() {
<Feature key={idx} {...props} />
))}
</div>
<ScrollToTopButton />
</div>
</section>
);
Expand Down
21 changes: 21 additions & 0 deletions src/components/ScrollToTop/ScrollToTopButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import styles from './ScrollToTopButton.module.css';

const ScrollToTopButton = () => {
const scrollToTop = () => {
window.scrollTo({
top: 0,
behavior: 'smooth',
});
};

return (
<div className={styles.scrollToTop}>
<button onClick={scrollToTop} className={styles.button}>
</button>
</div>
);
};

export default ScrollToTopButton;
26 changes: 26 additions & 0 deletions src/components/ScrollToTop/ScrollToTopButton.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.scrollToTop {
position: absolute;
bottom: 20px;
right: 20px;
z-index: 1;
}

.button {
background-color: rgb(0, 191, 166);
border: none;
color: white;
padding: 10px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px 0px;
cursor: pointer;
border-radius: 50%;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
transition: background-color 0.3s ease;
}

.button:hover {
background-color: #0056b3;
}
2 changes: 1 addition & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Home() {
description="30 days of CPP programming challenge is a step-by-step guide to learn CPP programming language in 30 days. Master the fundamental concepts of CPP Programming easily."
>
<HomepageHeader />
<main>
<main style={{ position: 'relative' }}>
<HomepageFeatures />
<Chatbot />
</main>
Expand Down

0 comments on commit 6510d3a

Please sign in to comment.