Detalhes do pacote

cookie-consent-box

adriandmitroca122MIT2.4.0

A tiny, dependency-free cookie box widget that helps you to be GDPR complaint after including 8 kB of code (gzipped)

adriandmitroca, cookie-box, cookie-law, cookie-consent

readme (leia-me)

cookie-consent-box

Latest Version on NPM Software License Build Status

This is a simple package that lets you add good-looking cookie box to your website within few seconds without any setup required. If you would like to see how it works and looks, make sure to check out the demo.

Usage

Webpack

You can install the package via package manager of your choice:

$ yarn add cookie-consent-box
$ npm install cookie-consent-box

Import it as normal ES6 module:

import CookieBox from 'cookie-consent-box';

new CookieBox({ options }).init();

and include in your SCSS file:

@import "~cookie-consent-box/dist/cookie-consent-box";

CDN

Or include it via jsDelivr CDN:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/cookie-consent-box@2.3.1/dist/cookie-consent-box.min.css" />
<script defer src="https://cdn.jsdelivr.net/npm/cookie-consent-box@2.3.1/dist/cookie-consent-box.min.js"></script>

Additionaly, you can configure the plugin using CookieBoxConfig object declared in your DOM. Just make sure that you declared it before you load js file.

Example:

<script>CookieBoxConfig = { backgroundColor: '#ec008c', url: '/privacy-policy' }</script>

Available Options

Option Type Default Description
backgroundColor string #007bff Color used for background
textColor string #fff Color used for text
language string en ISO 639 code. Supported languages: en, de, pl, ro, it, fr, pt
url string/null null Custom URL that points to your Privacy Policy page. If empty, link is automatically hidden.
linkTarget string _blank The target parameter for the url above.
containerWidth int 1140 Width of your page container
cookieKey string cookie-box Cookie name that is used to save users acceptance
cookieDomain string defaults to the host portion of the current document location The domain that the cookie belongs to
cookieExpireInDays int 365 The number of days after which the cookie expires
content object/null defaults to language Content object accepts following properties: title, content, accept, learnMore.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

Credits

changelog (log de mudanças)

Changelog

2.4.0

  • added cookieDomain option
  • fixed font family mismatch [#11]

2.3.1

  • added: portuguese translation (language: 'pt')

2.3.0

  • added: italian translation (language: 'it')
  • added: french translation (language: 'fr')
  • added: option to customise notice content using content object
  • added: option to customise cookie expiration time using expireInDays
  • added: option to set href target using linkTarget param
  • tweak: hide "read more" link when url is not provided
  • tweak: remove box from the DOM after accepting it (resolves Safari iOS issue with transform recalculation on orientation change)
  • fixed: more robust styles to avoid conflicts with site styling

2.2.1

  • example typo fix

2.2.0

  • added romanian translation (language: 'ro')

2.1.0

  • added german translation (language: 'de')

2.0.4

  • fixed icon overlapping issue on mobile

2.0.1

  • added cookieKey option
  • tweaked closing transition to match new design

2.0.0

  • introduced whole new design
  • brandColor option became backgroundColor
  • added containerWidth option

1.1.0

  • added responsive styles
  • added umd support
  • added textColor option

1.0.1

  • Added CDN links
  • Fixed ES6 import

1.0.0

  • Initial release