Skip to content

Commit

Permalink
Merge pull request #16 from logicalley/chore/create-cookie-consent-form
Browse files Browse the repository at this point in the history
  • Loading branch information
BolajiOlajide committed Jul 26, 2021
2 parents e155c2a + e157e73 commit 38ccec3
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 11 deletions.
48 changes: 48 additions & 0 deletions components/CookieForm/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, { useState, useEffect } from 'react';
import Image from 'next/image';
import Link from 'next/link';
import { useCookie } from 'next-cookie';

import styles from './styles.module.css';

import { ANNIE_USER_COOKIE_ACCEPT } from '../../utils/constants';

const CookieForm: React.FC = () => {
const [showCookieForm, setShowCookieForm] = useState<boolean>(false);
const cookie = useCookie();

const handleSubmit = (): void => {
cookie.set(ANNIE_USER_COOKIE_ACCEPT, 1);
setShowCookieForm(false);
};

useEffect(() => {
const cookieValue = cookie.get(ANNIE_USER_COOKIE_ACCEPT);
if (cookieValue == 1) {
setShowCookieForm(false);
} else {
setShowCookieForm(true);
}
}, []);

return showCookieForm ? (
<section className={styles.cookieContainer}>
<section className={styles.cookieImage}>
<Image src="/images/cookie.jpg" alt="cookie" width="36" height="36" />
</section>

<section className={styles.privacyText}>
By using Annie, you agree to our
<Link href="/privacy-policy">
<a>Privacy Policy</a>
</Link>
</section>

<button className={styles.acceptBtn} onClick={handleSubmit}>
ACCEPT
</button>
</section>
) : null;
};

export default CookieForm;
53 changes: 53 additions & 0 deletions components/CookieForm/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.cookieContainer {
position: fixed;
top: 90vh;
transform: translateX(-50%);
left: 50%;
width: 34rem;
display: flex;
justify-content: space-around;
align-items: center;
padding: 0.6rem;
background-color: var(--white);
box-shadow: 2px 2px 7px var(--primary3);
border-radius: var(--borderRadius);
z-index: 5;
}

.cookieImage {
width: 36px;
height: 36px;
}
.cookieImage img {
width: 100%;
height: 100%;
}
.acceptBtn {
background-color: var(--primary);
border: none;
padding: 2px 14px;
height: 2.1rem;
color: var(--white);
border-radius: var(--borderRadius);
}
.acceptBtn:hover {
cursor: pointer;
}
.privacyText {
font-size: 0.8rem;
text-align: center;
width: 64%;
}
.privacyText a {
color: var(--primary);
font-size: 0.8rem;
}

@media screen and (max-width: 600px) {
.cookieContainer {
width: 90vw;
}
.privacyText {
margin-left: 10px;
}
}
11 changes: 7 additions & 4 deletions components/TrackDetail/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.trackHeaderContainer {
width: 100%;
height: 70px;
background: #F9F7FD;
background: #f9f7fd;
position: absolute;
top: 0;
left: 0;
Expand Down Expand Up @@ -72,7 +72,7 @@
}

.genreYear span {
color: #5A6479;
color: #5a6479;
font-size: 11px;
}

Expand All @@ -84,6 +84,9 @@
justify-content: space-between;
margin-top: auto;
}
.trackFooter span {
text-align: center;
}

.footerLinks {
margin-top: 10px;
Expand Down Expand Up @@ -139,14 +142,14 @@
margin: 20px 0;
outline: 0;
cursor: pointer;
border: 1px solid #FFE9F4;
border: 1px solid #ffe9f4;
box-shadow: 0 4px 4px rgba(90, 100, 121, 0.05);
background: none;
}

.annieCardContainer {
composes: platformCardContainerBase;
background: #F3EEFD;
background: #f3eefd;
}

.shareGroup {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/react-select": "4.0.13",
"netlify-plugin-cache-nextjs": "1.5.2",
"next": "11.0.1",
"next-cookie": "2.6.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hot-toast": "1.0.2",
Expand Down
2 changes: 2 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { AppProps } from 'next/app';

import '../assets/css/global.css';
import { registerPageView } from '../utils/googleAnalytics';
import CookieForm from '../components/CookieForm';

if (typeof window !== 'undefined') {
// On the client, we have to run this once before React attempts a render.
Expand Down Expand Up @@ -50,6 +51,7 @@ const App: React.FC<AppProps> = ({ Component, pageProps }: AppProps) => {
<title>Annie</title>
</Head>
<Component {...pageProps} />
<CookieForm />
<Toaster position={toastPosition} reverseOrder={false} />
<section id="modal" />
</Fragment>
Expand Down
Binary file added public/images/cookie.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ export const OEMBED_BASE_URL: string =

export const ANNIE_USER_SELECTED_STOREFRONT_KEY: string =
'ANNIE_STOREFRONT_USER_KEY';

export const ANNIE_USER_COOKIE_ACCEPT: string = 'ANNIE_USER_COOKIE_ACCEPT';
36 changes: 29 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,11 @@
path-to-regexp "^6.1.0"
send "^0.17.1"

"@types/cookie@^0.3.3":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.3.tgz#85bc74ba782fb7aa3a514d11767832b0e3bc6803"
integrity sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow==

"@types/glob@^7.1.1":
version "7.1.4"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.4.tgz#ea59e21d2ee5c517914cb4bc8e4153b99e566672"
Expand Down Expand Up @@ -1802,7 +1807,7 @@ convert-source-map@1.7.0:
dependencies:
safe-buffer "~5.1.1"

cookie@^0.4.1:
cookie@^0.4.0, cookie@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1"
integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==
Expand Down Expand Up @@ -3214,6 +3219,11 @@ jws@^3.2.2:
jwa "^1.4.1"
safe-buffer "^5.0.1"

kind-of@>=6.0.3, kind-of@^6.0.0, kind-of@^6.0.2:
version "6.0.3"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0:
version "3.2.2"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
Expand All @@ -3233,11 +3243,6 @@ kind-of@^5.0.0:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d"
integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==

kind-of@^6.0.0, kind-of@^6.0.2:
version "6.0.3"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

klaw@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/klaw/-/klaw-3.0.0.tgz#b11bec9cf2492f06756d6e809ab73a2910259146"
Expand Down Expand Up @@ -3467,7 +3472,7 @@ minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"

minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5:
minimist@>=1.2.5, minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
Expand Down Expand Up @@ -3594,6 +3599,15 @@ netlify-plugin-cache-nextjs@1.5.2:
dependencies:
"@netlify/cache-utils" "1.0.2"

next-cookie@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/next-cookie/-/next-cookie-2.6.2.tgz#0a71e54adb92bfab084e02b7e1dd02829995a672"
integrity sha512-2M/76qCzanVaEjmzWQravWA/iJSupaqWC1mnLgbjfNhMATHGkUVrVEsmboZt1ojp4luHAtkhnmnpqmxvUpE3oA==
dependencies:
kind-of ">=6.0.3"
minimist ">=1.2.5"
universal-cookie "~4.0.4"

next@11.0.1:
version "11.0.1"
resolved "https://registry.yarnpkg.com/next/-/next-11.0.1.tgz#b8e3914d153aaf7143cb98c09bcd3c8230eeb17a"
Expand Down Expand Up @@ -5075,6 +5089,14 @@ union-value@^1.0.0:
is-extendable "^0.1.1"
set-value "^2.0.1"

universal-cookie@~4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/universal-cookie/-/universal-cookie-4.0.4.tgz#06e8b3625bf9af049569ef97109b4bb226ad798d"
integrity sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==
dependencies:
"@types/cookie" "^0.3.3"
cookie "^0.4.0"

universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
Expand Down

0 comments on commit 38ccec3

Please sign in to comment.