Skip to content

Commit

Permalink
1.1.1 Callback fix and new Status attribute (#9)
Browse files Browse the repository at this point in the history
* lockfiles

* update

* fix

* add descs

* update version

* update readme

* update callback

* update banner
  • Loading branch information
MysterieDev authored Mar 3, 2022
1 parent b2685d1 commit 5c4899a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cookiebanner.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Cookie Banner
version: 1.1.0
version: 1.1.1
description: Enables a cookie banner for websites
author: Josef Slezak
licence: MIT
Expand All @@ -22,7 +22,7 @@ forms:
label: introduction text as markdown - if you add a link to your data privacy or other links without cookiebanner requirement, add the parameter ?nocb=true
javascriptcallback:
type: textarea
label: callback of the banner - carries an object: { req: true/false, fun: true/false, mar: true/false} for the categories required, functional and marekting. True is for "user has consented". You can get it with 'e.detail'. You are already inside the callback, so just write javascript-statement-blocks.
label: callback of the banner - carries an object: { req: true/false, fun: true/false, mar: true/false, newConsent: true/false} for the categories required, functional and marekting.True is for "user has consented". The attribute newConsent shows, if the user set the cookies just now or if it already persisted in the storage. You can get it with 'e.detail'. You are already inside the callback, so just write javascript-statement-blocks.
consentversion:
type: text
label: Consent Version - Increment this string number to force a new cookiebanner to show
Expand Down
2 changes: 1 addition & 1 deletion public/cookiebanner-index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion solid-frontend-dev/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-template-solid",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"scripts": {
"start": "vite",
Expand Down
16 changes: 9 additions & 7 deletions solid-frontend-dev/src/banner-handling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import {
import { CookieCategory } from "./types";

let consent = { req: true, fun: false, mar: false };

const finishedConsentEvent = new CustomEvent("bannerconsent", {
detail: consent,
const getConsent = ()=> consent
const finishedConsentEvent = (didSeeCookiebannerUI: boolean) => new CustomEvent("bannerconsent", {
detail: {...getConsent(), newConsent: didSeeCookiebannerUI},
});

const setConsent = (details)=> {consent = details};

export const rootName = "#solidApp";
export const preventScrollClass = "cbPreventScroll";

Expand Down Expand Up @@ -43,11 +45,11 @@ export function handleFinishedConsentInteraction(category: CookieCategory) {
fireCallback(false);
}

export function fireCallback(checkCookies: boolean) {
if (checkCookies) {
consent = getConsentCookies();
export function fireCallback(cbAlreadySeen: boolean) {
if (cbAlreadySeen) {
setConsent(getConsentCookies());
}
window.dispatchEvent(finishedConsentEvent);
window.dispatchEvent(finishedConsentEvent(!cbAlreadySeen));
}

export function disableOtherUI() {
Expand Down

0 comments on commit 5c4899a

Please sign in to comment.