2.4.1 • Published 4 months ago

@superkoders/cookie v2.4.1

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

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

2.4.1

4 months ago

2.4.0

4 months ago

2.3.1

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.0

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago