Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
63c9ae97d4 | |||
a83239e0d9 | |||
8da64f1b50 | |||
2d4c0e4e49 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@designestate/dees-domtools",
|
||||
"version": "1.0.72",
|
||||
"version": "1.0.74",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@designestate/dees-domtools",
|
||||
"version": "1.0.72",
|
||||
"version": "1.0.74",
|
||||
"private": false,
|
||||
"description": "tools to simplify complex css structures",
|
||||
"main": "dist_ts/index.js",
|
||||
|
@ -6,12 +6,22 @@ export class ThemeManager {
|
||||
public domtoolsRef: DomTools;
|
||||
|
||||
public goBrightBoolean = false;
|
||||
public preferredColorSchemeMediaMatch = window.matchMedia('(prefers-color-scheme: light)');
|
||||
|
||||
constructor(domtoolsRefArg: DomTools) {
|
||||
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 => {
|
||||
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) {
|
||||
|
@ -10,7 +10,7 @@ import { html, LitElement } from 'lit-element';
|
||||
export const styles = html`
|
||||
<style>
|
||||
* {
|
||||
transition: background 0.2s, color 0.1s;
|
||||
transition: background 0.1s, color 0.1s;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
Reference in New Issue
Block a user