fix(core): update

This commit is contained in:
Philipp Kunz 2021-03-27 16:52:06 +00:00
parent 8390ba67b3
commit fae10a3240
9 changed files with 1549 additions and 794 deletions

2178
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,15 +13,16 @@
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tsbundle": "^1.0.80",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.11.2",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^14.14.37",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@designestate/dees-domtools": "^1.0.80",
"@designestate/dees-domtools": "^1.0.86",
"@pushrocks/isounique": "^1.0.4",
"@pushrocks/smartrx": "^2.0.19",
"lit-element": "^2.4.0"
},

23
test/test.browser.ts Normal file
View File

@ -0,0 +1,23 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as deesElement from '../ts/index';
tap.test('should create a static element', async () => {
@deesElement.customElement('my-button')
class MyButton extends deesElement.DeesElement {
// STATIC
public static styles = [
deesElement.css`
.buttonClass {
background: ${deesElement.cssManager.dbTheme('blue', 'black')};
}
`
];
// INSTANCE
render() {
return deesElement.html`<div class="buttonClass">My Button</div>`
}
}
});
tap.start();

View File

@ -1,6 +0,0 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as deesElement from '../ts/index';
tap.test('first test', async () => {});
tap.start();

View File

@ -0,0 +1,38 @@
import { CSSResult } from 'lit-element';
import * as plugins from './dees-element.plugins';
export interface IDbVarTriplet {
cssVarName: string;
darkValue: string;
brightValue: string;
}
export class CssManager {
public dbVarTripletStore: IDbVarTriplet[] = [];
public dbTheme(darkValueArg: string, brightValueArg: string): CSSResult {
const existingTriplet = this.dbVarTripletStore.find(tripletArg => tripletArg.darkValue === darkValueArg && tripletArg.brightValue === brightValueArg);
if (existingTriplet) {
return plugins.litElement.unsafeCSS(existingTriplet.cssVarName)
} else {
const newTriplet: IDbVarTriplet = {
cssVarName: `--${plugins.isounique.uni()}`,
brightValue: brightValueArg,
darkValue: darkValueArg
}
this.dbVarTripletStore.push(newTriplet)
document.body.style.setProperty(newTriplet.cssVarName, newTriplet.darkValue);
return plugins.litElement.unsafeCSS(newTriplet.cssVarName);
}
}
public cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number): CSSResult => {
let returnString = ``;
for (let i = 0; i < amountOfColumnsArg; i++) {
returnString += ` calc((100%/${amountOfColumnsArg}) - (${
gapSizeArg * (amountOfColumnsArg - 1)
}px/${amountOfColumnsArg}))`;
}
return plugins.litElement.unsafeCSS(returnString);
};
}

View File

@ -0,0 +1,38 @@
import * as plugins from './dees-element.plugins';
export class DeesElement extends plugins.litElement.LitElement {
// INSTANCE
@plugins.litElement.property({ type: Boolean })
public goBright: boolean = false;
// domtools
public domtoolsPromise = plugins.domtools.elementBasic.setup(this);
@plugins.litElement.property()
domtools?: plugins.domtools.DomTools;
private themeSubscription: plugins.smartrx.rxjs.Subscription;
constructor() {
super();
this.domtoolsPromise.then((domtoolsArg) => {
this.domtools = domtoolsArg;
});
}
public connectedCallback() {
super.connectedCallback();
this.domtoolsPromise.then(async (domtools) => {
this.themeSubscription = domtools.themeManager.themeObservable.subscribe((goBrightArg) => {
this.goBright = goBrightArg;
});
});
this.dispatchEvent(new CustomEvent('deesElementConnected'));
}
public disconnectedCallback() {
super.disconnectedCallback();
this.themeSubscription.unsubscribe();
this.dispatchEvent(new CustomEvent('deesElementDisconnected'));
}
}

View File

@ -1,13 +1,17 @@
// pushrocks scope
import * as isounique from '@pushrocks/isounique';
import * as smartrx from '@pushrocks/smartrx';
export {
isounique,
smartrx
};
// third party scope
import { LitElement, property } from 'lit-element';
import { css, unsafeCSS, LitElement, property } from 'lit-element';
const litElement = {
css,
unsafeCSS,
LitElement,
property
};

View File

@ -1,47 +1,16 @@
import { CssManager } from './dees-element.classes.cssmanager';
import * as plugins from './dees-element.plugins';
export {
property,
html,
customElement,
TemplateResult,
property,
internalProperty,
html,
TemplateResult,
css,
unsafeCSS,
unsafeCSS
} from 'lit-element';
export class DeesElement extends plugins.litElement.LitElement {
@plugins.litElement.property({ type: Boolean })
public goBright: boolean = false;
export { DeesElement } from './dees-element.classes.dees-element';
// domtools
public domtoolsPromise = plugins.domtools.elementBasic.setup(this);
@plugins.litElement.property()
domtools?: plugins.domtools.DomTools;
private themeSubscription: plugins.smartrx.rxjs.Subscription;
constructor() {
super();
this.domtoolsPromise.then((domtoolsArg) => {
this.domtools = domtoolsArg;
});
}
public connectedCallback() {
super.connectedCallback();
this.domtoolsPromise.then(async (domtools) => {
this.themeSubscription = domtools.themeManager.themeObservable.subscribe((goBrightArg) => {
this.goBright = goBrightArg;
});
});
this.dispatchEvent(new CustomEvent('deesElementConnected'));
}
public disconnectedCallback() {
super.disconnectedCallback();
this.themeSubscription.unsubscribe();
this.dispatchEvent(new CustomEvent('deesElementDisconnected'));
}
}
export const cssManager = new CssManager();