diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 4e1b5ce..be6e73c 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -28,6 +28,7 @@ import ProtectedRoute from "./components/shared/ProtectedRoute"; import PublicRoute from "./components/shared/PublicRoute"; import BugReportsPage from "./pages/BugReportsPage"; import Contact from "./pages/Contact"; +import BackToTop from './components/shared/Backtotop'; export default function App() { return ( @@ -119,6 +120,7 @@ export default function App() { } /> + diff --git a/frontend/src/components/shared/Backtotop.jsx b/frontend/src/components/shared/Backtotop.jsx new file mode 100644 index 0000000..ae99fd5 --- /dev/null +++ b/frontend/src/components/shared/Backtotop.jsx @@ -0,0 +1,49 @@ +import { useEffect, useState } from 'react'; +import { ArrowUp } from 'lucide-react'; + +const BackToTop = () => { + const [visible, setVisible] = useState(false); + + useEffect(() => { + const toggleVisibility = () => { + setVisible(window.scrollY > 300); + }; + + toggleVisibility(); + + window.addEventListener('scroll', toggleVisibility); + + return () => window.removeEventListener('scroll', toggleVisibility); + }, []); + + const scrollToTop = () => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); + }; + + return ( + + ); +}; + +export default BackToTop;