@@ -36,6 +36,8 @@ import {
36
36
37
37
const defaultFlexClasses = "flex flex-col gap-4" ;
38
38
39
+ import { Transition } from "@headlessui/react" ;
40
+
39
41
import {
40
42
SignInDropDownButton ,
41
43
SignUpDropDownButton ,
@@ -90,6 +92,9 @@ export default function Home({
90
92
const scrollRef3 = useRef < HTMLDivElement | null > ( null ) ;
91
93
const scrollRef4 = useRef < HTMLDivElement | null > ( null ) ;
92
94
95
+ const [ showCookieBanner , setShowCookieBanner ] = useState < boolean > ( true ) ;
96
+ const [ hasAcceptedCookies , setHasAcceptedCookies ] = useState < boolean > ( false ) ;
97
+
93
98
useEffect ( ( ) => {
94
99
if ( logoRef . current ) {
95
100
const logoPosition = logoRef . current . offsetTop ;
@@ -752,21 +757,34 @@ export default function Home({
752
757
</ div >
753
758
754
759
< Footer />
755
- < >
756
- < Script
757
- src = { `https://www.googletagmanager.com/gtag/js?id=${ gaTrackingId } ` }
758
- strategy = "afterInteractive"
759
- />
760
- < Script id = "google-analytics" strategy = "afterInteractive" >
761
- { `
760
+ < CookieBanner
761
+ className = "fixed bottom-4 right-4"
762
+ show = { showCookieBanner }
763
+ onClickAccept = { ( ) => {
764
+ setHasAcceptedCookies ( true ) ;
765
+ setShowCookieBanner ( false ) ;
766
+ } }
767
+ onClickRefuse = { ( ) => {
768
+ setShowCookieBanner ( false ) ;
769
+ } }
770
+ />
771
+ { hasAcceptedCookies && (
772
+ < >
773
+ < Script
774
+ src = { `https://www.googletagmanager.com/gtag/js?id=${ gaTrackingId } ` }
775
+ strategy = "afterInteractive"
776
+ />
777
+ < Script id = "google-analytics" strategy = "afterInteractive" >
778
+ { `
762
779
window.dataLayer = window.dataLayer || [];
763
780
function gtag(){window.dataLayer.push(arguments);}
764
781
gtag('js', new Date());
765
782
766
783
gtag('config', '${ gaTrackingId } ');
767
784
` }
768
- </ Script >
769
- </ >
785
+ </ Script >
786
+ </ >
787
+ ) }
770
788
</ main >
771
789
</ >
772
790
) ;
@@ -969,3 +987,55 @@ const Footer = () => {
969
987
</ div >
970
988
) ;
971
989
} ;
990
+
991
+ const CookieBanner = ( {
992
+ show,
993
+ onClickAccept,
994
+ onClickRefuse,
995
+ className,
996
+ } : {
997
+ show : boolean ;
998
+ onClickAccept : ( ) => void ;
999
+ onClickRefuse : ( ) => void ;
1000
+ className ?: string ;
1001
+ } ) => {
1002
+ return (
1003
+ < Transition
1004
+ show = { show }
1005
+ enter = "transition-opacity s-duration-300"
1006
+ appear = { true }
1007
+ enterFrom = "opacity-0"
1008
+ enterTo = "opacity-100"
1009
+ leave = "transition-opacity duration-300"
1010
+ leaveFrom = "opacity-100"
1011
+ leaveTo = "opacity-0"
1012
+ className = { classNames (
1013
+ "z-30 flex w-72 flex-col gap-3 rounded-xl border border-pink-100 bg-pink-50 p-4 shadow-xl" ,
1014
+ className || ""
1015
+ ) }
1016
+ >
1017
+ < div className = "text-sm font-normal text-element-900" >
1018
+ We use cookies to improve your experience on our site. By using our
1019
+ service, you agree to our{ " " }
1020
+ < A variant = "tertiary" >
1021
+ < Link href = "/terms" > Terms of Use</ Link >
1022
+ </ A >
1023
+ .
1024
+ </ div >
1025
+ < div className = "flex gap-2" >
1026
+ < Button
1027
+ variant = "primary"
1028
+ size = "sm"
1029
+ label = "Accept All"
1030
+ onClick = { onClickAccept }
1031
+ />
1032
+ < Button
1033
+ variant = "tertiary"
1034
+ size = "sm"
1035
+ label = "Reject All"
1036
+ onClick = { onClickRefuse }
1037
+ />
1038
+ </ div >
1039
+ </ Transition >
1040
+ ) ;
1041
+ } ;
0 commit comments