scroll to top button added

This commit is contained in:
Owen Rees
2023-06-20 15:00:59 +02:00
parent 5aaa1deeff
commit bcc3c74973
8 changed files with 97 additions and 40 deletions
+25
View File
@@ -0,0 +1,25 @@
"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"
: "sticky top-20";
return (
<button
className={`${scrollToTopButtonClass} z-10 text-2xl text-teal-900 dark:text-white`}
>
<FaArrowUp onClick={() => handleScrollToTop(scrollToTopElement)} />
</button>
);
};
export default ScrollToTopButton;