feat(DeesElement): Add invocation of the themeChanged hook in connectedCallback

This commit is contained in:
Juergen Kunz
2025-07-06 11:56:23 +00:00
parent 05cc971c0b
commit 7e26cd39d7
3 changed files with 18 additions and 1 deletions

View File

@ -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) {