Skip to content

Commit

Permalink
Merge pull request #378 from aslams2020/main
Browse files Browse the repository at this point in the history
Added "Scroll Down Progress Bar" to The Website
  • Loading branch information
usha-madithati authored Jul 5, 2024
2 parents 126682f + 517f0e2 commit 53b4556
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import AccountSettings from "./settings/AccountSettings";
import NotFoundPage from "./pages/PNF";
import ForgotPassword from "./pages/Forgotpassword.js";
import ResetPassword from "./pages/ResetPassword.js";
import ProgressBar from './components/ProgressBar.js';

const App = () => {
return (
<>
<ProgressBar />
<Routes>
<Route path="/" element={<Home />} />
<Route path="/user/add-products" element={<PForm />} />
Expand All @@ -32,6 +34,7 @@ const App = () => {
<Route path="/user/reset-password/:token" element={<ResetPassword />} />
<Route element={<PrivateRoute />}>
<Route path="/admin/dashboard" element={<AdminD></AdminD>} />
<Route path="/admin/" element={<AdminD></AdminD>} />
<Route path="/scanqr" element={<QRCodeVerification />} />
<Route path="/user/add-products" element={<PForm />} />
<Route path="/user/settings" element={<Settings></Settings>} />
Expand All @@ -46,6 +49,7 @@ const App = () => {
<Route path="/user/review" element={<Review />} />
<Route path="*" element={<NotFoundPage></NotFoundPage>} />
</Routes>

</>
);
};
Expand Down
16 changes: 16 additions & 0 deletions src/components/ProgressBar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#progressBar {
position: fixed;
top: 0;
left: 0;
width: 0%;
height: 8px;
background: linear-gradient(90deg, rgba(8, 106, 68, 1) 0%, rgba(8, 170, 106, 1) 50%, rgba(8, 106, 68, 1) 100%);
z-index: 99;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
/* transition: width 0.3s ease-in-out; */
}

#progressBar:hover {
background: linear-gradient(90deg, rgba(8, 170, 106, 1) 0%, rgba(8, 106, 68, 1) 100%);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
24 changes: 24 additions & 0 deletions src/components/ProgressBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

import React, { useEffect } from 'react';
import './ProgressBar.css';

const ProgressBar = () => {

useEffect(() => {
const handleScroll = () => {
const winScroll = document.body.scrollTop || document.documentElement.scrollTop;
const height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
const scrolled = (winScroll / height) * 100;
document.getElementById('progressBar').style.width = scrolled + '%';
};


window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
}, []);

return <div id="progressBar"></div>;

};

export default ProgressBar;

0 comments on commit 53b4556

Please sign in to comment.