-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from logicalley/chore/create-cookie-consent-form
- Loading branch information
Showing
8 changed files
with
142 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters