diff --git a/changelog.md b/changelog.md index da45d59..e395b7a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2025-07-06 - 2.1.0 - feat(DeesElement) +Add invocation of the themeChanged hook in connectedCallback + +- Now calls themeChanged (if defined) when the theme changes, enabling custom handlers for theme switches +- Improves lifecycle management by allowing extensions to react to bright/dark mode changes + ## 2025-06-20 - 2.0.44 - fix(ci) Remove obsolete GitLab CI configuration diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 977b4a7..27011a0 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@design.estate/dees-element', - version: '2.0.44', + version: '2.1.0', description: 'A library for creating custom elements extending the lit element class with additional functionalities.' } diff --git a/ts/classes.dees-element.ts b/ts/classes.dees-element.ts index 46523ad..c553b5e 100644 --- a/ts/classes.dees-element.ts +++ b/ts/classes.dees-element.ts @@ -25,11 +25,22 @@ export class DeesElement extends plugins.lit.LitElement { }); } + /** + * Called when the theme changes between bright and dark. + * Override this method to handle theme changes. + * @param goBright - true if switching to bright theme, false if switching to dark theme + */ + protected themeChanged?(goBright: boolean): void; + public async connectedCallback() { super.connectedCallback(); const domtools = await this.domtoolsPromise; this.themeSubscription = domtools.themeManager.themeObservable.subscribe((goBrightArg) => { this.goBright = goBrightArg; + // Call themeChanged if it's defined + if (this.themeChanged) { + this.themeChanged(goBrightArg); + } }); this.rxSubscriptions.push(this.themeSubscription); for (const startupFunction of this.startupFunctions) {