diff --git a/client/src/App.js b/client/src/App.js index 3a1f21c5..462cb201 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -23,6 +23,9 @@ import { OrderList } from './Pages/Orders.jsx'; import Preloader from "./Components/Preloader.jsx"; import GoToTop from "./Components/GoToTop.jsx"; + +import ScrollToTopButton from "./Components/ScrollToTopButton.jsx"; + function App() { const [darkMode, setDarkMode] = useState(false); @@ -43,8 +46,31 @@ function App() { // borderRadius: '8px', }; + return ( <> + + + +
+ + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + + +
+
+ +
@@ -69,6 +95,7 @@ function App() {
+ ); } diff --git a/client/src/Components/ScrollToTopButton.jsx b/client/src/Components/ScrollToTopButton.jsx new file mode 100644 index 00000000..3b4e1b83 --- /dev/null +++ b/client/src/Components/ScrollToTopButton.jsx @@ -0,0 +1,31 @@ +import React,{useEffect,useState} from 'react' +import {FaArrowUp} from 'react-icons/fa'; +const ScrollToTopButton = () => { + const [isVisible,setIsVisible]=useState(false) + useEffect(()=>{ + const toggleVisibility=()=>{ + if(window.pageYOffset>300){ + setIsVisible(true); + } + else{ + setIsVisible(false); + } + }; + window.addEventListener('scroll',toggleVisibility); + return ()=>window.removeEventListener('scroll',toggleVisibility); + },[]); + const ScrollToTop=()=>{ + window.scrollTo({ + top:0, + behavior:'smooth' + }) + } + return ( + + ) +} + +export default ScrollToTopButton diff --git a/client/src/index.css b/client/src/index.css index 45bd1d4a..fbe068ff 100644 --- a/client/src/index.css +++ b/client/src/index.css @@ -48,3 +48,42 @@ code { @tailwind base; @tailwind components; @tailwind utilities; + + + + +.scroll-to-top { + position: fixed; + bottom: 20px; + right: 20px; + width: 50px; + /* Adjust size as needed */ + height: 50px; + /* Adjust size as needed */ + border-radius: 50%; + /* This makes the button round */ + background-color: #333; + /* Background color */ + color: #fff; + /* Text/icon color */ + border: none; + outline: none; + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + transition: opacity 0.4s; + opacity: 0; + visibility: hidden; + z-index: 1000; +} + +.scroll-to-top.show { + opacity: 1; + visibility: visible; +} + +.scroll-to-top:hover { + background-color: #555; +} +