6 Commits

5 changed files with 60 additions and 36 deletions

View File

@ -1,5 +1,25 @@
# Changelog # Changelog
## 2025-01-17 - 1.4.5 - fix(elements)
Fix issues in consentsoftware-cookieconsent component
- Removed unused attribute handling for 'gotIt'.
- Fixed background and backdrop-filter transitions to ensure proper UI behavior.
- Consolidated consent button click handling into handleConsentButtonClick.
- Improved modal visibility toggling and acceptance flow.
## 2025-01-17 - 1.4.4 - fix(core)
Update LitElement properties to use accessors
- Changes made in ts_web/elements/consentsoftware-toggle.ts
- Updated properties 'required' and 'selected' to use accessors
## 2025-01-17 - 1.4.3 - fix(consentsoftware-cookieconsent)
Fix transition property in consent button styles and add HTMLElementTagNameMap declaration for global interface.
- Updated the transition property for consent buttons to transition all properties instead of just the background.
- Added global interface HTMLElementTagNameMap for custom element type support.
## 2025-01-16 - 1.4.2 - fix(cookieconsent) ## 2025-01-16 - 1.4.2 - fix(cookieconsent)
Fix user-select property in consentsoftware-cookieconsent component for consistency in interaction. Fix user-select property in consentsoftware-cookieconsent component for consistency in interaction.

View File

@ -1,6 +1,6 @@
{ {
"name": "@consent.software/catalog", "name": "@consent.software/catalog",
"version": "1.4.2", "version": "1.4.5",
"private": false, "private": false,
"description": "A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.", "description": "A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.",
"exports": { "exports": {

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@consent.software/catalog', name: '@consent.software/catalog',
version: '1.4.2', version: '1.4.5',
description: 'A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.' description: 'A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.'
} }

View File

@ -8,6 +8,12 @@ import * as csInterfaces from '@consent.software/interfaces';
import * as csWebclient from '@consent.software/webclient'; import * as csWebclient from '@consent.software/webclient';
import { delayFor } from '@push.rocks/smartdelay'; import { delayFor } from '@push.rocks/smartdelay';
declare global {
interface HTMLElementTagNameMap {
'consentsoftware-cookieconsent': ConsentsoftwareCookieconsent;
}
}
@customElement('consentsoftware-cookieconsent') @customElement('consentsoftware-cookieconsent')
export class ConsentsoftwareCookieconsent extends LitElement { export class ConsentsoftwareCookieconsent extends LitElement {
public static demo = () => html`<consentsoftware-cookieconsent></consentsoftware-cookieconsent>`; public static demo = () => html`<consentsoftware-cookieconsent></consentsoftware-cookieconsent>`;
@ -67,7 +73,7 @@ export class ConsentsoftwareCookieconsent extends LitElement {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 1000; /* standard z-index for fixed elements */ z-index: 1000; /* standard z-index for fixed elements */
background: rgba(0, 0, 0, 0); background: rgba(255, 255, 255, 0);
backdrop-filter: blur(0px); backdrop-filter: blur(0px);
transition: all 0.2s; transition: all 0.2s;
} }
@ -85,10 +91,6 @@ export class ConsentsoftwareCookieconsent extends LitElement {
min-width: calc(100vw / 3); min-width: calc(100vw / 3);
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: hidden;
/*
* We start with margin-bottom as negative to hide the banner.
* The animation occurs when we toggle the gotIt/show attributes.
*/
will-change: transform; /* ensure efficient rendering */ will-change: transform; /* ensure efficient rendering */
transition: all 0.3s; transition: all 0.3s;
transform: scale(0.95); transform: scale(0.95);
@ -106,18 +108,6 @@ export class ConsentsoftwareCookieconsent extends LitElement {
display: block; display: block;
} }
/*
* Animate margin-bottom when [gotIt] toggles.
* If gotIt=true, push the banner down off-screen.
* If gotIt=false, pull the banner into view.
*/
:host([gotIt='true']) {
background: blue;
}
:host([gotIt='false']) {
background: red;
}
.content { .content {
margin: auto; margin: auto;
} }
@ -168,7 +158,7 @@ export class ConsentsoftwareCookieconsent extends LitElement {
line-height: 30px; line-height: 30px;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
transition: background 0.2s; transition: all 0.2s;
} }
.consent-button:hover { .consent-button:hover {
@ -178,7 +168,6 @@ export class ConsentsoftwareCookieconsent extends LitElement {
constructor() { constructor() {
super(); super();
this.setAttribute('gotIt', 'true');
this.setAttribute('show', 'false'); this.setAttribute('show', 'false');
} }
@ -199,27 +188,29 @@ export class ConsentsoftwareCookieconsent extends LitElement {
<!-- <div class="button-container"> <!-- <div class="button-container">
<div <div
class="consent-button" class="consent-button"
@click=${(event: MouseEvent) => this.setLevel(event, ['functional'])} @click=${(event: MouseEvent) =>
this.handleConsentButtonClick(event, ['functional'])}
> >
Functional cookies Functional cookies
</div> </div>
<div <div
class="consent-button" class="consent-button"
@click=${(event: MouseEvent) => this.setLevel(event, ['functional', 'analytics'])} @click=${(event: MouseEvent) =>
this.handleConsentButtonClick(event, ['functional', 'analytics'])}
> >
Analytics cookies Analytics cookies
</div> </div>
<div <div
class="consent-button" class="consent-button"
@click=${(event: MouseEvent) => @click=${(event: MouseEvent) =>
this.setLevel(event, ['functional', 'analytics', 'marketing'])} this.handleConsentButtonClick(event, ['functional', 'analytics', 'marketing'])}
> >
Marketing cookies Marketing cookies
</div> </div>
<div <div
class="consent-button" class="consent-button"
@click=${(event: MouseEvent) => @click=${(event: MouseEvent) =>
this.setLevel(event, ['functional', 'analytics', 'marketing', 'all'])} this.handleConsentButtonClick(event, ['functional', 'analytics', 'marketing', 'all'])}
> >
All cookies All cookies
</div> </div>
@ -228,20 +219,22 @@ export class ConsentsoftwareCookieconsent extends LitElement {
<div class="button-container"> <div class="button-container">
<div <div
class="consent-button" class="consent-button"
@click=${(event: MouseEvent) => this.setLevel(event, ['functional'])} @click=${(event: MouseEvent) =>
this.handleConsentButtonClick(event, ['functional'])}
> >
Deny Deny
</div> </div>
<div <div
class="consent-button" class="consent-button"
@click=${(event: MouseEvent) => this.setLevel(event, ['functional', 'analytics'])} @click=${(event: MouseEvent) =>
this.handleConsentButtonClick(event, ['functional', 'analytics'])}
> >
Accept selection Accept selection
</div> </div>
<div <div
class="consent-button" class="consent-button"
@click=${(event: MouseEvent) => @click=${(event: MouseEvent) =>
this.setLevel(event, ['functional', 'analytics', 'marketing'])} this.handleConsentButtonClick(event, ['functional', 'analytics', 'marketing'])}
> >
Accept all cookies Accept all cookies
</div> </div>
@ -249,6 +242,7 @@ export class ConsentsoftwareCookieconsent extends LitElement {
<div class="info-container"> <div class="info-container">
consent management powered by consent management powered by
<a href="https://consent.software">consent.software</a> <a href="https://consent.software">consent.software</a>
(Open Source)
</div> </div>
</div> </div>
</div> </div>
@ -266,13 +260,12 @@ export class ConsentsoftwareCookieconsent extends LitElement {
const cookieLevel = await this.csWebclientInstance.getCookieLevels(); const cookieLevel = await this.csWebclientInstance.getCookieLevels();
if (!cookieLevel) { if (!cookieLevel) {
this.setAttribute('show', 'true'); this.setAttribute('show', 'true');
this.setAttribute('gotIt', 'false');
requestAnimationFrame(async () => { requestAnimationFrame(async () => {
await this.updated(); await this.updated();
const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay'); const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay');
if (pageOverlay) { if (pageOverlay) {
pageOverlay.style.background = 'rgba(0, 0, 0, 0.1)'; pageOverlay.style.background = 'rgba(255,255,255, 0.1)';
pageOverlay.style.backdropFilter = 'blur(2px)'; pageOverlay.style.backdropFilter = 'blur(1px)';
} }
const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox'); const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox');
if (modalBox) { if (modalBox) {
@ -282,7 +275,6 @@ export class ConsentsoftwareCookieconsent extends LitElement {
}); });
} else { } else {
this.setAttribute('show', 'false'); this.setAttribute('show', 'false');
this.setAttribute('gotIt', 'true');
} }
} }
@ -307,10 +299,22 @@ export class ConsentsoftwareCookieconsent extends LitElement {
/** /**
* Sets the users chosen cookie level(s) and hides the banner. * Sets the users chosen cookie level(s) and hides the banner.
*/ */
private async setLevel(event: MouseEvent, levelsArg: csInterfaces.TCookieLevel[]) { private async handleConsentButtonClick(
event: MouseEvent,
levelsArg: csInterfaces.TCookieLevel[]
) {
console.log(`Set level to ${levelsArg}`); console.log(`Set level to ${levelsArg}`);
const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay');
if (pageOverlay) {
pageOverlay.style.background = 'rgba(255,255,255, 0)';
pageOverlay.style.backdropFilter = 'blur(0px)';
}
const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox');
if (modalBox) {
modalBox.style.transform = `scale(0.95)`;
modalBox.style.opacity = '0';
}
await this.csWebclientInstance.setCookieLevels(levelsArg); await this.csWebclientInstance.setCookieLevels(levelsArg);
this.setAttribute('gotIt', 'true');
await delayFor(300); await delayFor(300);
this.setAttribute('show', 'false'); this.setAttribute('show', 'false');
// After user selection, re-check for any required scripts to run // After user selection, re-check for any required scripts to run

View File

@ -6,10 +6,10 @@ import { delayFor } from '@push.rocks/smartdelay';
@customElement('consentsoftware-toggle') @customElement('consentsoftware-toggle')
export class ConsentsoftwareToggle extends LitElement { export class ConsentsoftwareToggle extends LitElement {
@property({ type: Boolean }) @property({ type: Boolean })
public required = false; public accessor required = false;
@property({ type: Boolean, reflect: true }) @property({ type: Boolean, reflect: true })
public selected = false; public accessor selected = false;
/** /**
* We always track the knobs left offset in `currentX`. * We always track the knobs left offset in `currentX`.