Compare commits

...

22 Commits

Author SHA1 Message Date
570a026cf8 1.0.77 2020-11-30 20:03:05 +00:00
48b5cc770c fix(core): update 2020-11-30 20:03:05 +00:00
7ae2de5843 1.0.76 2020-11-30 10:25:00 +00:00
e4d87ae882 fix(core): update 2020-11-30 10:25:00 +00:00
259a669e24 1.0.75 2020-11-29 23:56:20 +00:00
bf461dd1a0 fix(core): update 2020-11-29 23:56:19 +00:00
63c9ae97d4 1.0.74 2020-11-25 15:42:56 +00:00
a83239e0d9 fix(core): update 2020-11-25 15:42:55 +00:00
8da64f1b50 1.0.73 2020-11-25 15:14:48 +00:00
2d4c0e4e49 fix(core): update 2020-11-25 15:14:48 +00:00
1c8f7fa59e 1.0.72 2020-11-25 14:56:09 +00:00
a613c0aca2 fix(core): update 2020-11-25 14:56:08 +00:00
127564cd71 1.0.71 2020-11-25 14:43:23 +00:00
e077bf5b25 fix(core): update 2020-11-25 14:43:23 +00:00
64a3f57813 1.0.70 2020-11-24 20:57:42 +00:00
1315e8c3f6 fix(core): update 2020-11-24 20:57:41 +00:00
d059862841 1.0.69 2020-11-24 19:48:14 +00:00
ad34affb9e fix(core): update 2020-11-24 19:48:14 +00:00
011b3fb76a 1.0.68 2020-11-24 19:23:07 +00:00
47099d02b5 fix(core): update 2020-11-24 19:23:06 +00:00
f4029ed008 1.0.67 2020-11-24 19:19:00 +00:00
d5732822e4 fix(core): update 2020-11-24 19:18:59 +00:00
5 changed files with 83 additions and 65 deletions

69
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@designestate/dees-domtools",
"version": "1.0.66",
"version": "1.0.77",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1381,15 +1381,15 @@
"integrity": "sha512-P1xLsuA1+8LQpoWCo2nP2vIQXKGUl5wDWU6CD7xTDZc3uw0He5V/qCPHM5zpIZsS7IuZOxDDpWb7aFveB11tXw=="
},
"@pushrocks/lik": {
"version": "4.0.17",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-4.0.17.tgz",
"integrity": "sha512-K5dX3k3i7iVxFMJ+IYwJRljewukJCc2zgj6+88R18/8SajVAq7ITOl3/FTbmEPFCJv5rl/LQ9FtcMynWlwSlzQ==",
"version": "4.0.20",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-4.0.20.tgz",
"integrity": "sha512-DJbxSZFwDuHe4W7dU5anyO72gy4woZpkxSpySphdHbSYZf50VJ1sMOKIccSpgRIczeB0BTR5i0c+cKnNFrg2jw==",
"requires": {
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartmatch": "^1.0.7",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrx": "^2.0.17",
"@pushrocks/smarttime": "^3.0.24",
"@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartrx": "^2.0.19",
"@pushrocks/smarttime": "^3.0.37",
"@types/minimatch": "^3.0.3",
"symbol-tree": "^3.2.4"
}
@ -1949,9 +1949,9 @@
}
},
"@pushrocks/smartrouter": {
"version": "1.0.4",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrouter/-/smartrouter-1.0.4.tgz",
"integrity": "sha512-6ahtHvZvwH/IQh7EtachXJkHxfQZe3i/TqCxmzFdhppDTWek+v8E/fpHit0av/568tLmC6Jc2B+WHPge6whVhg==",
"version": "1.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrouter/-/smartrouter-1.0.6.tgz",
"integrity": "sha512-aKhZOkHsqOUiPFA3+61vkZvInGb1lQ/68FIfT7dBrrFdHXXPo6tY8cm+GnT4ELUnXLpZBmnNm2rxLa22z6j4dg==",
"requires": {
"path-to-regexp": "^6.1.0"
}
@ -1991,34 +1991,22 @@
}
},
"@pushrocks/smartstate": {
"version": "1.0.17",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstate/-/smartstate-1.0.17.tgz",
"integrity": "sha512-lzcN6zeGXdDxG67cJPSgC2Of0Up7iQf7hKI0KMAxricYCQp514DJYdfrv82SAEoTqB4eG4bOVqq5M9IYkvEfZw==",
"version": "1.0.21",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstate/-/smartstate-1.0.21.tgz",
"integrity": "sha512-uyrnTrBoIP6Ka3pYAMZFZVZ4AOgFSTPgM5sURWMNogC5Fncx1A7PuDL5nE1oRJIZOl5U/kH3vq+/81gmPn4QbA==",
"requires": {
"@pushrocks/lik": "^4.0.12",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrx": "^2.0.15",
"rxjs": "^6.5.5"
"@pushrocks/lik": "^4.0.20",
"@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartrx": "^2.0.19",
"rxjs": "^6.6.3"
},
"dependencies": {
"@pushrocks/smartrx": {
"version": "2.0.18",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrx/-/smartrx-2.0.18.tgz",
"integrity": "sha512-DqUmtS7mONO6bvWEZmSLy4M9hlxNWysMYc7XOZLr50BMaa0HUNYWI1myUFCMNcbUUOxuQNig01XqR1smfIN69g==",
"rxjs": {
"version": "6.6.3",
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.6.3.tgz",
"integrity": "sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==",
"requires": {
"@pushrocks/lik": "^4.0.14",
"@pushrocks/smartpromise": "^3.0.6",
"rxjs": "^6.6.0"
},
"dependencies": {
"rxjs": {
"version": "6.6.0",
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.6.0.tgz",
"integrity": "sha512-3HMA8z/Oz61DUHe+SdOiQyzIf4tOx5oQHmMir7IZEu6TMqCLHT4LRcmNaUS0NwOz8VLvmmBduMsoaUvMaIiqzg==",
"requires": {
"tslib": "^1.9.0"
}
}
"tslib": "^1.9.0"
}
}
}
@ -2458,9 +2446,9 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"@types/node": {
"version": "14.14.6",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-14.14.6.tgz",
"integrity": "sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw=="
"version": "14.14.10",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-14.14.10.tgz",
"integrity": "sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ=="
},
"@types/parcel-bundler": {
"version": "1.12.1",
@ -8425,9 +8413,9 @@
"dev": true
},
"path-to-regexp": {
"version": "6.1.0",
"resolved": "https://verdaccio.lossless.one/path-to-regexp/-/path-to-regexp-6.1.0.tgz",
"integrity": "sha512-h9DqehX3zZZDCEm+xbfU0ZmwCGFCAAraPJWMXJ4+v32NjZJilVg3k1TcKsRgIb8IQ/izZSaydDc1OhJCZvs2Dw=="
"version": "6.2.0",
"resolved": "https://verdaccio.lossless.one/path-to-regexp/-/path-to-regexp-6.2.0.tgz",
"integrity": "sha512-f66KywYG6+43afgE/8j/GoiNyygk/bnoCbps++3ErRKsIYkGGupyv07R2Ok5m9i67Iqc+T2g1eAUGUPzWhYTyg=="
},
"pathval": {
"version": "1.1.0",
@ -9741,6 +9729,7 @@
"version": "6.5.5",
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.5.5.tgz",
"integrity": "sha512-WfQI+1gohdf0Dai/Bbmk5L5ItH5tYqm3ki2c5GdWhKjalzjg93N3avFjVStyZZz+A2Em+ZxKH5bNghw9UeylGQ==",
"dev": true,
"requires": {
"tslib": "^1.9.0"
}

View File

@ -1,6 +1,6 @@
{
"name": "@designestate/dees-domtools",
"version": "1.0.66",
"version": "1.0.77",
"private": false,
"description": "tools to simplify complex css structures",
"main": "dist_ts/index.js",
@ -17,18 +17,18 @@
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.14.6",
"@types/node": "^14.14.10",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@apiglobal/typedrequest": "^1.0.54",
"@designestate/dees-comms": "^1.0.7",
"@pushrocks/lik": "^4.0.17",
"@pushrocks/lik": "^4.0.20",
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartrouter": "^1.0.4",
"@pushrocks/smartstate": "^1.0.17",
"@pushrocks/smartrouter": "^1.0.6",
"@pushrocks/smartstate": "^1.0.21",
"@pushrocks/webrequest": "^2.0.13",
"@pushrocks/websetup": "^3.0.11",
"@pushrocks/webstore": "^1.0.16",

View File

@ -5,19 +5,20 @@ export class ElementInstrumenter {
connectedElements = new plugins.lik.ObjectMap<LitElement>();
public instrumentElement(elementArg: LitElement) {
const originalConnectedCallback = elementArg.connectedCallback;
const originalDisconnectedCallback = elementArg.disconnectedCallback;
elementArg.connectedCallback = () => {
const addToConnectedElementsFunc = (eventArg: CustomEvent) => {
this.connectedElements.add(elementArg);
originalConnectedCallback.apply(elementArg);
};
elementArg.disconnectedCallback = () => {
const removeFromConnectedElementsFunc = eventArg => {
this.connectedElements.remove(elementArg);
originalDisconnectedCallback.apply(elementArg);
elementArg.removeEventListener('domtools-connected', addToConnectedElementsFunc);
elementArg.removeEventListener('domtools-disconnected', removeFromConnectedElementsFunc);
};
this.connectedElements.add(elementArg);
elementArg.addEventListener('domtools-connected', addToConnectedElementsFunc);
elementArg.addEventListener('domtools-disconnected', removeFromConnectedElementsFunc);
if (elementArg.parentElement) {
this.connectedElements.add(elementArg);
}
}
public async forEachelement(eachFuncArg: (elementArg: LitElement) => Promise<void>) {

View File

@ -1,28 +1,55 @@
import { LitElement } from 'lit-element';
import { DomTools } from './domtools.classes.domtools';
import * as plugins from './domtools.plugins';
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) {
const goBright = (elementArg as any).goBright;
if (typeof goBright === 'boolean') {
(elementArg as any).goBright = goBrightBool;
}
}
private async updateAllConnectedElements() {
document.body.style.background = this.goBrightBoolean ? '#fff' : '#000';
this.domtoolsRef.elementInstrumenter.forEachelement(async elementArg => {
await this.setThemeStatusForElement(elementArg, this.goBrightBoolean);
});
}
public goBright() {
this.domtoolsRef.elementInstrumenter.forEachelement(async elementArg => {
const goBright = (elementArg as any).goBright;
if (typeof goBright === 'boolean') {
(elementArg as any).goBright = true;
}
});
this.goBrightBoolean = true;
this.updateAllConnectedElements();
}
public goDark() {
this.domtoolsRef.elementInstrumenter.forEachelement(async elementArg => {
const goBright = (elementArg as any).goBright;
if (typeof goBright === 'boolean') {
(elementArg as any).goBright = false;
}
});
this.goBrightBoolean = false;
this.updateAllConnectedElements();
}
public toggleDarkBright() {
this.goBrightBoolean = !this.goBrightBoolean;
this.updateAllConnectedElements();
}
}

View File

@ -10,6 +10,7 @@ import { html, LitElement } from 'lit-element';
export const styles = html`
<style>
* {
transition: background 0.1s, color 0.1s;
font-family: 'Roboto', sans-serif;
box-sizing: border-box;
}