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
52 changes: 52 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -2689,3 +2689,55 @@ body[data-theme='light'] .console-separator::after {
background: #3b82f6 !important; /* Standout blue badge for activities */
}

/* Scroll To Top Button */

.scroll-to-top {
position: fixed;
bottom: 24px;
right: 24px;

width: 52px;
height: 52px;

border: none;
border-radius: 50%;

background: var(--aside-bg);
color: var(--text-color);

cursor: pointer;

display: flex;
align-items: center;
justify-content: center;

box-shadow: 0 4px 12px var(--box-shadow);

z-index: 999;

transition:
transform 0.2s ease,
background 0.2s ease,
color 0.2s ease;
}

.scroll-to-top:hover {
transform: translateY(-3px);
background: #4aed88;
color: #1c1e29;
}

.scroll-to-top:active {
transform: scale(0.95);
}

/* Mobile */

@media (max-width: 768px) {
.scroll-to-top {
width: 46px;
height: 46px;
bottom: 18px;
right: 18px;
}
}
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import NotFound from './pages/NotFound';
import {Toaster} from "react-hot-toast";
import LandingPage from './pages/LandingPage';
import ErrorBoundary from './components/ErrorBoundary';
import ScrollToTopButton from "./components/ScrollToTopButton";

function App() {
return (
Expand All @@ -33,6 +34,7 @@ function App() {
<Route path='/editor/:roomId' element={<EditorPage />}></Route>
<Route path='*' element={<NotFound/>}></Route>
</Routes>
<ScrollToTopButton />
</BrowserRouter>
</ErrorBoundary>
);
Expand Down
38 changes: 38 additions & 0 deletions src/components/ScrollToTopButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useEffect, useState } from "react";
import { ChevronUp } from "lucide-react";

function ScrollToTop() {
const [visible, setVisible] = useState(false);

useEffect(() => {
const toggleVisibility = () => {
setVisible(window.scrollY > 300);
};

window.addEventListener("scroll", toggleVisibility);

return () =>
window.removeEventListener("scroll", toggleVisibility);
}, []);

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

if (!visible) return null;

return (
<button
className="scroll-to-top"
onClick={scrollToTop}
aria-label="Scroll to top"
>
<ChevronUp size={22} />
</button>
);
}

export default ScrollToTop;