Package for our custom "cookie" popup implementation. Everything what you need to know is in our Notion.
Package expose files (source and compiled)
- base css for popup style
- vanilla javascript module for interaction management.
// 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();
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>
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);
- SUPERKODERS - www.superkoders.com – support@superkoders.com