@consent.software/catalog 1.5.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_bundle/bundle.js +79 -66
- package/dist_bundle/bundle.js.map +2 -2
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/elements/consentsoftware-cookieconsent.d.ts +14 -11
- package/dist_ts_web/elements/consentsoftware-cookieconsent.js +95 -74
- package/dist_ts_web/elements/consentsoftware-tabs.js +9 -2
- package/dist_watch/bundle.js +85 -69
- package/dist_watch/bundle.js.map +2 -2
- package/package.json +1 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/elements/consentsoftware-cookieconsent.ts +95 -77
- package/ts_web/elements/consentsoftware-tabs.ts +9 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@consent.software/catalog",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.",
|
|
6
6
|
"exports": {
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@consent.software/catalog',
|
|
6
|
-
version: '1.
|
|
6
|
+
version: '1.6.0',
|
|
7
7
|
description: 'A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.'
|
|
8
8
|
}
|
|
@@ -21,18 +21,20 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
21
21
|
public csWebclientInstance = new csWebclient.CsWebclient();
|
|
22
22
|
public csWebclientRan = false;
|
|
23
23
|
|
|
24
|
+
// Reflects the current theme ('light' or 'dark')
|
|
24
25
|
@property({ type: String, reflect: true })
|
|
25
26
|
public theme: 'light' | 'dark' = 'light';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
29
|
+
* Define component styles with CSS variables that adjust based on theme.
|
|
30
|
+
* The default variables serve as baseline for the light theme.
|
|
31
|
+
* Theme-specific overrides modify these for dark mode.
|
|
30
32
|
*/
|
|
31
33
|
public static styles = css`
|
|
32
34
|
:host {
|
|
33
35
|
font-family: ${shared.fontStack};
|
|
34
36
|
user-select: none;
|
|
35
|
-
/* Default
|
|
37
|
+
/* Default variables for Light Theme */
|
|
36
38
|
--text-color: #333;
|
|
37
39
|
--background-color: #eeeeee;
|
|
38
40
|
--accent-color: #333333;
|
|
@@ -41,8 +43,14 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
41
43
|
--icon-color: #4496f5;
|
|
42
44
|
--link-color: #333;
|
|
43
45
|
--padding-sides: 16px;
|
|
46
|
+
/* Additional variables for modal and info container styling */
|
|
47
|
+
--info-bg: rgba(0, 0, 0, 0.1);
|
|
48
|
+
--info-text: rgba(255, 255, 255, 0.5);
|
|
49
|
+
--modal-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2);
|
|
44
50
|
}
|
|
45
51
|
|
|
52
|
+
/* Dark Theme Overrides:
|
|
53
|
+
When theme attribute is 'dark', override variables accordingly. */
|
|
46
54
|
:host([theme='dark']) {
|
|
47
55
|
--text-color: #fff;
|
|
48
56
|
--background-color: #111;
|
|
@@ -51,8 +59,14 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
51
59
|
--button-hover-bg: #222222;
|
|
52
60
|
--icon-color: #4496f5;
|
|
53
61
|
--link-color: #fff;
|
|
62
|
+
--info-bg: rgba(0, 0, 0, 0.1);
|
|
63
|
+
--info-text: rgba(255, 255, 255, 0.5);
|
|
64
|
+
--modal-box-shadow: 0px 0px 8px rgba(255, 255, 255, 0.6);
|
|
54
65
|
}
|
|
55
66
|
|
|
67
|
+
/* Light Theme Overrides:
|
|
68
|
+
Explicit light theme settings, currently matching defaults.
|
|
69
|
+
Can be customized independently if desired. */
|
|
56
70
|
:host([theme='light']) {
|
|
57
71
|
--text-color: #333;
|
|
58
72
|
--background-color: #eeeeee;
|
|
@@ -61,33 +75,39 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
61
75
|
--button-hover-bg: #f2f2f2;
|
|
62
76
|
--icon-color: #4496f5;
|
|
63
77
|
--link-color: #333;
|
|
78
|
+
--info-bg: rgba(0, 0, 0, 0.1);
|
|
79
|
+
--info-text: rgba(0, 0, 0, 0.5);
|
|
80
|
+
--modal-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2);
|
|
64
81
|
}
|
|
65
82
|
|
|
83
|
+
/* Overlay covering the page behind the modal */
|
|
66
84
|
.pageOverlay {
|
|
67
85
|
position: fixed;
|
|
68
|
-
top:
|
|
69
|
-
bottom:
|
|
70
|
-
right:
|
|
71
|
-
left:
|
|
86
|
+
top: 0;
|
|
87
|
+
bottom: 0;
|
|
88
|
+
right: 0;
|
|
89
|
+
left: 0;
|
|
72
90
|
display: grid;
|
|
73
91
|
align-items: center;
|
|
74
92
|
justify-content: center;
|
|
75
|
-
z-index: 1000; /*
|
|
93
|
+
z-index: 1000; /* Ensures the overlay is on top of other elements */
|
|
76
94
|
background: rgba(255, 255, 255, 0);
|
|
77
95
|
backdrop-filter: blur(0px);
|
|
78
96
|
transition: all 0.2s;
|
|
79
97
|
}
|
|
80
98
|
|
|
99
|
+
/* Shake animation for overlay when clicked */
|
|
81
100
|
.pageOverlay.shake {
|
|
82
101
|
background: rgba(0, 0, 0, 0.5) !important;
|
|
83
102
|
}
|
|
84
103
|
|
|
104
|
+
/* Modal box styling using theme variables for colors and shadows */
|
|
85
105
|
.modalBox {
|
|
86
106
|
display: block;
|
|
87
107
|
color: var(--text-color);
|
|
88
108
|
background: var(--background-color);
|
|
89
|
-
box-shadow:
|
|
90
|
-
position:
|
|
109
|
+
box-shadow: var(--modal-box-shadow);
|
|
110
|
+
position: relative;
|
|
91
111
|
border: 1px dotted rgba(255, 255, 255, 0.1);
|
|
92
112
|
border-top: 1px solid var(--accent-color);
|
|
93
113
|
border-radius: 16px;
|
|
@@ -95,12 +115,22 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
95
115
|
min-width: calc(100vw / 3);
|
|
96
116
|
box-sizing: border-box;
|
|
97
117
|
overflow: hidden;
|
|
98
|
-
will-change: transform;
|
|
118
|
+
will-change: transform;
|
|
99
119
|
transition: all 0.3s;
|
|
100
120
|
transform: scale(0.95);
|
|
101
121
|
opacity: 0;
|
|
102
122
|
}
|
|
103
123
|
|
|
124
|
+
/* Media query for mobile devices: stack buttons vertically */
|
|
125
|
+
@media (max-width: 600px) {
|
|
126
|
+
.modalBox {
|
|
127
|
+
height: 100vh;
|
|
128
|
+
box-shadow: none;
|
|
129
|
+
border-radius: 0px;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Shake animation for modal box */
|
|
104
134
|
.modalBox.shake {
|
|
105
135
|
animation: shake 150ms 2 linear;
|
|
106
136
|
}
|
|
@@ -117,10 +147,7 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
117
147
|
}
|
|
118
148
|
}
|
|
119
149
|
|
|
120
|
-
/*
|
|
121
|
-
* Toggle display based on [show] attribute
|
|
122
|
-
* (so if show=false, the banner doesn't show at all).
|
|
123
|
-
*/
|
|
150
|
+
/* Toggle display based on [show] attribute */
|
|
124
151
|
:host([show='false']) {
|
|
125
152
|
display: none;
|
|
126
153
|
}
|
|
@@ -151,25 +178,14 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
151
178
|
gap: 16px;
|
|
152
179
|
}
|
|
153
180
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
border-top: 1px dotted rgba(255, 255, 255, 0.1);
|
|
160
|
-
font-size: 0.8em;
|
|
161
|
-
color: rgba(255, 255, 255, 0.5);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.info-container a {
|
|
165
|
-
text-decoration: underline;
|
|
166
|
-
color: var(--link-color);
|
|
167
|
-
transition: color 0.2s;
|
|
168
|
-
}
|
|
169
|
-
.info-container a:hover {
|
|
170
|
-
color: #ffffff;
|
|
181
|
+
/* Media query for mobile devices: stack buttons vertically */
|
|
182
|
+
@media (max-width: 600px) {
|
|
183
|
+
.button-container {
|
|
184
|
+
grid-template-columns: 1fr;
|
|
185
|
+
}
|
|
171
186
|
}
|
|
172
187
|
|
|
188
|
+
/* Consent button styling using theme variables */
|
|
173
189
|
.consent-button {
|
|
174
190
|
border-radius: 3px;
|
|
175
191
|
background: var(--button-bg);
|
|
@@ -184,10 +200,30 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
184
200
|
.consent-button:hover {
|
|
185
201
|
background: var(--button-hover-bg);
|
|
186
202
|
}
|
|
203
|
+
|
|
204
|
+
/* Use theme variables for info container background and text */
|
|
205
|
+
.info-container {
|
|
206
|
+
text-align: center;
|
|
207
|
+
line-height: 3em;
|
|
208
|
+
background: var(--info-bg);
|
|
209
|
+
border-top: 1px dotted rgba(255, 255, 255, 0.1);
|
|
210
|
+
font-size: 0.8em;
|
|
211
|
+
color: var(--info-text);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.info-container a {
|
|
215
|
+
text-decoration: underline;
|
|
216
|
+
color: var(--link-color);
|
|
217
|
+
transition: color 0.2s;
|
|
218
|
+
}
|
|
219
|
+
.info-container a:hover {
|
|
220
|
+
color: #ffffff;
|
|
221
|
+
}
|
|
187
222
|
`;
|
|
188
223
|
|
|
189
224
|
constructor() {
|
|
190
225
|
super();
|
|
226
|
+
// Initially hide the consent banner until needed
|
|
191
227
|
this.setAttribute('show', 'false');
|
|
192
228
|
}
|
|
193
229
|
|
|
@@ -205,36 +241,6 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
205
241
|
and choose which cookie level you are willing to accept.
|
|
206
242
|
</div>
|
|
207
243
|
</div>
|
|
208
|
-
<!-- <div class="button-container">
|
|
209
|
-
<div
|
|
210
|
-
class="consent-button"
|
|
211
|
-
@click=${(event: MouseEvent) =>
|
|
212
|
-
this.handleConsentButtonClick(event, ['functional'])}
|
|
213
|
-
>
|
|
214
|
-
Functional cookies
|
|
215
|
-
</div>
|
|
216
|
-
<div
|
|
217
|
-
class="consent-button"
|
|
218
|
-
@click=${(event: MouseEvent) =>
|
|
219
|
-
this.handleConsentButtonClick(event, ['functional', 'analytics'])}
|
|
220
|
-
>
|
|
221
|
-
Analytics cookies
|
|
222
|
-
</div>
|
|
223
|
-
<div
|
|
224
|
-
class="consent-button"
|
|
225
|
-
@click=${(event: MouseEvent) =>
|
|
226
|
-
this.handleConsentButtonClick(event, ['functional', 'analytics', 'marketing'])}
|
|
227
|
-
>
|
|
228
|
-
Marketing cookies
|
|
229
|
-
</div>
|
|
230
|
-
<div
|
|
231
|
-
class="consent-button"
|
|
232
|
-
@click=${(event: MouseEvent) =>
|
|
233
|
-
this.handleConsentButtonClick(event, ['functional', 'analytics', 'marketing', 'all'])}
|
|
234
|
-
>
|
|
235
|
-
All cookies
|
|
236
|
-
</div>
|
|
237
|
-
</div> -->
|
|
238
244
|
<consentsoftware-mainselection></consentsoftware-mainselection>
|
|
239
245
|
<div class="button-container">
|
|
240
246
|
<div
|
|
@@ -262,7 +268,6 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
262
268
|
<div class="info-container">
|
|
263
269
|
consent management powered by
|
|
264
270
|
<a href="https://consent.software">consent.software</a>
|
|
265
|
-
(Open Source)
|
|
266
271
|
</div>
|
|
267
272
|
</div>
|
|
268
273
|
</div>
|
|
@@ -271,41 +276,44 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
271
276
|
}
|
|
272
277
|
|
|
273
278
|
/**
|
|
274
|
-
*
|
|
279
|
+
* Lifecycle method called when the element is connected to the DOM.
|
|
280
|
+
* It sets up the theme and displays the consent banner if no cookie levels are set.
|
|
275
281
|
*/
|
|
276
282
|
public async connectedCallback() {
|
|
277
283
|
super.connectedCallback();
|
|
278
|
-
this.updateTheme();
|
|
284
|
+
this.updateTheme(); // Initialize theme based on system preference
|
|
279
285
|
|
|
280
286
|
const cookieLevel = await this.csWebclientInstance.getCookieLevels();
|
|
281
287
|
if (!cookieLevel) {
|
|
288
|
+
// Show consent banner if cookie levels haven't been set yet
|
|
282
289
|
this.setAttribute('show', 'true');
|
|
283
290
|
requestAnimationFrame(async () => {
|
|
284
291
|
await this.updated();
|
|
285
292
|
const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay');
|
|
286
293
|
if (pageOverlay) {
|
|
294
|
+
// Apply dark overlay styling when modal appears
|
|
287
295
|
pageOverlay.style.background = 'rgba(0,0,0, 0.5)';
|
|
288
296
|
pageOverlay.style.backdropFilter = 'blur(20px)';
|
|
289
297
|
}
|
|
290
298
|
const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox');
|
|
291
299
|
if (modalBox) {
|
|
300
|
+
// Animate modal box appearance
|
|
292
301
|
modalBox.style.transform = `scale(1)`;
|
|
293
302
|
modalBox.style.opacity = '1';
|
|
294
303
|
}
|
|
295
304
|
});
|
|
296
305
|
} else {
|
|
306
|
+
// Hide banner if cookie levels are already set
|
|
297
307
|
this.setAttribute('show', 'false');
|
|
298
308
|
}
|
|
299
309
|
}
|
|
300
310
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
*/
|
|
305
|
-
public async firstUpdated() {}
|
|
311
|
+
public async firstUpdated() {
|
|
312
|
+
// Placeholder for any logic needed after first render
|
|
313
|
+
}
|
|
306
314
|
|
|
307
315
|
/**
|
|
308
|
-
* Called
|
|
316
|
+
* Called after updates. Logs banner height and runs consent scripts if necessary.
|
|
309
317
|
*/
|
|
310
318
|
public async updated() {
|
|
311
319
|
console.log(`The height of the cookie banner is ${this.shadowRoot?.host?.clientHeight}px`);
|
|
@@ -317,7 +325,8 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
317
325
|
}
|
|
318
326
|
|
|
319
327
|
/**
|
|
320
|
-
*
|
|
328
|
+
* Handles consent button clicks, sets cookie levels, and hides the banner.
|
|
329
|
+
* Uses theme variables for styling transitions.
|
|
321
330
|
*/
|
|
322
331
|
private async handleConsentButtonClick(
|
|
323
332
|
event: MouseEvent,
|
|
@@ -326,21 +335,27 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
326
335
|
console.log(`Set level to ${levelsArg}`);
|
|
327
336
|
const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay');
|
|
328
337
|
if (pageOverlay) {
|
|
338
|
+
// Fade out overlay effect using inline styles for transition
|
|
329
339
|
pageOverlay.style.background = 'rgba(255,255,255, 0)';
|
|
330
340
|
pageOverlay.style.backdropFilter = 'blur(0px)';
|
|
331
341
|
}
|
|
332
342
|
const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox');
|
|
333
343
|
if (modalBox) {
|
|
344
|
+
// Scale down and fade out modal box before hiding
|
|
334
345
|
modalBox.style.transform = `scale(0.95)`;
|
|
335
346
|
modalBox.style.opacity = '0';
|
|
336
347
|
}
|
|
348
|
+
// Save user consent preferences
|
|
337
349
|
await this.csWebclientInstance.setCookieLevels(levelsArg);
|
|
338
350
|
await delayFor(300);
|
|
339
|
-
this.setAttribute('show', 'false');
|
|
340
|
-
//
|
|
341
|
-
this.updated();
|
|
351
|
+
this.setAttribute('show', 'false'); // Hide the consent banner
|
|
352
|
+
this.updated(); // Trigger any post-consent actions
|
|
342
353
|
}
|
|
343
354
|
|
|
355
|
+
/**
|
|
356
|
+
* Handles clicks on the page overlay. If clicked outside the modal,
|
|
357
|
+
* triggers a shake animation as feedback.
|
|
358
|
+
*/
|
|
344
359
|
private async pageOverlayClick(e: MouseEvent) {
|
|
345
360
|
if (e.target === e.currentTarget) {
|
|
346
361
|
const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay');
|
|
@@ -356,12 +371,15 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|
|
356
371
|
}
|
|
357
372
|
|
|
358
373
|
/**
|
|
359
|
-
* Dynamically switches the theme between light
|
|
360
|
-
*
|
|
374
|
+
* Dynamically switches the theme between light and dark.
|
|
375
|
+
* Listens for system theme changes to update the component's theme.
|
|
361
376
|
*/
|
|
362
377
|
private updateTheme() {
|
|
378
|
+
// Check the initial system preference for dark mode
|
|
363
379
|
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
364
380
|
this.theme = prefersDark ? 'dark' : 'light';
|
|
381
|
+
|
|
382
|
+
// Listen for changes in the system color scheme preference
|
|
365
383
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
|
|
366
384
|
this.theme = e.matches ? 'dark' : 'light';
|
|
367
385
|
});
|
|
@@ -24,6 +24,13 @@ export class ConsentsoftwareTabs extends LitElement {
|
|
|
24
24
|
cursor: pointer;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/* Media query for mobile devices: stack buttons vertically */
|
|
28
|
+
@media (max-width: 600px) {
|
|
29
|
+
.tabs .tab {
|
|
30
|
+
font-size: 0.8em;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
.selector {
|
|
28
35
|
position: absolute;
|
|
29
36
|
width: calc(100% / 3);
|
|
@@ -44,7 +51,7 @@ export class ConsentsoftwareTabs extends LitElement {
|
|
|
44
51
|
<div class="tabs">
|
|
45
52
|
<div class="tab" @click=${this.handleClick}>Consent</div>
|
|
46
53
|
<div class="tab" @click=${this.handleClick}>Details</div>
|
|
47
|
-
<div class="tab" @click=${this.handleClick}>Cookie Policy
|
|
54
|
+
<div class="tab" @click=${this.handleClick}>Cookie Policy</div>
|
|
48
55
|
</div>
|
|
49
56
|
<div class="selector"></div>
|
|
50
57
|
`;
|
|
@@ -61,4 +68,4 @@ export class ConsentsoftwareTabs extends LitElement {
|
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
|
-
}
|
|
71
|
+
}
|