diff --git a/components/Scrollbutton/ScrolButton.js b/components/Scrollbutton/ScrolButton.js new file mode 100644 index 00000000..57ad8d53 --- /dev/null +++ b/components/Scrollbutton/ScrolButton.js @@ -0,0 +1,45 @@ +import React, { useEffect, useState } from 'react'; +import Image from 'next/image'; + +function ScrollButton() { + const [backToTopButton, setBackToTopButton] = useState(false); + + useEffect(() => { + const handleScroll = () => { + if (window.scrollY > 150) { + setBackToTopButton(true); + } else { + setBackToTopButton(false); + } + }; + + window.addEventListener('scroll', handleScroll); + + // Clean up the event listener on component unmount + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }, []); + + const scrollUp = () => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); + }; + + return ( +
+ {backToTopButton && ( + + )} +
+ ); +} + +export default ScrollButton; diff --git a/package-lock.json b/package-lock.json index ce81cfb1..9f495c6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7626,6 +7626,66 @@ "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } + }, + "node_modules/@next/swc-android-arm-eabi": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-12.3.4.tgz", + "integrity": "sha512-cM42Cw6V4Bz/2+j/xIzO8nK/Q3Ly+VSlZJTa1vHzsocJRYz8KT6MrreXaci2++SIZCF1rVRCDgAg5PpqRibdIA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-android-arm64": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-12.3.4.tgz", + "integrity": "sha512-5jf0dTBjL+rabWjGj3eghpLUxCukRhBcEJgwLedewEA/LJk2HyqCvGIwj5rH+iwmq1llCWbOky2dO3pVljrapg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-freebsd-x64": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-12.3.4.tgz", + "integrity": "sha512-KM9JXRXi/U2PUM928z7l4tnfQ9u8bTco/jb939pdFUHqc28V43Ohd31MmZD1QzEK4aFlMRaIBQOWQZh4D/E5lQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm-gnueabihf": { + "version": "12.3.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.3.4.tgz", + "integrity": "sha512-3zqD3pO+z5CZyxtKDTnOJ2XgFFRUBciOox6EWkoZvJfc9zcidNAQxuwonUeNts6Xbm8Wtm5YGIRC0x+12YH7kw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } } } } diff --git a/pages/index.js b/pages/index.js index 9a94f90a..03d90933 100644 --- a/pages/index.js +++ b/pages/index.js @@ -16,6 +16,8 @@ import speakers from '../config/speakers.json'; import Link from 'next/link'; import Button from '../components/Buttons/button'; import Dropdown from '../components/Dropdown/dropdown'; +import ScrollButton from '../components/Scrollbutton/ScrolButton'; // Adjust the import path if needed + export default function Home() { const isTablet = useMediaQuery({ maxWidth: '1118px' }); @@ -191,6 +193,7 @@ export default function Home() {
+ ); diff --git a/public/img/scroll.svg b/public/img/scroll.svg new file mode 100644 index 00000000..d49550d8 --- /dev/null +++ b/public/img/scroll.svg @@ -0,0 +1,14 @@ + + + + + + + +