Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): add cookie consent banner #1011

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"i18next-browser-languagedetector": "^8.0.0",
"lexical": "^0.18.0",
"react": "^18.3.1",
"react-cookie-consent": "^9.0.0",
"react-dom": "^18.3.1",
"react-dropzone": "^14.2.9",
"react-hook-form": "^7.53.0",
Expand Down
11 changes: 7 additions & 4 deletions src/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { translations } from './i18n/components'
import { datesLocale } from './i18n/locales'
import { RoutesProvider } from './router/Router'
import { RainbowKitTheme, Theme } from './Theme'
import Wrapper from '~components/Layout/Wrapper'

const queryClient = new QueryClient()

Expand Down Expand Up @@ -58,10 +59,12 @@ export const AppProviders = () => {
datesLocale={datesLocale(i18n.language)}
options={{ faucet_url: import.meta.env.CUSTOM_FAUCET_URL }}
>
<SaasProviders>
<ColorModeScript />
<RoutesProvider />
</SaasProviders>
<Wrapper>
<SaasProviders>
<ColorModeScript />
<RoutesProvider />
</SaasProviders>
</Wrapper>
</ClientProvider>
</RainbowKitTheme>
)
Expand Down
44 changes: 44 additions & 0 deletions src/components/Layout/CookieBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import CookieConsent from 'react-cookie-consent'

const CookieBanner = () => {
return (
<div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this div here for any special reason? I think it could perfectly be omitted.

<CookieConsent
location='bottom'
buttonText='Accept'
declineButtonText='Cancel'
enableDeclineButton
cookieName='vocdoni_cookie_consent'
onAccept={() => {
localStorage.setItem('cookieConsent', 'accepted')
}}
onDecline={() => {
localStorage.setItem('cookieConsent', 'declined')
}}
style={{ background: '#2B373B' }}
buttonStyle={{
color: '#fff',
background: '#4e503b',
fontSize: '14px',
}}
declineButtonStyle={{
color: '#fff',
background: '#c00',
fontSize: '14px',
}}
>
This website uses cookies to enhance the user experience.{' '}
<a href='/privacy-policy' style={{ color: '#4e9c81' }}>
Privacy Policy
</a>{' '}
and{' '}
<a href='/terms-and-conditions' style={{ color: '#4e9c81' }}>
Terms and Conditions
</a>
.
</CookieConsent>
</div>
)
}

export default CookieBanner
2 changes: 2 additions & 0 deletions src/components/Layout/Wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, Flex } from '@chakra-ui/react'
import CookieBanner from './CookieBanner'

const Wrapper = ({ ...props }) => (
<Box bg={'wrapper.bg_light'} _dark={{ bgColor: 'wrapper.bg_dark' }}>
Expand All @@ -14,6 +15,7 @@ const Wrapper = ({ ...props }) => (
}}
{...props}
></Flex>
<CookieBanner />
</Box>
)

Expand Down
32 changes: 14 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5643,6 +5643,11 @@ jiti@^1.21.0:
resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.0.tgz#7c97f8fe045724e136a397f7340475244156105d"
integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==

js-cookie@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==

js-sha256@^0.10.1:
version "0.10.1"
resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.10.1.tgz#b40104ba1368e823fdd5f41b66b104b15a0da60d"
Expand Down Expand Up @@ -7494,6 +7499,13 @@ react-clientside-effect@^1.2.6:
dependencies:
"@babel/runtime" "^7.12.13"

react-cookie-consent@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/react-cookie-consent/-/react-cookie-consent-9.0.0.tgz#26dc3a3387cc8524275864a4ed4584af881435f0"
integrity sha512-Blyj+m+Zz7SFHYqT18p16EANgnSg2sIyU6Yp3vk83AnOnSW7qnehPkUe4+8+qxztJrNmCH5GP+VHsWzAKVOoZA==
dependencies:
js-cookie "^2.2.1"

react-dom@^18.3.1:
version "18.3.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.3.1.tgz#c2265d79511b57d479b3dd3fdfa51536494c5cb4"
Expand Down Expand Up @@ -8173,16 +8185,7 @@ strict-uri-encode@^2.0.0:
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -8222,14 +8225,7 @@ stringify-entities@^4.0.0:
character-entities-html4 "^2.0.0"
character-entities-legacy "^3.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down