Skip to content

Commit ca37780

Browse files
committed
Improve CookiesConsent Popup
1 parent 1081c49 commit ca37780

File tree

4 files changed

+64
-17
lines changed

4 files changed

+64
-17
lines changed

src/App.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ function App() {
5858
setCookie("theme", newTheme);
5959
};
6060

61+
if (getCookie("cookieconsent_status") === "accepted") {
62+
// @ts-ignore
63+
window["ga-disable-G-P9YFFF08LN"] = false;
64+
} else {
65+
// @ts-ignore
66+
window["ga-disable-G-P9YFFF08LN"] = true;
67+
}
68+
6169
return (
6270
<IntlProvider locale={lang} messages={messages}>
6371
<Router>

src/components/button/sass/Button.module.sass

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
@import '../../../sass/variables.omega.library'
22

33
.button
4-
background-color: #e0e0e0
5-
color: #303030
4+
color: $color-secondary-text
65
font-size: 12px
76
cursor: pointer
87
font-weight: 700
@@ -18,7 +17,7 @@
1817
white-space: nowrap
1918

2019
&:hover
21-
background-color: #c0c0c0
20+
background-color: $color-third-background
2221
animation: hover-feedback 0.2s
2322
box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.08)
2423

src/components/cookiesconsent/CookiesConsent.tsx

+34-6
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,33 @@ type CookiesConsentProps = {
1616
export default function CookiesConsent(props: CookiesConsentProps) {
1717
let _show = false;
1818
const cookie = getCookie("cookieconsent_status");
19-
if (cookie !== "dismiss" && cookie !== "allow") {
19+
if (cookie !== "refused" && cookie !== "accepted") {
2020
_show = true;
2121
}
2222

2323
const [show, setShow] = useState(_show);
2424

2525
const agree = () => {
26-
setCookie("cookieconsent_status", "dismiss");
26+
setCookie("cookieconsent_status", "accepted");
2727
setShow(false);
28+
// @ts-ignore
29+
window["ga-disable-G-P9YFFF08LN"] = false;
30+
};
31+
32+
const refuse = () => {
33+
setCookie("cookieconsent_status", "refused");
34+
setShow(false);
35+
// @ts-ignore
36+
window["ga-disable-G-P9YFFF08LN"] = true;
2837
};
2938

3039
const messages = {
3140
text:
3241
props.message ||
3342
"This website uses cookies to ensure you get the best experience on our website.",
3443
learnMore: props.messageLearnMore || "Learn more",
35-
gotIt: props.messageGotIt || "Got it!",
44+
accept: "Accept",
45+
refuse: "Refuse",
3646
};
3747

3848
return (
@@ -46,9 +56,27 @@ export default function CookiesConsent(props: CookiesConsentProps) {
4656
{messages.learnMore}
4757
</Link>
4858
</div>
49-
<Button onClick={agree} className={styles.button} blue>
50-
{messages.gotIt}
51-
</Button>
59+
<div
60+
style={{
61+
display: "flex",
62+
flexDirection: "row-reverse",
63+
gap: "16px",
64+
width: "100%",
65+
}}
66+
>
67+
<Button
68+
rightIcon="sentiment_very_satisfied"
69+
onClick={agree}
70+
className={styles.button}
71+
blue
72+
big
73+
>
74+
{messages.accept.toUpperCase()}
75+
</Button>
76+
<Button onClick={refuse} className={styles.button} big>
77+
{messages.refuse.toUpperCase()}
78+
</Button>
79+
</div>
5280
</div>
5381
);
5482
}
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
@import '../../../sass/variables.omega.library'
22

33
.cookiesConsent
4+
display: flex
5+
flex-direction: column
6+
align-items: flex-start
7+
gap: 16px
48
z-index: 10000000
5-
width: 100%
9+
width: calc(100% - 96px)
610
box-sizing: border-box
7-
background-color: $color-third-background
11+
background-color: $color-secondary-background
12+
border: 1px solid $color-third-background
813
color: $color-primary-text
9-
padding: 12px 48px
14+
margin: 24px 48px
15+
margin-top: 48px
16+
padding: 24px 32px
1017
vertical-align: middle
1118
font-size: 14px
1219
overflow: hidden
1320
box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.08)
21+
position: relative
22+
border-radius: 16px
1423

1524
.text
25+
font-size: 15px
1626
display: inline-block
1727
line-height: 20px
18-
margin-top: 8px
1928
display: inline-block
2029
vertical-align: middle
21-
margin-right: 100px
30+
margin-bottom: 16px
2231

2332
.link
2433
padding: 2px 4px
@@ -31,13 +40,16 @@
3140

3241
.button
3342
margin-top: 2px
34-
float: right
3543
vertical-align: middle
44+
padding: 12px 24px
3645

3746
@media screen and ( min-width: 1400px )
3847
.cookiesConsent
39-
padding: 12px calc(15% - 16px)
48+
margin: 48px calc(15% - 16px)
49+
width: calc(100% - 30% + 32px)
4050

4151
@media screen and ( max-width: 700px )
4252
.cookiesConsent
43-
padding: 12px 24px
53+
margin: 24px
54+
margin-top: 48px
55+
width: calc(100% - 48px)

0 commit comments

Comments
 (0)