1- import { Box , Typography , useMediaQuery , useTheme } from '@mui/material' ;
1+ import { Box , Button , Typography , useMediaQuery , useTheme } from '@mui/material' ;
22import * as Sentry from '@sentry/nextjs' ;
33import React , { useEffect , useState } from 'react' ;
4- import { CookieConsent as AnalyticsConsentBanner } from 'react-cookie-consent' ;
54import { Link } from 'src/components/primitives/Link' ;
65import { CONSENT_KEY } from 'src/store/analyticsSlice' ;
76import { useRootStore } from 'src/store/root' ;
@@ -30,8 +29,6 @@ export default function AnalyticsBanner() {
3029 return ( ) => clearTimeout ( timerId ) ;
3130 } , [ ] ) ;
3231
33- const theme = useTheme ( ) ;
34-
3532 const { breakpoints } = useTheme ( ) ;
3633 const isMobile = useMediaQuery ( breakpoints . down ( 'sm' ) ) ;
3734
@@ -52,98 +49,62 @@ export default function AnalyticsBanner() {
5249 const hasUserMadeChoice =
5350 typeof window !== 'undefined' && localStorage . getItem ( CONSENT_KEY ) !== null ;
5451
55- // Note: If they have already chosen don't show again unless configured from footer
56- if ( hasUserMadeChoice ) return null ;
52+ // Hide once the user has made a choice. Reopening from the footer clears the stored choice and
53+ // reopens analyticsConfigOpen, which brings the banner back.
54+ if ( hasUserMadeChoice || ! analyticsConfigOpen ) return null ;
5755
5856 return (
59- < >
60- < AnalyticsConsentBanner
61- buttonText = { < Typography > Allow analytics </ Typography > }
62- declineButtonText = { < Typography > Opt-out</ Typography > }
63- disableStyles = { true }
64- visible = { analyticsConfigOpen ? 'show' : 'hidden' }
65- flipButtons
66- style = { {
67- background : figVars [ 'surface-elevated' ] ,
68- bottom : isMobile ? '24px' : '24px' ,
69- right : isMobile ? '50%' : '24px' ,
70- left : isMobile ? '50%' : 'auto' ,
71- position : 'fixed' ,
72- width : '400px' ,
73- // height: '184px',
74- gap : '16px' ,
75- display : 'flex' ,
76- flexDirection : 'column' ,
77- flexFlow : 'column' ,
78- justifyContent : 'space-between' ,
79- alignItems : 'center' ,
80- color : figVars [ 'fg-1' ] ,
81- marginBottom : '16px' ,
82- fontSize : '14px' ,
83- lineHeight : '20.02px' ,
84- padding : '16px 16px' ,
85- zIndex : 100 ,
86- borderRadius : '12px' ,
87- border : '0.5px solid rgba(235, 235, 239, 0.42)' ,
88- boxShadow : '0px 0px 2px rgba(0, 0, 0, 0.2), 0px 2px 10px rgba(0, 0, 0, 0.1)' ,
89- transition : 'transform 0.5s ease-out' , // Add this
90-
91- transform : bannerVisible
92- ? isMobile
93- ? 'translateX(-50%)'
94- : 'none'
95- : 'translateX(100%) translateY(100%)' ,
96- } }
97- buttonStyle = { {
98- background : theme . palette . mode === 'dark' ? '#F7F7F9' : '#383D51' ,
99- color : theme . palette . mode === 'dark' ? '#383D51' : '#F7F7F9' ,
100-
101- fontSize : '14px' ,
102- borderRadius : '4px' ,
103- margin : '0px' ,
104- border : '1px solid #000' ,
105- width : '172px' ,
106- height : '36px' ,
107- fontWeight : '700' ,
108- cursor : 'pointer' ,
109- } }
110- declineButtonStyle = { {
111- // background: '#F7F7F9',
112- background : theme . palette . mode === 'dark' ? '#383D51' : '#F7F7F9' ,
113- color : theme . palette . mode === 'dark' ? '#EAEBEF' : '#383D51' ,
114-
115- fontFamily : 'Inter' ,
116- fontWeight : '500' ,
117- lineHeight : '24px' ,
118- fontSize : '14px' ,
119- borderRadius : '4px' ,
120- margin : '10px' ,
121- // padding: '10px 20px',
122- border : `1px solid ${ theme . palette . mode === 'dark' ? '#383D51' : '#EAEBEF' } ` ,
123- width : '172px' ,
124- height : '36px' ,
125- // padding: '0px',
126- cursor : 'pointer' ,
127- } }
128- enableDeclineButton
129- onDecline = { ( ) => {
130- optOutAnalytics ( ) ;
131- } }
132- onAccept = { ( ) => {
133- optInAnalytics ( ) ;
134- } }
135- cookieName = { CONSENT_KEY }
136- >
137- < Box >
57+ < Box
58+ sx = { {
59+ position : 'fixed' ,
60+ zIndex : 100 ,
61+ bottom : '24px' ,
62+ ...( isMobile ? { left : '50%' } : { right : '24px' } ) ,
63+ width : '400px' ,
64+ maxWidth : 'calc(100vw - 48px)' ,
65+ p : '1.25rem' ,
66+ display : 'flex' ,
67+ flexDirection : 'column' ,
68+ gap : '1.25rem' ,
69+ borderRadius : '0.625rem' ,
70+ backgroundColor : figVars [ 'bg-2' ] ,
71+ boxShadow : `0 0 0 1px ${ figVars [ 'shadow-stroke-2' ] } , 0 6px 32px 0 ${ figVars [ 'shadow-high' ] } ` ,
72+ transition : 'transform 0.5s ease-out' ,
73+ transform : bannerVisible
74+ ? isMobile
75+ ? 'translateX(-50%)'
76+ : 'none'
77+ : 'translateX(100%) translateY(100%)' ,
78+ } }
79+ >
80+ < Box sx = { { display : 'flex' , flexDirection : 'column' , gap : '0.5rem' } } >
81+ < Typography variant = "h5" sx = { { color : 'fg-1' } } >
82+ We value your privacy
83+ </ Typography >
84+ < Typography
85+ sx = { { color : 'fg-3' , fontSize : '0.875rem' , fontWeight : 400 , lineHeight : '1.1875rem' } }
86+ >
13887 We may employ on-the-spot tracking techniques during your browsing session to collect data
13988 on your interactions, preferences, and behaviour. This data helps us personalise your
140- experience and improve our services. See our
141- < Link sx = { { color : 'info.main' } } href = "https://aave.com/privacy-policy/" >
142- { ' ' }
143- Privacy Policy.
89+ experience and improve our services. See our{ ' ' }
90+ < Link
91+ href = "https://aave.com/privacy-policy/"
92+ sx = { { textDecoration : 'underline' , color : 'fg-3' } }
93+ >
94+ Privacy Policy
14495 </ Link >
145- </ Box >
146- </ AnalyticsConsentBanner >
147- </ >
96+ .
97+ </ Typography >
98+ </ Box >
99+
100+ < Box sx = { { display : 'flex' , gap : '1rem' } } >
101+ < Button variant = "outlined" onClick = { ( ) => optOutAnalytics ( ) } sx = { { flex : 1 } } >
102+ Opt-out
103+ </ Button >
104+ < Button variant = "contained" onClick = { ( ) => optInAnalytics ( ) } sx = { { flex : 1 } } >
105+ Allow analytics
106+ </ Button >
107+ </ Box >
108+ </ Box >
148109 ) ;
149110}
0 commit comments