diff --git a/.travis.yml b/.travis.yml index 249b42bb..8ee6afc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ matrix: if: (branch = master AND NOT type = pull_request) OR tag IS present cache: npm: false - yarn: false + yarn: true before_script: - if [[ -n "$TRAVIS_TAG" ]]; then export REACT_APP_ENV='production'; fi; - if [ $TRAVIS_PULL_REQUEST != "false" ]; then export PUBLIC_URL="/${REACT_APP_NETWORK}/app"; fi; @@ -54,7 +54,6 @@ before_install: - sudo apt-get -y install python3-pip python3-dev libusb-1.0-0-dev libudev-dev - pip install awscli --upgrade --user script: - - yarn lint:check - yarn prettier:check - yarn test:coverage - yarn build diff --git a/src/components/CookiesBanner/assets/alert-red.svg b/src/components/CookiesBanner/assets/alert-red.svg new file mode 100644 index 00000000..6a20c41c --- /dev/null +++ b/src/components/CookiesBanner/assets/alert-red.svg @@ -0,0 +1,11 @@ + diff --git a/src/components/CookiesBanner/assets/intercom.png b/src/components/CookiesBanner/assets/intercom.png new file mode 100644 index 00000000..74eb6efa Binary files /dev/null and b/src/components/CookiesBanner/assets/intercom.png differ diff --git a/src/components/CookiesBanner/index.tsx b/src/components/CookiesBanner/index.tsx index 6850456b..bd5e2551 100644 --- a/src/components/CookiesBanner/index.tsx +++ b/src/components/CookiesBanner/index.tsx @@ -1,10 +1,8 @@ import Checkbox from '@material-ui/core/Checkbox' import FormControlLabel from '@material-ui/core/FormControlLabel' import { makeStyles } from '@material-ui/core/styles' -import cn from 'classnames' -import React, { useEffect, useState, useCallback } from 'react' +import React, { ReactElement, useEffect, useState } from 'react' import { useDispatch, useSelector } from 'react-redux' - import Button from 'src/components/layout/Button' import Link from 'src/components/layout/Link' import { COOKIES_KEY } from 'src/logic/cookies/model/cookie' @@ -13,7 +11,9 @@ import { cookieBannerOpen } from 'src/logic/cookies/store/selectors' import { loadFromCookie, saveCookie } from 'src/logic/cookies/utils' import { mainFontFamily, md, primary, screenSm } from 'src/theme/variables' import { loadGoogleAnalytics } from 'src/utils/googleAnalytics' -import { loadIntercom } from 'src/utils/intercom' +import { closeIntercom, isIntercomLoaded, loadIntercom } from 'src/utils/intercom' +import AlertRedIcon from './assets/alert-red.svg' +import IntercomIcon from './assets/intercom.png' const isDesktop = process.env.REACT_APP_BUILD_FOR_DESKTOP @@ -27,14 +27,13 @@ const useStyles = makeStyles({ justifyContent: 'center', left: '0', minHeight: '200px', - padding: '27px 15px', + padding: '30px 15px 45px', position: 'fixed', width: '100%', - zIndex: '15', + zIndex: '999', }, content: { maxWidth: '100%', - width: '830px', }, text: { color: primary, @@ -42,19 +41,21 @@ const useStyles = makeStyles({ fontSize: md, fontWeight: 'normal', lineHeight: '1.38', - margin: '0 0 25px', + margin: '0 auto 35px', textAlign: 'center', + maxWidth: '810px', }, form: { - columnGap: '10px', + columnGap: '20px', display: 'grid', gridTemplateColumns: '1fr', - paddingBottom: '30px', - rowGap: '10px', - + paddingBottom: '50px', + rowGap: '15px', + margin: '0 auto', [`@media (min-width: ${screenSm}px)`]: { - gridTemplateColumns: '1fr 1fr 1fr', + gridTemplateColumns: '1fr 1fr 1fr 1fr 1fr', paddingBottom: '0', + rowGap: '5px', }, }, formItem: { @@ -68,139 +69,199 @@ const useStyles = makeStyles({ textDecoration: 'none', }, }, - acceptPreferences: { - bottom: '-20px', + intercomAlert: { + fontWeight: 'bold', + display: 'flex', + justifyContent: 'center', + padding: '0 0 13px 0', + svg: { + marginRight: '5px', + }, + }, + intercomImage: { + position: 'fixed', cursor: 'pointer', - position: 'absolute', - right: '20px', - textDecoration: 'underline', - - [`@media (min-width: ${screenSm}px)`]: { - bottom: '-10px', - }, - - '&:hover': { - textDecoration: 'none', - }, + height: '80px', + width: '80px', + bottom: '8px', + right: '10px', + zIndex: '1000', + boxShadow: '1px 2px 10px 0 var(rgba(40, 54, 61, 0.18))', }, } as any) -const CookiesBanner = () => { +interface CookiesBannerFormProps { + alertMessage: boolean +} + +const CookiesBanner = (): ReactElement => { const classes = useStyles() const dispatch = useDispatch() const [showAnalytics, setShowAnalytics] = useState(false) + const [showIntercom, setShowIntercom] = useState(false) const [localNecessary, setLocalNecessary] = useState(true) const [localAnalytics, setLocalAnalytics] = useState(false) - const showBanner = useSelector(cookieBannerOpen) + const [localIntercom, setLocalIntercom] = useState(false) - const acceptCookiesHandler = useCallback(async () => { - const newState = { - acceptedNecessary: true, - acceptedAnalytics: !isDesktop, - } - await saveCookie(COOKIES_KEY, newState, 365) - dispatch(openCookieBanner(false)) - setShowAnalytics(!isDesktop) - }, [dispatch]) + const showBanner = useSelector(cookieBannerOpen) useEffect(() => { async function fetchCookiesFromStorage() { const cookiesState = await loadFromCookie(COOKIES_KEY) - if (cookiesState) { - const { acceptedAnalytics, acceptedNecessary } = cookiesState + if (!cookiesState) { + dispatch(openCookieBanner(true)) + } else { + const { acceptedIntercom, acceptedAnalytics, acceptedNecessary } = cookiesState + if (acceptedIntercom === undefined) { + const newState = { + acceptedNecessary, + acceptedAnalytics, + acceptedIntercom: acceptedAnalytics, + } + const expDays = acceptedAnalytics ? 365 : 7 + await saveCookie(COOKIES_KEY, newState, expDays) + setLocalIntercom(newState.acceptedIntercom) + setShowIntercom(newState.acceptedIntercom) + } else { + setLocalIntercom(acceptedIntercom) + setShowIntercom(acceptedIntercom) + } setLocalAnalytics(acceptedAnalytics) setLocalNecessary(acceptedNecessary) - const openBanner = acceptedNecessary === false || showBanner - dispatch(openCookieBanner(openBanner)) - setShowAnalytics(acceptedAnalytics) - } else { - dispatch(openCookieBanner(true)) } } fetchCookiesFromStorage() - }, [dispatch, showBanner]) + }, [showAnalytics, showIntercom]) - useEffect(() => { - if (isDesktop && showBanner) acceptCookiesHandler() - }, [acceptCookiesHandler, showBanner]) + const acceptCookiesHandler = async () => { + const newState = { + acceptedNecessary: true, + acceptedAnalytics: !isDesktop, + acceptedIntercom: true, + } + await saveCookie(COOKIES_KEY, newState, 365) + setShowAnalytics(!isDesktop) + setShowIntercom(true) + dispatch(openCookieBanner(false)) + } const closeCookiesBannerHandler = async () => { const newState = { acceptedNecessary: true, acceptedAnalytics: localAnalytics, + acceptedIntercom: localIntercom, } const expDays = localAnalytics ? 365 : 7 await saveCookie(COOKIES_KEY, newState, expDays) setShowAnalytics(localAnalytics) + setShowIntercom(localIntercom) + if (!localIntercom && isIntercomLoaded()) { + closeIntercom() + } dispatch(openCookieBanner(false)) } - const cookieBannerContent = ( -
- We use cookies to give you the best experience and to help improve our website. Please read our{' '} - - Cookie Policy - {' '} - for more information. By clicking "Accept all", you agree to the storing of cookies on your device - to enhance site navigation, analyze site usage and provide customer support. -
-+ We use cookies to provide you with the best experience and to help improve our website and application. + Please read our{' '} + + Cookie Policy + {' '} + for more information. By clicking "Accept all", you agree to the storing of cookies on your device + to enhance site navigation, analyze site usage and provide customer support. +
+