dees-domtools/ts/domtools.classes.thememanager.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-11-24 19:18:59 +00:00
import { LitElement } from 'lit-element';
2020-11-23 20:41:26 +00:00
import { DomTools } from './domtools.classes.domtools';
import * as plugins from './domtools.plugins';
export class ThemeManager {
public domtoolsRef: DomTools;
2020-11-24 19:18:59 +00:00
goBrightBoolean = false;
2020-11-23 20:41:26 +00:00
constructor(domtoolsRefArg: DomTools) {
this.domtoolsRef = domtoolsRefArg;
2020-11-24 19:18:59 +00:00
this.domtoolsRef.elementInstrumenter.connectedElements.eventSubject.subscribe(async eventData => {
await this.setThemeStatusForElement(eventData.payload, this.goBrightBoolean);
});
}
private async setThemeStatusForElement (elementArg: LitElement, goBrightBool: boolean) {
const goBright = (elementArg as any).goBright;
if (typeof goBright === 'boolean') {
(elementArg as any).goBright = goBrightBool;
}
2020-11-23 20:41:26 +00:00
}
public goBright() {
this.domtoolsRef.elementInstrumenter.forEachelement(async elementArg => {
2020-11-24 19:18:59 +00:00
await this.setThemeStatusForElement(elementArg, true);
2020-11-23 20:41:26 +00:00
});
}
public goDark() {
this.domtoolsRef.elementInstrumenter.forEachelement(async elementArg => {
2020-11-24 19:18:59 +00:00
await this.setThemeStatusForElement(elementArg, false);
2020-11-23 20:41:26 +00:00
});
}
}