React component wrapper for https://github.com/gairal/cooksent
Here is the simplest way to init and use the cookie consent.
You can find more examples in the examples/
directory of this repo.
import React from 'react';
import { render } from 'react-dom';
import ReactCooksent from 'react-cooksent';
render(
<ReactCooksent />
, document.getElementById('root'),
);
npm install react-cooksent
yarn add react-cooksent
Default values are the ones from https://github.com/gairal/cooksent.
{
<ReactCooksent
selector="custom title"
btnSelector="custom title"
title="custom title"
description="custom description"
btnLabel="Oki"
storageKey="COOKSENT2"
force
/>
}
Main popin section class selector
Consent button class selector
Popin title
Popin description
Popin button label
Key used in local storage to memorise the user consent
onConsent expects a function that will be executed when the user clicks on the consent button.
force expects a boolean.
If true
, the popin will be injected in dom even if the user already opted-in.
cooksent/
├──src/ * our source files that will be compiled to javascript
| ├──app/ * Lib sources
│ │
| └──examples/ * examples sources
│ ├──index.pug * our index.html
│ │
│ ├──html/ * where you keep your pug templates
│ │ └──layout.pug * the main pug layout
│ │
│ └──app/ * JavaScript/ES2015 files
│
├──test/ * Jest test definitions
│
├──webpack/ * Webpack configuration files
│ ├──webpack.config.base.js * Base config
│ ├──webpack.config.js * Development overrides
│ └──webpack.config.prod.js * Production overrides
│
└──package.json * package.json
You need to install the following on you system
node
andnpm
- Ensure you running Node version >= 8.0.0
fork
the github repo https://github.com/gairal/cooksentclone
your forknpm install
to install all dependenciesmake start
ornpm start
to start the dev server
After all dependencies are installed, just run make start
to start a local server using webpack-dev-server
which will watch your files and build them.
webpack-dev-server will display the address and port of your server (by default, http://0.0.0.0:3000
).
# build files then launch the server and watch files
make start
# build files in ./build/ (Webpack, Sass, Pug) and validate them
make build
# "compile" files in ./dist/
# minify and concatenate assets
make release
# runs the validations eslint and jest tests
make test