|
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"; |
5 | 3 |
|
6 | | -const storage = createStorageSlot('docusaurus.cookieConsent'); |
| 4 | +const storage = createStorageSlot("docusaurus.cookieConsent"); |
7 | 5 |
|
8 | 6 | 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 "accept" |
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 | + ); |
42 | 56 | } |
0 commit comments