Files
echecsfrance/components/ScrollToTopButton.tsx
T
2023-06-20 15:37:08 +02:00

26 lines
736 B
TypeScript

"use client";
import { FaArrowUp } from "react-icons/fa";
import { handleScrollToTop } from "@/handlers/scrollHandlers";
const ScrollToTopButton = ({ isLgScreen }: { isLgScreen: boolean }) => {
// determine scrollable element based on screen size - window or div
const scrollToTopElement = isLgScreen
? document.getElementById("tournament-table")
: window;
const scrollToTopButtonClass = isLgScreen
? "absolute bottom-0 right-3 p-10"
: "fixed top-20 right-3";
return (
<button
className={`${scrollToTopButtonClass} z-10 text-2xl text-teal-900 dark:text-white`}
>
<FaArrowUp onClick={() => handleScrollToTop(scrollToTopElement)} />
</button>
);
};
export default ScrollToTopButton;