cooksent v0.0.1
CookSent
Straight simple cookie consent popin using local storage
Motivation
Simple and lightweight reusable cookie consent module for web dev
Usage
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 Cooksent from 'cooksent';
const cooksent = Cooksent.factory();Table of Contents
Installation
npm install cooksentyarn add cooksentConsent Options
Default values:
{
selector: 'js-cooksent',
btnSelector: 'js-cooksent__btn',
title: 'Cookie Consent',
description: 'By continuing your navigation without changing your cookie settings, you accept the use of cookies to analyse and measure audience, attendance, navigation and redirection from external websites.',
btnLabel: 'ok',
onConsent: () => {},
storageKey: 'COOKSENT',
}selector
Main popin section class selector
btnSelector
Consent button class selector
title
Popin title
description
Popin description
btnLabel
Popin button label
storageKey
Key used in local storage to memorise the user consent
onConsent
onConsent expects a function that will be executed when the user clicks on the consent button.
Contribute
File structure
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.jsonGetting Started
Dependencies
You need to install the following on you system
nodeandnpm- Ensure you running Node version >= 8.0.0
Installing
forkthe github repo https://github.com/gairal/cooksentcloneyour forknpm installto install all dependenciesmake startornpm startto start the dev server
Running the app
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 commands
Server
# build files then launch the server and watch files
make startBuild files
# build files in ./build/ (Webpack, Sass, Pug) and validate them
make build
# "compile" files in ./dist/
# minify and concatenate assets
make releaseValidate files
# runs the validations eslint and jest tests
make testLicense
Author: Frank Gairal
7 years ago