Skip to content

Commit

Permalink
feat: Add cookies dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
timglaser committed Jul 2, 2020
1 parent 73cf3fc commit dc81263
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/components/CookieApprovalDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import PropTypes from 'prop-types';
import Button from './Button';
import styles from './CookieApprovalDialog.module.scss';

const CookieApprovalDialog = ({ className }) => {
return (
<div className={`${styles.container} ${className || ''}`}>
<div className={styles.content}>
<div className={styles.primaryContent}>
<h4 className={styles.heading}>
This site uses cookies{' '}
<span role="img" aria-label="Cookie emoji">
🍪
</span>
</h4>
<p className={styles.description}>
We rely on cookies to play videos, remember your preferences, and
analyze our website traffic. You consent to our cookies if you click
“OK”.
</p>
</div>
<div className={styles.ctaContainer}>
<Button
className={`button ${styles.approvalButton}`}
variant={Button.VARIANT.PRIMARY}
>
OK
</Button>
<Button
className={`${styles.ignoreButton}`}
variant={Button.VARIANT.NORMAL}
>
Reject
</Button>
</div>
</div>
</div>
);
};

CookieApprovalDialog.propTypes = {
className: PropTypes.string,
};

export default CookieApprovalDialog;
113 changes: 113 additions & 0 deletions src/components/CookieApprovalDialog.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
.container {
width: 100%;
position: fixed;
bottom: 0;
z-index: 10000;
background-color: rgba(28, 42, 47, 0.92);
box-shadow: 0px -0.249053px 4.26158px rgba(12, 48, 57, 0.0421718),
0px -0.598509px 10.2412px rgba(12, 48, 57, 0.0605839),
0px -1.12694px 19.2832px rgba(12, 48, 57, 0.075),
0px -2.01027px 34.3979px rgba(12, 48, 57, 0.0894161),
0px -3.75998px 64.3375px rgba(12, 48, 57, 0.107828),
0px -9px 154px rgba(12, 48, 57, 0.15);
backdrop-filter: blur(5px);
}

.content {
display: flex;
justify-content: space-between;
align-items: center;
width: 1180px;
margin: 0 auto;
box-sizing: border-box;
padding: 18px 0;
}

.heading {
color: #fff;
margin-top: 0;
margin-bottom: 2px;
line-height: 21px;
}

.description {
margin: 0 0 0px;
font-size: 13px;
line-height: 21px;
color: var(--color-neutrals-500);
}

.cta-container {
margin-left: 16px;
flex-shrink: 0;
}

.approval-button {
margin-right: 10px;
padding: 10px 30px;
}

.button-close {
position: absolute;
top: 4px;
right: 4px;
opacity: 0.75;
}

// ==============================================================
// Responsive styles
// ==============================================================
@media screen and (max-width: 1200px) {
.content {
width: 100%;
padding: 18px 28px;
}

.heading {
margin-bottom: 6px;
}

.description {
line-height: 19px;
}
}

@media screen and (max-width: 480px) {
.content {
flex-direction: column;
align-items: flex-start;
}

.description {
margin-bottom: 16px;
}

.cta-container {
margin: 0;
}

.approval-button {
padding-top: 8px;
padding-bottom: 8px;
}

.ignore-button {
padding-top: 8px;
padding-bottom: 8px;
color: var(--color-neutrals-700);
}
}

// ==============================================================
// Dark mode
// ==============================================================
:global(.dark-mode) {
.container {
background-color: rgba(15, 25, 28, 0.92);
box-shadow: 0 -1px 0 rgba(55, 72, 78, 0.4);
}

.description {
color: var(--color-neutrals-600);
}
}
2 changes: 2 additions & 0 deletions src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Footer from './Footer';
import GlobalHeader from './GlobalHeader';
import MobileHeader from './MobileHeader';
import Sidebar from './Sidebar';
import CookieApprovalDialog from './CookieApprovalDialog';
import styles from './Layout.module.scss';
import 'normalize.css';
import './styles.scss';
Expand Down Expand Up @@ -34,6 +35,7 @@ const Layout = ({ children }) => {
<Footer className={styles.footer} />
</div>
</div>
<CookieApprovalDialog />
</div>
);
};
Expand Down

0 comments on commit dc81263

Please sign in to comment.