Reorganise code - use src folder

This commit is contained in:
Timothy Armes
2023-10-11 08:45:36 +02:00
committed by Owen Rees
parent 2dc5f477c9
commit b5061b1c78
89 changed files with 70 additions and 69 deletions
+38
View File
@@ -0,0 +1,38 @@
"use client";
import { useEffect, useRef, useState } from "react";
import { FaArrowUp } from "react-icons/fa";
import { useBreakpoint } from "@/hooks/tailwind";
import { ScrollableElement } from "@/types";
import { handleScrollToTop } from "@/utils/scrollHandlers";
const ScrollToTopButton = () => {
const scrollToTopElementRef = useRef<ScrollableElement | null>(null);
const isLgScreen = useBreakpoint("lg");
// determine scrollable element based on screen size - window or div
useEffect(() => {
isLgScreen
? (scrollToTopElementRef.current = document.getElementById("listing"))
: (scrollToTopElementRef.current = window);
}, [isLgScreen]);
const scrollToTopButtonClass = isLgScreen
? "absolute bottom-0 right-3 p-10"
: "fixed bottom-20 right-3 py-10";
return (
<button
className={`${scrollToTopButtonClass} z-10 text-2xl text-primary-900 dark:text-white`}
data-test="scroll-to-top-button"
>
<FaArrowUp
onClick={() => handleScrollToTop(scrollToTopElementRef.current)}
/>
</button>
);
};
export default ScrollToTopButton;