@@ -3,22 +3,21 @@ import { FormattedMessage } from 'react-intl';
3
3
import classNames from 'classnames' ;
4
4
import PropTypes from 'prop-types' ;
5
5
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' ;
7
8
8
9
import styles from './CookieBanner.module.css' ;
9
10
10
11
const MAX_CONSENT_DAYS = 365 ;
11
12
const MAX_REJECTED_DAYS = 7 ;
12
13
13
- const useLocalStorageState = createLocalStorageStateHook ( 'cookie-banner' , {
14
- consents : [ ] ,
15
- consentedAt : null ,
16
- rejectedAt : null ,
17
- } ) ;
18
-
19
14
const CookieBanner = ( { className, onConsents, ...rest } ) => {
20
15
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
+ } ) ;
22
21
23
22
const consents = useMemo ( ( ) => (
24
23
state . consentedAt > Date . now ( ) - ( MAX_CONSENT_DAYS * 24 * 60 * 60 * 1000 ) ? state . consents : [ ]
@@ -59,26 +58,32 @@ const CookieBanner = ({ className, onConsents, ...rest }) => {
59
58
60
59
return (
61
60
< 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 >
73
76
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 >
82
87
</ div >
83
88
) ;
84
89
} ;
0 commit comments