Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions frontend/src/components/BackToTop.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useEffect, useState } from "react";

export default function BackToTop() {
const [visible, setVisible] = useState(false);

useEffect(() => {
const handleScroll = () => setVisible(window.scrollY > 300);
handleScroll();
window.addEventListener("scroll", handleScroll);
return () => window.removeEventListener("scroll", handleScroll);
}, []);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

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

if (!visible) return null;

return (
<button
onClick={scrollToTop}
aria-label="Back to top"
style={{
position: "fixed",
bottom: "2rem",
right: "2rem",
zIndex: 999,
backgroundColor: "#C8F135",
color: "black",
border: "none",
borderRadius: "50%",
width: "48px",
height: "48px",
fontSize: "1.4rem",
cursor: "pointer",
boxShadow: "0 4px 12px rgba(0,0,0,0.2)",
transition: "opacity 0.3s ease",
}}
>
</button>
);
}
2 changes: 2 additions & 0 deletions frontend/src/components/Landing/LandingPage.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BackToTop from "../BackToTop";
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuth } from '../../contexts/AuthContext';
Expand Down Expand Up @@ -33,6 +34,7 @@ const LandingPage = () => {
<Pricing />
<FAQ />
<Footer />
<BackToTop />
</div>
);
};
Expand Down
Loading