0.1.8 • Published 6 years ago

simple-cookie-consent v0.1.8

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

Simple Cookie Consent

npm version StyleCI

A basic cookie consent bar to help comply with the EU GDPR regulation. Compatible with all modern browsers and IE10+. It works by storing whether the user has consented in localStorage.

By default, it displays a simple message and an 'Accept' button but an additional button (e.g. 'Find out more' with a custom link) can be added (see Parameters). For example:

Cookie Bar Example

Installation

Yarn

yarn add simple-cookie-consent --dev

NPM

npm install simple-cookie-consent --save --dev

Usage

The library relies on Javascript to build the DOM/functionality and SCSS for basic styling.

1. Javascript

import SimpleCookieConsent from 'simple-cookie-consent';

new SimpleCookieConsent();

2. SCSS

@import '../../node_modules/simple-cookie-consent/dist/simple-cookie-consent.min.css';

Custom styling

All changes to styling should be made in CSS by overriding the base styles imported from the library. The markup is written using the BEM methodology and changes can be structrued like so (SCSS):

.c-simple-cookie-consent {
	// Bar styles here (e.g. background-color, position, z-index)
	&__policy {
		// Message styling here (e.g. font)
	}

    &__button {
    	// Styles that apply to both the 'accept' and 'additonal button'. (e.g. background-color)
    	&--additional {
    		// Styles specifically for the 'additonal' button which override the base button styling
    	}
    }
}

For additional elements, such as placement of buttons, inspect the bar in dev tools and override as demonstrated above.

Parameters

(policyText, barClassName, additionalLink, additionalLinkText)

MIT © Chris Boakes

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago