Skip to content

Commit 7713bc4

Browse files
committed
feat(ui): restyle cookie consent banner with design tokens
Replace fixed-size layout and hardcoded hex colors with --cs-* tokens. Banner now uses the surface/border/ink palette and orange CTA button consistent with the rest of the UI.
1 parent 340bf68 commit 7713bc4

2 files changed

Lines changed: 53 additions & 76 deletions

File tree

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,56 @@
1-
import clsx from 'clsx';
2-
import styles from './styles.module.css';
3-
import {createStorageSlot} from '@docusaurus/theme-common';
4-
import React, {useState} from 'react';
1+
import { createStorageSlot } from "@docusaurus/theme-common";
2+
import React, { useState } from "react";
53

6-
const storage = createStorageSlot('docusaurus.cookieConsent');
4+
const storage = createStorageSlot("docusaurus.cookieConsent");
75

86
export default function CookieConsent() {
9-
const [dismissed, setDismissed] = useState(false);
10-
if (dismissed) {
11-
return null;
12-
}
13-
return (
14-
<div className={styles.banner}>
15-
<p className={styles.text}>
16-
This website uses cookies to help us improve. Click &quot;accept&quot;
17-
to allow us to continue using cookies.
18-
</p>
19-
<div className={styles.buttons}>
20-
<button
21-
type="button"
22-
className={clsx('clean-btn', styles.button)}
23-
onClick={() => {
24-
storage.set('true');
25-
window.dispatchEvent(new CustomEvent('cookieConsentAccepted'));
26-
setDismissed(true);
27-
}}>
28-
Accept
29-
</button>
30-
<button
31-
type="button"
32-
className={clsx('clean-btn', styles.button)}
33-
onClick={() => {
34-
storage.set('false');
35-
setDismissed(true);
36-
}}>
37-
Decline
38-
</button>
39-
</div>
40-
</div>
41-
);
7+
const [dismissed, setDismissed] = useState(false);
8+
if (dismissed) return null;
9+
10+
return (
11+
<div className="fixed bottom-6 right-6 w-80 rounded-[14px] bg-cs-surface border border-cs-border-hi z-[9999] flex flex-col gap-3.5 p-5 pb-4"
12+
style={{ boxShadow: "0 16px 48px rgba(0,0,0,0.35), 0 0 0 1px rgba(148,163,184,0.06)" }}
13+
>
14+
{/* Eyebrow */}
15+
<div className="font-cs-mono text-[10px] tracking-[0.18em] uppercase text-cs-orange font-semibold">
16+
CrowdSec Docs
17+
</div>
18+
19+
{/* Title + body */}
20+
<div>
21+
<div className="text-sm font-semibold text-cs-ink mb-1.5">
22+
We use cookies
23+
</div>
24+
<p className="m-0 text-[13px] text-cs-ink-dim leading-[1.55]">
25+
This site uses cookies to help us improve your experience. You can
26+
accept or decline below.
27+
</p>
28+
</div>
29+
30+
{/* Actions */}
31+
<div className="flex gap-2">
32+
<button
33+
type="button"
34+
onClick={() => {
35+
storage.set("true");
36+
window.dispatchEvent(new CustomEvent("cookieConsentAccepted"));
37+
setDismissed(true);
38+
}}
39+
className="flex-1 py-2 px-3 rounded-lg bg-cs-orange text-cs-btn-text font-sans text-[13px] font-semibold border-0 cursor-pointer"
40+
>
41+
Accept
42+
</button>
43+
<button
44+
type="button"
45+
onClick={() => {
46+
storage.set("false");
47+
setDismissed(true);
48+
}}
49+
className="flex-1 py-2 px-3 rounded-lg bg-cs-surface-2 text-cs-ink-dim font-sans text-[13px] font-semibold border border-cs-border-hi cursor-pointer"
50+
>
51+
Decline
52+
</button>
53+
</div>
54+
</div>
55+
);
4256
}
Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1 @@
1-
.banner {
2-
background-color: var(--ifm-color-emphasis-200);
3-
position: fixed;
4-
bottom: 20px;
5-
right: 20px;
6-
width: 300px;
7-
height: 200px;
8-
border-radius: var(--ifm-global-radius);
9-
box-shadow: 0 1.5px 6px 0 rgba(0, 0, 0, 0.15) inset;
10-
z-index: 1000;
11-
}
12-
13-
.text {
14-
font-size: small;
15-
padding: 30px;
16-
}
17-
18-
.buttons {
19-
position: absolute;
20-
bottom: 20px;
21-
display: flex;
22-
justify-content: center;
23-
width: 100%;
24-
}
25-
26-
.button {
27-
width: 100px;
28-
background-color: #d0d0d0 !important;
29-
margin: 10px;
30-
/* TODO this is because the CSS is imported as a client module as well, and happens to be before Infima */
31-
padding: 5px !important;
32-
border-radius: var(--ifm-global-radius);
33-
}
34-
35-
html[data-theme='dark'] .button {
36-
background: #333333 !important;
37-
}
38-
1+
/* Cookie consent styles moved to inline styles in cookieconsent.js */

0 commit comments

Comments
 (0)