mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 02:08:55 +02:00
dismiss
This commit is contained in:
parent
7a17da02cd
commit
888d259313
3 changed files with 10 additions and 3 deletions
|
@ -15,5 +15,5 @@ declare module '@docusaurus/plugin-google-gtag' {
|
|||
}
|
||||
|
||||
declare module '@theme/CookieConsent' {
|
||||
export default function CookieConsent(): JSX.Element;
|
||||
export default function CookieConsent(): JSX.Element | null;
|
||||
}
|
||||
|
|
|
@ -5,14 +5,18 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React, {useState} from 'react';
|
||||
import clsx from 'clsx';
|
||||
import styles from './styles.module.css';
|
||||
import {createStorageSlot} from '@docusaurus/theme-common';
|
||||
|
||||
const storage = createStorageSlot('docusaurus.cookieConsent');
|
||||
|
||||
export default function CookieConsent(): JSX.Element {
|
||||
export default function CookieConsent(): JSX.Element | null {
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
if (dismissed) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div className={styles.banner}>
|
||||
<p className={styles.text}>
|
||||
|
@ -24,6 +28,7 @@ export default function CookieConsent(): JSX.Element {
|
|||
className={clsx('clean-btn', styles.button)}
|
||||
onClick={() => {
|
||||
storage.set('true');
|
||||
setDismissed(true);
|
||||
}}>
|
||||
Accept
|
||||
</button>
|
||||
|
@ -32,6 +37,7 @@ export default function CookieConsent(): JSX.Element {
|
|||
className={clsx('clean-btn', styles.button)}
|
||||
onClick={() => {
|
||||
storage.set('true');
|
||||
setDismissed(true);
|
||||
}}>
|
||||
Deny
|
||||
</button>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
right: 20px;
|
||||
width: 300px;
|
||||
height: 200px;
|
||||
border-radius: var(--ifm-global-radius);
|
||||
}
|
||||
|
||||
.text {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue