From 2a3a07e7caa77a8f0b1df971538208b14065826e Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 29 Jul 2021 15:26:16 +0200 Subject: [PATCH] implement scrolling to modal --- components/HeroSection.tsx | 11 ++++++++++- components/ModalSection.tsx | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/components/HeroSection.tsx b/components/HeroSection.tsx index 5ff2869..94c81e8 100644 --- a/components/HeroSection.tsx +++ b/components/HeroSection.tsx @@ -2,6 +2,15 @@ import GradientText from './GradientText' import Button from './Button' import Link from './Link' +function scrollToId(id: string) { + const element = document.getElementById(id) + const y = element.getBoundingClientRect().top + window.scrollY + window.scroll({ + top: y, + behavior: 'smooth', + }) +} + const HeroSection = () => { return (
@@ -17,7 +26,7 @@ const HeroSection = () => {

- + scrollToId('contribute')}> diff --git a/components/ModalSection.tsx b/components/ModalSection.tsx index 4e1544d..e1cbaa0 100644 --- a/components/ModalSection.tsx +++ b/components/ModalSection.tsx @@ -4,7 +4,7 @@ import StatsModal from './StatsModal' const ModalSection = () => { return ( <> -
+

Ready to contribute?