fix(core): update
This commit is contained in:
parent
8da64f1b50
commit
a83239e0d9
@ -6,12 +6,22 @@ export class ThemeManager {
|
|||||||
public domtoolsRef: DomTools;
|
public domtoolsRef: DomTools;
|
||||||
|
|
||||||
public goBrightBoolean = false;
|
public goBrightBoolean = false;
|
||||||
|
public preferredColorSchemeMediaMatch = window.matchMedia('(prefers-color-scheme: light)');
|
||||||
|
|
||||||
constructor(domtoolsRefArg: DomTools) {
|
constructor(domtoolsRefArg: DomTools) {
|
||||||
this.domtoolsRef = domtoolsRefArg;
|
this.domtoolsRef = domtoolsRefArg;
|
||||||
|
|
||||||
|
// lets take care of elements being added that need to know of the current theme
|
||||||
this.domtoolsRef.elementInstrumenter.connectedElements.eventSubject.subscribe(async eventData => {
|
this.domtoolsRef.elementInstrumenter.connectedElements.eventSubject.subscribe(async eventData => {
|
||||||
await this.setThemeStatusForElement(eventData.payload, this.goBrightBoolean);
|
await this.setThemeStatusForElement(eventData.payload, this.goBrightBoolean);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// lets care
|
||||||
|
this.goBrightBoolean = this.preferredColorSchemeMediaMatch.matches;
|
||||||
|
this.preferredColorSchemeMediaMatch.addEventListener('change', eventArg => {
|
||||||
|
this.goBrightBoolean = eventArg.matches;
|
||||||
|
this.updateAllConnectedElements();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async setThemeStatusForElement (elementArg: LitElement, goBrightBool: boolean) {
|
private async setThemeStatusForElement (elementArg: LitElement, goBrightBool: boolean) {
|
||||||
|
Loading…
Reference in New Issue
Block a user