X (Twitter)

Discord

GitHub1.1k
2.59 min read

v1.1.3 โ€” Enhanced Theming & Callback Improvements

Posted By

Christopher Burns
Consent Team
Christopher Burns

Minor Changes

This release introduces enhanced theme flexibility and significantly improved consent callbacks with structured data responses.

โœจ New Features

Comprehensive Theming Support

  • useColorScheme now detects themes via the .dark class on document.documentElement
  • Optional colorScheme parameter improves integration with existing theme systems
  • Full test suite added to validate dark/light/system theme switching
  • Theme system now uses @layer base for better CSS encapsulation
  • Callbacks now return structured and useful consent data
  • Works consistently across offline, c15t, and backend-connected modes
  • Callback responses now reflect user-selected preferences more clearly

๐Ÿ› Bug Fixes

  • #203 4d47e21 โ€“ fix(core): callbacks not working in c15t mode. Thanks @KayleeWilliams!
  • Fixed callbacks not firing in alternate modes (e.g., c15t)
  • useColorScheme now correctly responds to:
    • System preference changes
    • Document class changes (via MutationObserver)
  • Improved error handling for environments missing matchMedia
  • Removed unnecessary localStorage dependency for theme persistence

๐Ÿ—๏ธ Refactors

  • Theme-related CSS is now consistently structured using @layer base
  • Refined internal theme types to allow better extension/customization
  • Simplified theme config to support nested object structure for banners and widgets

๐Ÿ“š Documentation

  • Fixed broken example in offline mode โ€“ #187
  • Updated configuration types to document new theme and colorScheme options
  • Added detailed callback payload examples and behavior notes across client modes
  • Enhanced API references and docs for:
    • onSetConsent and other lifecycle callbacks
    • Banner fetch event handler

๐Ÿงช Tests

Color Scheme Tests:

  • System preference override
  • Explicit theme override
  • Document class detection

Callback Tests:

  • Triggering across client modes
  • Payload accuracy and structure

๐Ÿ’ฅ Breaking Changes

  • Removed localStorage theme fallback โ€” rely on system preference or class
  • Misconfigured theme props in c15t config may need to be adjusted
  • Some fields (e.g., id) removed from callback data objects โ€” now accessible via the response object

๐Ÿ”„ Migration Guide

Theme System Changes

localStorage theme fallback has been removed:

// Before: Manual localStorage theme management
localStorage.setItem('theme', 'dark');

// After: Use system preference or class-based detection
document.documentElement.classList.add('dark');

Callback Data Structure

Some fields have been moved in callback responses:

// Before
onSetConsent(({ id, consents }) => {
  // id was directly available
});

// After
onSetConsent(({ consents, response }) => {
  // id is now in response object
  const id = response.id;
});

๐Ÿ“ฆ Version Packages

Published via #205 by @github-actions

This release significantly enhances the theming capabilities and callback reliability of c15t, providing a more robust foundation for custom UI implementations and better integration with existing design systems.

Thank you to our contributors

c15t.com