@groundbrick/sveltekit-adapter 0.7.0 → 0.8.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.
@@ -142,74 +142,61 @@
142
142
 
143
143
  {#if showBanner && currentConfig}
144
144
  <div class="cookie-consent-overlay">
145
- <div class={getBannerClasses()}>
145
+ <div class={getBannerClasses()} role="dialog" aria-label={currentConfig.banner.title}>
146
146
  {#if !showPreferences}
147
- <!-- Basic Banner -->
148
- <div class="consent-content">
149
- <div class="consent-header">
150
- <h3 class="consent-title">{currentConfig.banner.title}</h3>
151
- <p class="consent-message">{currentConfig.banner.message}</p>
152
- </div>
153
-
154
- <div class="consent-actions">
155
- <button type="button" class="btn btn-secondary" onclick={togglePreferences}>
156
- {currentConfig.banner.customizeText}
157
- </button>
158
- <button type="button" class="btn btn-outline" onclick={rejectAll}>
159
- {currentConfig.banner.rejectAllText}
160
- </button>
161
- <button type="button" class="btn btn-primary" onclick={acceptAll}>
162
- {currentConfig.banner.acceptAllText}
163
- </button>
164
- </div>
147
+ <p class="consent-message">
148
+ {currentConfig.banner.message}
149
+ {#if currentConfig.banner.policyUrl}
150
+ <a href={currentConfig.banner.policyUrl}>{currentConfig.banner.policyLinkText}</a>
151
+ {/if}
152
+ </p>
153
+
154
+ <div class="consent-actions">
155
+ <button type="button" class="cc-btn-link" onclick={togglePreferences}>
156
+ {currentConfig.banner.customizeText}
157
+ </button>
158
+ <button type="button" class="cc-btn cc-btn-outline" onclick={rejectAll}>
159
+ {currentConfig.banner.rejectAllText}
160
+ </button>
161
+ <button type="button" class="cc-btn cc-btn-primary" onclick={acceptAll}>
162
+ {currentConfig.banner.acceptAllText}
163
+ </button>
165
164
  </div>
166
165
  {:else}
167
- <!-- Preferences Panel -->
168
- <div class="consent-preferences">
169
- <div class="preferences-header">
170
- <h3 class="consent-title">Cookie preferences</h3>
171
- <button type="button" class="btn-close" onclick={togglePreferences} aria-label="Close">
172
- ✕
173
- </button>
174
- </div>
175
-
176
- <div class="preferences-list">
177
- {#each Object.entries(currentConfig.categories) as [category, categoryConfig]}
178
- <div class="preference-item">
179
- <div class="preference-control">
180
- <div class="switch-container">
181
- <input
182
- type="checkbox"
183
- id="consent-{category}"
184
- class="switch-input"
185
- bind:checked={preferences[category]}
186
- disabled={categoryConfig.required}
187
- onchange={(e) => updatePreference(category, e.currentTarget.checked)}
188
- />
189
- <label for="consent-{category}" class="switch-label">
190
- <span class="switch-slider"></span>
191
- </label>
192
- </div>
193
- <div class="preference-info">
194
- <strong class="preference-name">{categoryConfig.name}</strong>
195
- {#if categoryConfig.required}
196
- <span class="required-badge">Requerido</span>
197
- {/if}
198
- </div>
199
- </div>
200
- <p class="preference-description">{categoryConfig.description}</p>
201
- </div>
202
- {/each}
203
- </div>
204
-
205
- <div class="preferences-actions">
206
- <button type="button" class="btn btn-outline" onclick={rejectAll}>
207
- {currentConfig.banner.rejectAllText}
208
- </button>
209
- <button type="button" class="btn btn-primary" onclick={savePreferences}>
210
- {currentConfig.banner.savePreferencesText}
211
- </button>
212
- </div>
166
+ <div class="preferences-header">
167
+ <strong class="consent-title">{currentConfig.banner.customizeText}</strong>
168
+ <button type="button" class="cc-btn-close" onclick={togglePreferences} aria-label={currentConfig.banner.closeText ?? 'Close'}>
169
+ ✕
170
+ </button>
171
+ </div>
172
+
173
+ <div class="preferences-list">
174
+ {#each Object.entries(currentConfig.categories) as [category, categoryConfig]}
175
+ <label class="preference-item" for="consent-{category}">
176
+ <span class="preference-info">
177
+ <strong class="preference-name">{categoryConfig.name}</strong>
178
+ <span class="preference-description">{categoryConfig.description}</span>
179
+ </span>
180
+ <input
181
+ type="checkbox"
182
+ role="switch"
183
+ id="consent-{category}"
184
+ class="switch-input"
185
+ bind:checked={preferences[category]}
186
+ disabled={categoryConfig.required}
187
+ onchange={(e) => updatePreference(category, e.currentTarget.checked)}
188
+ />
189
+ </label>
190
+ {/each}
191
+ </div>
192
+
193
+ <div class="consent-actions">
194
+ <button type="button" class="cc-btn cc-btn-outline" onclick={rejectAll}>
195
+ {currentConfig.banner.rejectAllText}
196
+ </button>
197
+ <button type="button" class="cc-btn cc-btn-primary" onclick={savePreferences}>
198
+ {currentConfig.banner.savePreferencesText}
199
+ </button>
213
200
  </div>
214
201
  {/if}
215
202
  </div>
@@ -217,34 +204,37 @@
217
204
  {/if}
218
205
 
219
206
  <style>
207
+ /* Discreet by design: a small card in the corner on desktop, a slim strip on mobile.
208
+ Accent follows the host app via --consent-accent. */
220
209
  .cookie-consent-overlay {
221
210
  position: fixed;
222
- top: 0;
223
- left: 0;
224
- right: 0;
225
- bottom: 0;
211
+ inset: 0;
226
212
  z-index: 9999;
227
213
  pointer-events: none;
228
214
  display: flex;
229
215
  align-items: flex-end;
230
- justify-content: center;
216
+ justify-content: flex-start;
217
+ padding: 16px;
231
218
  }
232
219
 
233
220
  .cookie-consent-banner {
221
+ --accent: var(--consent-accent, #3b82f6);
234
222
  background: white;
223
+ color: #1e293b;
224
+ border: 1px solid #e2e8f0;
235
225
  border-radius: 12px;
236
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
237
- margin: 20px;
238
- max-width: 600px;
226
+ box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
227
+ max-width: 400px;
239
228
  width: 100%;
229
+ padding: 14px 16px;
230
+ font-size: 13px;
231
+ line-height: 1.45;
240
232
  pointer-events: auto;
241
- animation: slideUp 0.3s ease-out;
242
- border: 1px solid #e2e8f0;
233
+ animation: slideUp 0.25s ease-out;
243
234
  }
244
235
 
245
236
  .cookie-consent-banner.position-top {
246
237
  align-self: flex-start;
247
- animation: slideDown 0.3s ease-out;
248
238
  }
249
239
 
250
240
  .cookie-consent-banner.theme-dark {
@@ -253,284 +243,200 @@
253
243
  border-color: #2d3748;
254
244
  }
255
245
 
256
- .cookie-consent-banner.show-preferences {
257
- max-width: 500px;
246
+ .consent-message {
247
+ margin: 0;
248
+ color: #475569;
258
249
  }
259
250
 
260
- .consent-content {
261
- padding: 24px;
251
+ .theme-dark .consent-message {
252
+ color: #a0aec0;
262
253
  }
263
254
 
264
- .consent-preferences {
265
- padding: 24px;
266
- max-height: 70vh;
267
- overflow-y: auto;
255
+ .consent-message a {
256
+ color: var(--accent);
257
+ white-space: nowrap;
258
+ }
259
+
260
+ .consent-actions {
261
+ display: flex;
262
+ align-items: center;
263
+ gap: 8px;
264
+ margin-top: 12px;
268
265
  }
269
266
 
270
- .consent-header {
271
- margin-bottom: 20px;
267
+ .consent-actions .cc-btn {
268
+ flex: 1;
272
269
  }
273
270
 
274
271
  .preferences-header {
275
272
  display: flex;
276
273
  justify-content: space-between;
277
274
  align-items: center;
278
- margin-bottom: 20px;
275
+ margin-bottom: 8px;
279
276
  }
280
277
 
281
278
  .consent-title {
282
- font-size: 18px;
283
- font-weight: 600;
284
- margin: 0 0 8px 0;
285
- color: inherit;
286
- }
287
-
288
- .consent-message {
289
279
  font-size: 14px;
290
- color: #64748b;
291
- margin: 0;
292
- line-height: 1.5;
293
- }
294
-
295
- .theme-dark .consent-message {
296
- color: #a0aec0;
297
- }
298
-
299
- .consent-actions {
300
- display: flex;
301
- gap: 12px;
302
- flex-wrap: wrap;
303
- justify-content: flex-end;
304
- margin-top: 20px;
305
- }
306
-
307
- .preferences-actions {
308
- display: flex;
309
- gap: 12px;
310
- justify-content: flex-end;
311
- margin-top: 24px;
312
- padding-top: 20px;
313
- border-top: 1px solid #e2e8f0;
314
- }
315
-
316
- .theme-dark .preferences-actions {
317
- border-top-color: #2d3748;
280
+ font-weight: 600;
318
281
  }
319
282
 
320
283
  .preferences-list {
321
284
  display: flex;
322
285
  flex-direction: column;
323
- gap: 20px;
286
+ max-height: 50vh;
287
+ overflow-y: auto;
324
288
  }
325
289
 
326
290
  .preference-item {
327
- padding: 16px;
328
- border: 1px solid #e2e8f0;
329
- border-radius: 8px;
330
- background: #f8fafc;
331
- }
332
-
333
- .theme-dark .preference-item {
334
- background: #2d3748;
335
- border-color: #4a5568;
336
- }
337
-
338
- .preference-control {
339
291
  display: flex;
340
292
  align-items: center;
341
293
  gap: 12px;
342
- margin-bottom: 8px;
294
+ padding: 8px 0;
295
+ border-top: 1px solid #e2e8f0;
296
+ cursor: pointer;
297
+ }
298
+
299
+ .theme-dark .preference-item {
300
+ border-top-color: #2d3748;
343
301
  }
344
302
 
345
303
  .preference-info {
346
304
  display: flex;
347
- align-items: center;
348
- gap: 8px;
305
+ flex-direction: column;
349
306
  flex: 1;
350
307
  }
351
308
 
352
309
  .preference-name {
353
310
  font-weight: 500;
354
- color: inherit;
355
- }
356
-
357
- .required-badge {
358
- background: #10b981;
359
- color: white;
360
- font-size: 10px;
361
- font-weight: 500;
362
- padding: 2px 6px;
363
- border-radius: 4px;
364
- text-transform: uppercase;
365
- letter-spacing: 0.5px;
366
311
  }
367
312
 
368
313
  .preference-description {
369
- font-size: 13px;
314
+ font-size: 12px;
370
315
  color: #64748b;
371
- margin: 0;
372
- line-height: 1.4;
373
316
  }
374
317
 
375
318
  .theme-dark .preference-description {
376
319
  color: #a0aec0;
377
320
  }
378
321
 
379
- /* Switch Styles */
380
- .switch-container {
381
- position: relative;
382
- display: flex;
383
- }
384
-
322
+ /* Native checkbox styled as a switch */
385
323
  .switch-input {
386
- opacity: 0;
387
- width: 0;
388
- height: 0;
389
- }
390
-
391
- .switch-label {
392
- display: inline-block;
393
- width: 44px;
394
- height: 24px;
324
+ appearance: none;
325
+ flex-shrink: 0;
326
+ width: 36px;
327
+ height: 20px;
328
+ margin: 0;
329
+ border-radius: 20px;
330
+ background: #cbd5e0;
331
+ position: relative;
395
332
  cursor: pointer;
333
+ transition: background 0.2s;
396
334
  }
397
335
 
398
- .switch-slider {
399
- position: absolute;
400
- top: 0;
401
- left: 0;
402
- right: 0;
403
- bottom: 0;
404
- background-color: #cbd5e0;
405
- border-radius: 24px;
406
- transition: 0.2s;
407
- height: 1.5rem;
408
- }
409
-
410
- .switch-slider:before {
411
- position: absolute;
336
+ .switch-input::before {
412
337
  content: "";
413
- height: 18px;
414
- width: 18px;
415
- left: 3px;
416
- bottom: 3px;
417
- background-color: white;
338
+ position: absolute;
339
+ top: 2px;
340
+ left: 2px;
341
+ width: 16px;
342
+ height: 16px;
418
343
  border-radius: 50%;
419
- transition: 0.2s;
344
+ background: white;
345
+ transition: transform 0.2s;
420
346
  }
421
347
 
422
- .switch-input:checked + .switch-label .switch-slider {
423
- background-color: #3b82f6;
348
+ .switch-input:checked {
349
+ background: var(--accent);
424
350
  }
425
351
 
426
- .switch-input:checked + .switch-label .switch-slider:before {
427
- transform: translateX(20px);
352
+ .switch-input:checked::before {
353
+ transform: translateX(16px);
428
354
  }
429
355
 
430
- .switch-input:disabled + .switch-label {
356
+ .switch-input:disabled {
431
357
  opacity: 0.6;
432
358
  cursor: not-allowed;
433
359
  }
434
360
 
435
- /* Button Styles */
436
- .btn {
437
- padding: 10px 16px;
361
+ .switch-input:focus-visible {
362
+ outline: 2px solid var(--accent);
363
+ outline-offset: 2px;
364
+ }
365
+
366
+ .cc-btn {
367
+ padding: 7px 12px;
438
368
  border-radius: 8px;
439
- font-size: 14px;
369
+ font-size: 13px;
440
370
  font-weight: 500;
371
+ line-height: 1.2;
441
372
  cursor: pointer;
442
- transition: all 0.2s ease;
443
373
  border: 1px solid transparent;
444
- display: inline-flex;
445
- align-items: center;
446
- justify-content: center;
447
- min-height: 40px;
448
- }
449
-
450
- .btn:hover {
451
- transform: translateY(-1px);
452
- }
453
-
454
- .btn:active {
455
- transform: translateY(0);
456
- }
457
-
458
- .btn-primary {
459
- background: #3b82f6;
460
- color: white;
461
- border-color: #3b82f6;
374
+ white-space: nowrap;
375
+ transition: background 0.15s, border-color 0.15s;
462
376
  }
463
377
 
464
- .btn-primary:hover {
465
- background: #2563eb;
466
- border-color: #2563eb;
467
- }
468
-
469
- .btn-secondary {
470
- background: #64748b;
378
+ .cc-btn-primary {
379
+ background: var(--accent);
380
+ border-color: var(--accent);
471
381
  color: white;
472
- border-color: #64748b;
473
382
  }
474
383
 
475
- .btn-secondary:hover {
476
- background: #475569;
477
- border-color: #475569;
384
+ .cc-btn-primary:hover {
385
+ filter: brightness(0.92);
478
386
  }
479
387
 
480
- .btn-outline {
388
+ .cc-btn-outline {
481
389
  background: transparent;
482
- color: #64748b;
390
+ color: inherit;
483
391
  border-color: #cbd5e0;
484
392
  }
485
393
 
486
- .btn-outline:hover {
394
+ .cc-btn-outline:hover {
487
395
  background: #f1f5f9;
488
- border-color: #94a3b8;
489
396
  }
490
397
 
491
- .theme-dark .btn-outline {
492
- color: #a0aec0;
398
+ .theme-dark .cc-btn-outline {
493
399
  border-color: #4a5568;
494
400
  }
495
401
 
496
- .theme-dark .btn-outline:hover {
402
+ .theme-dark .cc-btn-outline:hover {
497
403
  background: #2d3748;
498
- border-color: #718096;
499
404
  }
500
405
 
501
- .btn-close {
406
+ .cc-btn-link {
502
407
  background: none;
503
408
  border: none;
504
- font-size: 18px;
505
- cursor: pointer;
409
+ padding: 7px 4px;
410
+ margin-right: auto;
411
+ font-size: 13px;
506
412
  color: #64748b;
507
- width: 32px;
508
- height: 32px;
509
- display: flex;
510
- align-items: center;
511
- justify-content: center;
512
- border-radius: 6px;
513
- transition: all 0.2s ease;
413
+ text-decoration: underline;
414
+ cursor: pointer;
415
+ white-space: nowrap;
514
416
  }
515
417
 
516
- .btn-close:hover {
517
- background: #f1f5f9;
518
- color: #374151;
418
+ .theme-dark .cc-btn-link {
419
+ color: #a0aec0;
519
420
  }
520
421
 
521
- .theme-dark .btn-close {
522
- color: #a0aec0;
422
+ .cc-btn-close {
423
+ background: none;
424
+ border: none;
425
+ font-size: 14px;
426
+ cursor: pointer;
427
+ color: #64748b;
428
+ width: 28px;
429
+ height: 28px;
430
+ border-radius: 6px;
523
431
  }
524
432
 
525
- .theme-dark .btn-close:hover {
526
- background: #374151;
527
- color: white;
433
+ .cc-btn-close:hover {
434
+ background: #f1f5f9;
528
435
  }
529
436
 
530
- /* Animations */
531
437
  @keyframes slideUp {
532
438
  from {
533
- transform: translateY(100%);
439
+ transform: translateY(16px);
534
440
  opacity: 0;
535
441
  }
536
442
  to {
@@ -539,43 +445,33 @@
539
445
  }
540
446
  }
541
447
 
542
- @keyframes slideDown {
543
- from {
544
- transform: translateY(-100%);
545
- opacity: 0;
546
- }
547
- to {
548
- transform: translateY(0);
549
- opacity: 1;
448
+ @media (max-width: 576px) {
449
+ .cookie-consent-overlay {
450
+ padding: 8px;
550
451
  }
551
- }
552
452
 
553
- /* Responsive */
554
- @media (max-width: 768px) {
555
453
  .cookie-consent-banner {
556
- margin: 0;
557
- border-radius: 0;
558
454
  max-width: none;
559
- width: 100%;
455
+ padding: 10px 12px;
560
456
  }
561
457
 
562
- .consent-actions,
563
- .preferences-actions {
564
- flex-direction: column;
458
+ .consent-actions {
459
+ flex-wrap: wrap;
460
+ margin-top: 8px;
565
461
  }
566
462
 
567
- .btn {
568
- width: 100%;
569
- }
570
-
571
- .preference-control {
572
- flex-direction: column;
573
- align-items: flex-start;
574
- gap: 8px;
463
+ /* Link sits on its own line so both buttons keep a usable width */
464
+ .cc-btn-link {
465
+ flex-basis: 100%;
466
+ order: 1;
467
+ padding: 2px 0 0;
468
+ text-align: left;
575
469
  }
470
+ }
576
471
 
577
- .switch-container {
578
- align-self: flex-start;
472
+ @media (prefers-reduced-motion: reduce) {
473
+ .cookie-consent-banner {
474
+ animation: none;
579
475
  }
580
476
  }
581
477
  </style>
@@ -1 +1 @@
1
- {"version":3,"file":"consent.config.d.ts","sourceRoot":"","sources":["../../../src/consent/config/consent.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,eAAO,MAAM,sBAAsB,EAAE,aAmG3B,CAAC;AAGX,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,aAAa,CA6B9C,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,aAAa,CA6B9C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,aAAa,CAoBjD,CAAC;AAGF,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAcvE"}
1
+ {"version":3,"file":"consent.config.d.ts","sourceRoot":"","sources":["../../../src/consent/config/consent.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,eAAO,MAAM,sBAAsB,EAAE,aAoG3B,CAAC;AAGX,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,aAAa,CA8B9C,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,aAAa,CA8B9C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,aAAa,CAoBjD,CAAC;AAGF,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAcvE"}
@@ -44,6 +44,7 @@ export const DEFAULT_CONSENT_CONFIG = {
44
44
  rejectAllText: 'Reject all',
45
45
  customizeText: 'Manage preferences',
46
46
  savePreferencesText: 'Save preferences',
47
+ closeText: 'Close',
47
48
  // New Consent Mode v2 specific messaging
48
49
  consentModeNotice: 'Your choices help us comply with Google\'s updated consent requirements.'
49
50
  },
@@ -107,13 +108,14 @@ export const GDPR_CONFIG = {
107
108
  enableAdsDataRedaction: true
108
109
  },
109
110
  banner: {
110
- title: 'Aceitas cookies?',
111
- message: 'Usamos cookies e tecnologias semelhantes para que os nossos serviços funcionem melhor, sejam mais seguros e fáceis de usar. Ao clicar em "Aceitar todos", está a concordar com a utilização desses cookies. Pode gerir as suas preferências para escolher quais quer permitir.',
112
- acceptAllText: 'Aceitar todos',
113
- rejectAllText: 'Recusar os essenciais',
114
- customizeText: 'Gerir preferências',
111
+ title: 'Cookies',
112
+ message: 'Este site usa cookies de análise e marketing. Os essenciais estão sempre ativos.',
113
+ acceptAllText: 'OK',
114
+ rejectAllText: 'Só essenciais',
115
+ customizeText: 'Preferências',
115
116
  consentModeNotice: 'Isto ajuda-nos a cumprir as regulamentações de privacidade da UE e os requisitos de consentimento do Google.',
116
- savePreferencesText: 'Guardar preferências'
117
+ savePreferencesText: 'Guardar',
118
+ closeText: 'Fechar'
117
119
  },
118
120
  consentMode: {
119
121
  enabled: true,
@@ -144,7 +146,8 @@ export const CCPA_CONFIG = {
144
146
  rejectAllText: 'Do not sell my info',
145
147
  customizeText: 'Privacy settings',
146
148
  consentModeNotice: 'Your choices are processed according to California privacy laws.',
147
- savePreferencesText: 'Save preferences'
149
+ savePreferencesText: 'Save preferences',
150
+ closeText: 'Close'
148
151
  },
149
152
  consentMode: {
150
153
  enabled: true,