Skip to content

Commit 7beea47

Browse files
committed
fix: use grid in cookie banner
1 parent edd24ce commit 7beea47

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

www/app/cookie-banner/CookieBanner.js

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@ import { FormattedMessage } from 'react-intl';
33
import classNames from 'classnames';
44
import PropTypes from 'prop-types';
55
import Link from 'next/link';
6-
import { createLocalStorageStateHook } from 'use-local-storage-state';
6+
import useLocalStorageState from 'use-local-storage-state';
7+
import { Container, Row, Col } from '../../shared/react/grid';
78

89
import styles from './CookieBanner.module.css';
910

1011
const MAX_CONSENT_DAYS = 365;
1112
const MAX_REJECTED_DAYS = 7;
1213

13-
const useLocalStorageState = createLocalStorageStateHook('cookie-banner', {
14-
consents: [],
15-
consentedAt: null,
16-
rejectedAt: null,
17-
});
18-
1914
const CookieBanner = ({ className, onConsents, ...rest }) => {
2015
const [mounted, setMounted] = useState(false);
21-
const [state, setState] = useLocalStorageState();
16+
const [state, setState] = useLocalStorageState('cookie-banner', {
17+
consents: [],
18+
consentedAt: null,
19+
rejectedAt: null,
20+
});
2221

2322
const consents = useMemo(() => (
2423
state.consentedAt > Date.now() - (MAX_CONSENT_DAYS * 24 * 60 * 60 * 1000) ? state.consents : []
@@ -59,26 +58,32 @@ const CookieBanner = ({ className, onConsents, ...rest }) => {
5958

6059
return (
6160
<div className={ classNames(styles.cookieBanner, className) } { ...rest }>
62-
<p>
63-
<FormattedMessage
64-
id="cookie-banner.text"
65-
values={ {
66-
link: /* istanbul ignore next */ (...chunks) => (
67-
<Link href="/terms">
68-
<a>{ chunks }</a>
69-
</Link>
70-
),
71-
} } />
72-
</p>
61+
<Container>
62+
<Row justifyContent="space-between" alignItems="center">
63+
<Col>
64+
<p>
65+
<FormattedMessage
66+
id="cookie-banner.text"
67+
values={ {
68+
link: /* istanbul ignore next */ (...chunks) => (
69+
<Link href="/terms">
70+
<a>{ chunks }</a>
71+
</Link>
72+
),
73+
} } />
74+
</p>
75+
</Col>
7376

74-
<div className={ styles.buttons }>
75-
<button className={ styles.accept } type="button" onClick={ handleAcceptClick }>
76-
<FormattedMessage id="cookie-banner.accept" />
77-
</button>
78-
<button type="button" onClick={ handleRejectClick }>
79-
<FormattedMessage id="cookie-banner.reject" />
80-
</button>
81-
</div>
77+
<Col columns="auto" className={ styles.buttonsCol }>
78+
<button className={ styles.accept } type="button" onClick={ handleAcceptClick }>
79+
<FormattedMessage id="cookie-banner.accept" />
80+
</button>
81+
<button type="button" onClick={ handleRejectClick }>
82+
<FormattedMessage id="cookie-banner.reject" />
83+
</button>
84+
</Col>
85+
</Row>
86+
</Container>
8287
</div>
8388
);
8489
};

www/app/cookie-banner/CookieBanner.module.css

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
@import "../../shared/styles/imports";
22

33
.cookieBanner {
4-
@mixin position fixed, null, null, 0, 0;
5-
width: 100%;
4+
@mixin position fixed, null, 0, 0, 0;
65
min-width: var(--viewport-min-width);
76
min-height: 8rem;
87
z-index: calc(var(--z-index-cookie-banner) + 1);
9-
padding: 2.5rem;
8+
padding: 2rem 0;
109
display: flex;
11-
justify-content: space-between;
1210
align-items: center;
1311
border-top: 0.1rem solid;
1412
background-color: var(--color-white);
15-
font-size: 1.4rem;
13+
color: var(--color-black);
14+
@mixin typography-body-2;
1615

17-
& .buttons {
16+
& .buttonsCol {
1817
display: flex;
1918
flex: 0 0 auto;
2019

0 commit comments

Comments
 (0)