14 Commits

6 changed files with 121 additions and 50 deletions

View File

@ -1,5 +1,49 @@
# Changelog
## 2025-01-21 - 1.5.4 - fix(consentsoftware-components)
Add interactive consent software components for managing cookie levels.
- Implemented 'consentsoftware-cookieconsent' component for cookie management
- Introduced 'consentsoftware-toggle' for user interaction improvements
- Added theme support for light/dark modes in consent components
- Enhanced consent interface with responsive design and accessibility features
## 2025-01-20 - 1.5.3 - fix(consentsoftware-cookieconsent)
Fix visual inconsistencies in the consent software modal overlay and shadow.
- Updated the shadow color in the modal box to use a consistent color.
- Restored backdrop blur effect in the page overlay when visible.
## 2025-01-20 - 1.5.2 - fix(core)
No changes detected
## 2025-01-20 - 1.5.1 - fix(consentsoftware-cookieconsent)
Adjusted shake animation duration and box-shadow for modalBox in consent cookie component.
- Changed the box-shadow to be softer with reduced spread for more subtle visual effect.
- Increased the duration of shake animation from 300ms to 2000ms for enhanced user feedback upon overlay interaction.
## 2025-01-20 - 1.5.0 - feat(consentsoftware-cookieconsent)
Enhance consent modal with shake animation on overlay click
- Added shake animation to the modal and overlay when clicked outside the modal.
- Updated dependency @consent.software/interfaces to version ^1.0.14.
## 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.

View File

@ -1,6 +1,6 @@
{
"name": "@consent.software/catalog",
"version": "1.4.3",
"version": "1.5.4",
"private": false,
"description": "A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.",
"exports": {
@ -15,7 +15,7 @@
"author": "Lossless GmbH",
"license": "MIT",
"dependencies": {
"@consent.software/interfaces": "^1.0.11",
"@consent.software/interfaces": "^1.0.14",
"@consent.software/webclient": "^1.1.0",
"@push.rocks/smartdelay": "^3.0.5",
"lit": "^3.2.1"

19
pnpm-lock.yaml generated
View File

@ -9,8 +9,8 @@ importers:
.:
dependencies:
'@consent.software/interfaces':
specifier: ^1.0.11
version: 1.0.13
specifier: ^1.0.14
version: 1.0.14
'@consent.software/webclient':
specifier: ^1.1.0
version: 1.1.0
@ -42,9 +42,6 @@ packages:
'@api.global/typedrequest-interfaces@2.0.2':
resolution: {integrity: sha512-D+mkr4IiUZ/eUgrdp5jXjBKOW/iuMcl0z2ZLQsLLypKX/psFGD3viZJ58FNRa+/1OSM38JS5wFyoWl8oPEFLrw==}
'@api.global/typedrequest-interfaces@3.0.1':
resolution: {integrity: sha512-eR2Cr01BYRwIq/X2ajOenWhm8l+/YE4A5kK/9V6I8ZnhtEBMFHG6YjF6Fg8npLJWbvhZXhOms+axZ6JKI71o8g==}
'@api.global/typedrequest-interfaces@3.0.19':
resolution: {integrity: sha512-uuHUXJeOy/inWSDrwD0Cwax2rovpxYllDhM2RWh+6mVpQuNmZ3uw6IVg6dA2G1rOe24Ebs+Y9SzEogo+jYN7vw==}
@ -227,8 +224,8 @@ packages:
'@cloudflare/workers-types@4.20241230.0':
resolution: {integrity: sha512-dtLD4jY35Lb750cCVyO1i/eIfdZJg2Z0i+B1RYX6BVeRPlgaHx/H18ImKAkYmy0g09Ow8R2jZy3hIxMgXun0WQ==}
'@consent.software/interfaces@1.0.13':
resolution: {integrity: sha512-xB1h5n5vltRLBrvQhrKz4K6tz+TN5RHHvcbQbTIphxetiWOJJq/RwyEN2iH8TtwWIGBSqHRtoljBQqY8t8Oanw==}
'@consent.software/interfaces@1.0.14':
resolution: {integrity: sha512-xfOhDuj4ECEMyutJCSwEOX1SPN/MlReR40D/x7CsKg1mSauoq0pZbZEUb9m4z5EoPfywZl8gkLVzFoiGyg1IcA==}
'@consent.software/webclient@1.1.0':
resolution: {integrity: sha512-VX7e8ygZwgU8WEzn22fdvvEytLYl4kfp/u40GusaBU4iFtjrCY2hxDy9Z1FTKicpGcRxf3t13lM0Jaugq7Jj/w==}
@ -2981,8 +2978,6 @@ snapshots:
'@api.global/typedrequest-interfaces@2.0.2': {}
'@api.global/typedrequest-interfaces@3.0.1': {}
'@api.global/typedrequest-interfaces@3.0.19': {}
'@api.global/typedrequest@3.1.10':
@ -3569,14 +3564,14 @@ snapshots:
'@cloudflare/workers-types@4.20241230.0': {}
'@consent.software/interfaces@1.0.13':
'@consent.software/interfaces@1.0.14':
dependencies:
'@api.global/typedrequest-interfaces': 3.0.1
'@api.global/typedrequest-interfaces': 3.0.19
'@consent.software/webclient@1.1.0':
dependencies:
'@api.global/typedrequest': 3.1.10
'@consent.software/interfaces': 1.0.13
'@consent.software/interfaces': 1.0.14
'@push.rocks/smarttime': 4.1.1
'@push.rocks/webstore': 2.0.20

View File

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

View File

@ -73,16 +73,20 @@ export class ConsentsoftwareCookieconsent extends LitElement {
align-items: center;
justify-content: center;
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);
transition: all 0.2s;
}
.pageOverlay.shake {
background: rgba(0, 0, 0, 0.5) !important;
}
.modalBox {
display: block;
color: var(--text-color);
background: var(--background-color);
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.6);
box-shadow: 0px 0px 8px rgba(255, 255, 255, 0.6);
position: realtive;
border: 1px dotted rgba(255, 255, 255, 0.1);
border-top: 1px solid var(--accent-color);
@ -91,16 +95,28 @@ export class ConsentsoftwareCookieconsent extends LitElement {
min-width: calc(100vw / 3);
box-sizing: border-box;
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 */
transition: all 0.3s;
transform: scale(0.95);
opacity: 0;
}
.modalBox.shake {
animation: shake 150ms 2 linear;
}
@keyframes shake {
0% {
transform: translate(3px, 0);
}
50% {
transform: translate(-3px, 0);
}
100% {
transform: translate(0, 0);
}
}
/*
* Toggle display based on [show] attribute
* (so if show=false, the banner doesn't show at all).
@ -112,18 +128,6 @@ export class ConsentsoftwareCookieconsent extends LitElement {
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 {
margin: auto;
}
@ -184,13 +188,12 @@ export class ConsentsoftwareCookieconsent extends LitElement {
constructor() {
super();
this.setAttribute('gotIt', 'true');
this.setAttribute('show', 'false');
}
public render(): TemplateResult {
return html`
<div class="pageOverlay">
<div class="pageOverlay" @click=${this.pageOverlayClick}>
<div class="modalBox">
<div class="content">
<consentsoftware-header></consentsoftware-header>
@ -205,27 +208,29 @@ export class ConsentsoftwareCookieconsent extends LitElement {
<!-- <div class="button-container">
<div
class="consent-button"
@click=${(event: MouseEvent) => this.setLevel(event, ['functional'])}
@click=${(event: MouseEvent) =>
this.handleConsentButtonClick(event, ['functional'])}
>
Functional cookies
</div>
<div
class="consent-button"
@click=${(event: MouseEvent) => this.setLevel(event, ['functional', 'analytics'])}
@click=${(event: MouseEvent) =>
this.handleConsentButtonClick(event, ['functional', 'analytics'])}
>
Analytics cookies
</div>
<div
class="consent-button"
@click=${(event: MouseEvent) =>
this.setLevel(event, ['functional', 'analytics', 'marketing'])}
this.handleConsentButtonClick(event, ['functional', 'analytics', 'marketing'])}
>
Marketing cookies
</div>
<div
class="consent-button"
@click=${(event: MouseEvent) =>
this.setLevel(event, ['functional', 'analytics', 'marketing', 'all'])}
this.handleConsentButtonClick(event, ['functional', 'analytics', 'marketing', 'all'])}
>
All cookies
</div>
@ -234,20 +239,22 @@ export class ConsentsoftwareCookieconsent extends LitElement {
<div class="button-container">
<div
class="consent-button"
@click=${(event: MouseEvent) => this.setLevel(event, ['functional'])}
@click=${(event: MouseEvent) =>
this.handleConsentButtonClick(event, ['functional'])}
>
Deny
</div>
<div
class="consent-button"
@click=${(event: MouseEvent) => this.setLevel(event, ['functional', 'analytics'])}
@click=${(event: MouseEvent) =>
this.handleConsentButtonClick(event, ['functional', 'analytics'])}
>
Accept selection
</div>
<div
class="consent-button"
@click=${(event: MouseEvent) =>
this.setLevel(event, ['functional', 'analytics', 'marketing'])}
this.handleConsentButtonClick(event, ['functional', 'analytics', 'marketing'])}
>
Accept all cookies
</div>
@ -255,6 +262,7 @@ export class ConsentsoftwareCookieconsent extends LitElement {
<div class="info-container">
consent management powered by
<a href="https://consent.software">consent.software</a>
(Open Source)
</div>
</div>
</div>
@ -272,13 +280,12 @@ export class ConsentsoftwareCookieconsent extends LitElement {
const cookieLevel = await this.csWebclientInstance.getCookieLevels();
if (!cookieLevel) {
this.setAttribute('show', 'true');
this.setAttribute('gotIt', 'false');
requestAnimationFrame(async () => {
await this.updated();
const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay');
if (pageOverlay) {
pageOverlay.style.background = 'rgba(0, 0, 0, 0.1)';
pageOverlay.style.backdropFilter = 'blur(2px)';
pageOverlay.style.background = 'rgba(0,0,0, 0.5)';
pageOverlay.style.backdropFilter = 'blur(20px)';
}
const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox');
if (modalBox) {
@ -288,7 +295,6 @@ export class ConsentsoftwareCookieconsent extends LitElement {
});
} else {
this.setAttribute('show', 'false');
this.setAttribute('gotIt', 'true');
}
}
@ -313,16 +319,42 @@ export class ConsentsoftwareCookieconsent extends LitElement {
/**
* 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}`);
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);
this.setAttribute('gotIt', 'true');
await delayFor(300);
this.setAttribute('show', 'false');
// After user selection, re-check for any required scripts to run
this.updated();
}
private async pageOverlayClick(e: MouseEvent) {
if (e.target === e.currentTarget) {
const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay');
const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox');
if (pageOverlay && modalBox) {
pageOverlay.classList.add('shake');
modalBox.classList.add('shake');
await delayFor(2000);
pageOverlay.classList.remove('shake');
modalBox.classList.remove('shake');
}
}
}
/**
* Dynamically switches the theme between light/dark,
* respecting `prefers-color-scheme` by default.

View File

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