@superkoders/cookie

2.4.1 • Public • Published

SUPERKODERS Cookie

Package for our custom "cookie" popup implementation. Everything what you need to know is in our Notion.

Package expose files (source and compiled)

  1. base css for popup style
  2. vanilla javascript module for interaction management.

Implementation

Option 1: Add to build

// project css/components/box/cookie.scss

@import @superkoders/cookie/css/components/box/cookie

.b-cookie {
	&__box {
		background: #000;
	}
}
// app.js

import * as cookie from '@superkoders/cookie/js/components/cookie.js';

cookie.init();

Option 2: Use compiled version

link css

<link rel="stylesheet" href="https://unpkg.com/@superkoders/cookie@latest/dist/css/cookie.css">

link js

<script src="https://unpkg.com/@superkoders/cookie@latest/dist/js/cookie.js"></script>

Javascript API

exposed method from javascript module

// start cookie popup interactivity
init()

// open cookie popup again
open()

// subscribe to cookie event - update, delete
on(type, fn); 
// subscribe to cookie event only once
one(type, fn);
// unsubscribe to cookie event
off(type, fn);

// current cookie object
getCurrentState(); 
// delete all user votes
deleteConsent();
// check if user voted
didUserConsent(); 

// check if user accepted some category
// ['functional_storage', 'ad_storage', 'analytics_storage', 'personalization_storage']
allowedCategory('functional_storage'); 

// run lazyevaluated embeds
heckEmbeds();
// run lazyevaluated scripts
checkScripts();

When compiled package is linked all API is exported to window.SKcookieAPI.

window.SKcookieAPI.init();
window.SKcookieAPI.checkScripts();
window.SKcookieAPI.on('update', window.SKcookieAPI.checkScripts);

Author

Readme

Keywords

none

Package Sidebar

Install

npm i @superkoders/cookie

Weekly Downloads

532

Version

2.4.1

License

none

Unpacked Size

30.2 kB

Total Files

7

Last publish

Collaborators

  • martina.paclikova
  • josk
  • andsco
  • fireball_
  • jena.hajek
  • petrbulaneksk
  • petr.grochal