Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
188690a845 | |||
85aa910046 | |||
7b8e9ecdf3 | |||
df79f7a27c | |||
a7527ab73c | |||
ffba30da5a | |||
c6204f5324 | |||
6411028376 | |||
c915c3a713 | |||
5009068b56 | |||
62136c8d20 | |||
06b7f7fd12 |
21030
package-lock.json
generated
21030
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@designestate/dees-element",
|
"name": "@designestate/dees-element",
|
||||||
"version": "1.0.15",
|
"version": "1.0.21",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a custom element class extending lit element class",
|
"description": "a custom element class extending lit element class",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -12,19 +12,19 @@
|
|||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.27",
|
||||||
"@gitzone/tsbundle": "^1.0.80",
|
"@gitzone/tsbundle": "^1.0.87",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tstest": "^1.0.57",
|
||||||
"@pushrocks/tapbundle": "^3.2.14",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.14.37",
|
"@types/node": "^16.9.0",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@designestate/dees-domtools": "^1.0.86",
|
"@designestate/dees-domtools": "^1.0.93",
|
||||||
"@pushrocks/isounique": "^1.0.4",
|
"@pushrocks/isounique": "^1.0.4",
|
||||||
"@pushrocks/smartrx": "^2.0.19",
|
"@pushrocks/smartrx": "^2.0.19",
|
||||||
"lit-element": "^2.4.0"
|
"lit-element": "^2.5.1"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
|
@ -8,7 +8,7 @@ tap.test('should create a static element', async () => {
|
|||||||
public static styles = [
|
public static styles = [
|
||||||
deesElement.css`
|
deesElement.css`
|
||||||
.buttonClass {
|
.buttonClass {
|
||||||
background: ${deesElement.cssManager.dbTheme('blue', 'black')};
|
background: ${deesElement.cssManager.bdTheme('blue', 'black')};
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
];
|
];
|
||||||
|
@ -1,31 +1,67 @@
|
|||||||
import { CSSResult } from 'lit-element';
|
import { CSSResult, unsafeCSS } from 'lit-element';
|
||||||
import * as plugins from './dees-element.plugins';
|
import * as plugins from './dees-element.plugins';
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@designestate/dees-domtools';
|
||||||
|
|
||||||
export interface IDbVarTriplet {
|
export interface IBdVarTriplet {
|
||||||
cssVarName: string;
|
cssVarName: string;
|
||||||
darkValue: string;
|
darkValue: string;
|
||||||
brightValue: string;
|
brightValue: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CssManager {
|
export class CssManager {
|
||||||
public dbVarTripletStore: IDbVarTriplet[] = [];
|
public domtoolsPromise = domtools.DomTools.setupDomTools();
|
||||||
|
public goBright: boolean = false;
|
||||||
|
public bdVarTripletStore: IBdVarTriplet[] = [];
|
||||||
|
|
||||||
public dbTheme(brightValueArg: string, darkValueArg: string): CSSResult {
|
constructor() {
|
||||||
|
this.domtoolsPromise.then(async (domtoolsArg) => {
|
||||||
|
domtoolsArg.themeManager.themeObservable.subscribe(async (goBrightArg) => {
|
||||||
|
this.goBright = goBrightArg;
|
||||||
|
await domtoolsArg.domReady.promise;
|
||||||
|
for (const bdTripletArg of this.bdVarTripletStore) {
|
||||||
|
document.body.style.setProperty(
|
||||||
|
bdTripletArg.cssVarName,
|
||||||
|
this.goBright ? bdTripletArg.brightValue : bdTripletArg.darkValue
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public get defaultStyles () {
|
||||||
|
return domtools.elementBasic.staticStyles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public cssForTablet(contentArg) {
|
||||||
|
return unsafeCSS(domtools.breakpoints.cssForTablet(contentArg));
|
||||||
|
};
|
||||||
|
|
||||||
|
public cssForPhablet(contentArg) {
|
||||||
|
return unsafeCSS(domtools.breakpoints.cssForPhablet(contentArg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public cssForPhone(contentArg) {
|
||||||
|
return unsafeCSS(domtools.breakpoints.cssForPhone(contentArg));
|
||||||
|
};
|
||||||
|
|
||||||
|
public bdTheme(brightValueArg: string, darkValueArg: string): CSSResult {
|
||||||
let returnCssVar: string;
|
let returnCssVar: string;
|
||||||
const existingTriplet = this.dbVarTripletStore.find(tripletArg => tripletArg.darkValue === darkValueArg && tripletArg.brightValue === brightValueArg);
|
const existingTriplet = this.bdVarTripletStore.find(
|
||||||
|
(tripletArg) =>
|
||||||
|
tripletArg.darkValue === darkValueArg && tripletArg.brightValue === brightValueArg
|
||||||
|
);
|
||||||
if (existingTriplet) {
|
if (existingTriplet) {
|
||||||
returnCssVar = existingTriplet.cssVarName;
|
returnCssVar = existingTriplet.cssVarName;
|
||||||
} else {
|
} else {
|
||||||
const newTriplet: IDbVarTriplet = {
|
const newTriplet: IBdVarTriplet = {
|
||||||
cssVarName: `--${plugins.isounique.uni()}`,
|
cssVarName: `--${plugins.isounique.uni()}`,
|
||||||
brightValue: brightValueArg,
|
brightValue: brightValueArg,
|
||||||
darkValue: darkValueArg
|
darkValue: darkValueArg,
|
||||||
};
|
};
|
||||||
this.dbVarTripletStore.push(newTriplet);
|
this.bdVarTripletStore.push(newTriplet);
|
||||||
domtools.DomTools.setupDomTools().then(async (domtools) => {
|
this.domtoolsPromise.then(async (domtoolsArg) => {
|
||||||
await domtools.domReady.promise;
|
await domtoolsArg.domReady.promise;
|
||||||
document.body.style.setProperty(newTriplet.cssVarName, newTriplet.darkValue);
|
document.body.style.setProperty(newTriplet.cssVarName, this.goBright ? newTriplet.brightValue : newTriplet.darkValue);
|
||||||
});
|
});
|
||||||
returnCssVar = newTriplet.cssVarName;
|
returnCssVar = newTriplet.cssVarName;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@ export {
|
|||||||
html,
|
html,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
css,
|
css,
|
||||||
unsafeCSS
|
unsafeCSS,
|
||||||
|
state
|
||||||
} from 'lit-element';
|
} from 'lit-element';
|
||||||
|
|
||||||
export { DeesElement } from './dees-element.classes.dees-element';
|
export { DeesElement } from './dees-element.classes.dees-element';
|
||||||
|
Reference in New Issue
Block a user