JSPM

react-mui-cookie-dialog

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q29131F
  • License MIT

A simple solution for a GDPR compliant Cookie dialog with support for multiple Cookie categories.

Package Exports

  • react-mui-cookie-dialog

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-mui-cookie-dialog) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Material Ui Cookie Dialog

Version Downloads

A simple solution for a GDPR compliant Cookie dialog.

Example

import { Typography } from '@material-ui/core';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {
  CookieDialog,
  CookieDialogCategory,
  cookieDialogStringDefaultsGerman,
} from 'react-mui-cookie-dialog';

const categories: CookieDialogCategory[] = [
  {
    key: 'necessary',
    title: 'Necessary Cookies',
    description: 'Necessary Cookie description.',
    isNecessary: true,
  },
  {
    key: 'analytics',
    title: 'Analytics & Personalization',
    description: 'Analytics Cookie description.',
  },
  {
    key: 'marketing',
    title: 'Marketing',
    description: 'Marketing Cookie description.',
  },
];

const App = () => {
  const [cookieDialogVisible, setCookieDialogVisible] = React.useState(true);

  const handleAccept = (acceptedCategories: CookieDialogCategory[]) => {
    // Do something with the accepted categories
    setCookieDialogVisible(false);
  };

  return (
    <div>
      <CookieDialog
        visible={cookieDialogVisible}
        categories={categories}
        onAccept={handleAccept}
        // You can use the german pre defined strings but for every
        // other language you will have to define the strings yourself.
        {...cookieDialogStringDefaultsGerman}
        // Every string can be replaced with a function component like this
        mainDialogTitle={() => <Typography>Example title</Typography>}
      />
    </div>
  );
};

ReactDOM.render(<App />, document.getElementById('root'));