1.0.4 • Published 3 years ago

@vivaprivacy/cookie-consent v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Cookie notice with a lot of customization features

Examples

Installing

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/@vivaprivacy/cookie-consent@1.0.4/build/cookie-consent.min.js"></script>

Classic

const CC = window.CookieConsent
Initialization:
const cc = new CC({
  //...options
})
PropTypeDescriptionValues
themestringName of preset theme"CodGrayWhite" (default), "BigStoneTurquoise", "SeaweedAtlantis", "CharadeJaffa", "RhinoShakespeare", "CloudBurstGorse", "SanJuanGold", "BlueChillCanary", "AffairBrightSun", "PorcelainMalibu", "AliceBlueCornflowerBlue", "LinkWaterChathamsBlue", "SazeracTuscany", "CatskillWhiteAquaForest", "WhiteMineShaft"
cookieNamestringName of a cookie stored in a browser."cookie-banner"(default)
typestringType of a banner. confirm: Two buttons(let visitors accept/decline cookies). alert: One button(inform visitors)"confirm" (default), "alert"
blockTypestringDisplay banner as block or line"line" (default), "block"
blockPositionstringBanner position on the screen"bottom" (default), "bottom-left", "bottom-right", "top-left", "top-right", "center", "top", "top-scroll", "bottom-scroll"
buttonTypestringButton styles"round-fill" (default), "round", "rectangle", "rectangle-fill", "rectangle-round", "rectangle-round-fill"
buttonDirectionstringDisplay buttons in a row or one after another"row" (default), "column"
showPoweredBybooleanDisplay credentialstrue (default), false
blind.visiblebooleanDisplay screen overlay to force banner interactionfalse (default), true
blind.bgColorstringOverlay color"black" (default)
blind.opacitystringOverlay opacity".5" (default)
animation.typestringRender a banner with animation."no" (default), "slide-top", "slide-bottom", "slide-left", "slide-right", "fade"
animation.delaystringAnimation delay in milliseconds."5000" (default)
animation.durationstringAnimation duration in milliseconds."500" (default)
link.htmlstringText in the link positioned after the banner message."Learn more" (default)
link.hrefstringLearn more link href"https://gdprinfo.eu" (default)
message.htmlstringMessage displayed inside the banner."This website uses cookies to ensure you get the best experience on our website." (default)
accept.byScrollstringAuto accept and hide banner after user scrolls for x amount of pixels. Provide a number of pixels."none" (default)
accept.byTimenumberAuto accept and hide banner after x amount of milliseconds. Provide a number of milliseconds."-1" (default)
accept.byClickbooleanAuto accept and hide banner after a user clicks anywhere on the screenfalse (default), true
refreshonallowbooleanRefresh a page after user accepts cookies.false (default),true
cookieNamestringCookie name."cookie-banner" (default)
ignoreAllowbooleanIgnores a previous choice of a user and display the banner anyway. Use for testing purposes only.false (default), true
popupStylesobjectChange popup CSSAccepted parameters: {"background-color", "color", "padding", "border-radius", "border-color", "border-width", "border-style", "font-size", "font-family", "border", "box-shadow", "width"}
messageStylesobjectChange message CSSAccepted parameters: {"color", "font-size", "font-family", "margin"}
linkStyleobjectChange link CSS{"background-color", "color", "padding", "border-radius", "border-color", "border-width", "border-style", "box-shadow", "background", "font-size", "font-family", "border", "text-decoration", "margin", "display"}
linkStyleHoverobjectChange link hover CSS{"background-color", "color", "padding", "border-radius", "border-color", "border-width", "border-style", "box-shadow", "background", "font-size", "font-family", "border", "text-decoration", "margin", "display"}
allowHtmlstringAccept button HTML"Accept" (default)
allowStyleobjectAccept button CSS{"background-color", "color", "padding", "border-radius", "border-color", "border-width", "border-style", "font-size", "font-family", "box-shadow", "background", "border"}
allowStyleHoverobjectAccept button hover CSS{"background-color", "color", "padding", "border-radius", "border-color", "border-width", "border-style", "font-size", "font-family", "box-shadow", "background", "border"}
dismissHtmlstringDismiss button HTML"Dismiss" (default)
dismissStyleobjectDismiss button hover CSS{"background-color", "color", "padding", "border-radius", "border-color", "border-width", "border-style", "font-size", "font-family", "box-shadow", "background", "border"}
dismissStyleHoverobjectDismiss button hover CSS{"background-color", "color", "padding", "border-radius", "border-color", "border-width", "border-style", "font-size", "font-family", "box-shadow", "background", "border"}
declineHtmlstringDecline button HTML"Decline" (default)
declineStyleobjectDecline button hover CSS{"background-color", "color", "padding", "border-radius", "border-color", "border-width", "border-style", "font-size", "font-family", "box-shadow", "background", "border"}
declineStyleHoverobjectDecline button hover CSS{"background-color", "color", "padding", "border-radius", "border-color", "border-width", "border-style", "font-size", "font-family", "box-shadow", "background", "border"}
onAllowfunctionFunction to call after a user clicks on the allow buttonExample: function() { console.log("clicked allow button"); }
onDeclinefunctionFunction to call after a user clicks on the decline buttonExample: function() {console.log("clicked decline button");}
onDismissfunctionFunction to call after a user clicks on the dismiss buttonExample: function() {console.log("clicked dismiss button");}
onRestorefunctionFunction to call after the banner is shown againExample: function() {console.log("restores");}
onInitfunction(onAllow)Function to call on banner initizalizationExample: function(isAllow) {console.log("plugin has been initialzed", isAllow);}
onUpdatefunction(onAllow)Function to call on banner updateExample: function(isAllow) {console.log("updated", isAllow);}