Compare commits

..

24 Commits

Author SHA1 Message Date
7b8e9ecdf3 1.0.20 2021-09-08 23:42:07 +02:00
df79f7a27c fix(core): update 2021-09-08 23:42:06 +02:00
a7527ab73c 1.0.19 2021-03-28 22:20:16 +00:00
ffba30da5a fix(core): update 2021-03-28 22:20:16 +00:00
c6204f5324 1.0.18 2021-03-28 22:14:25 +00:00
6411028376 fix(core): update 2021-03-28 22:14:25 +00:00
c915c3a713 1.0.17 2021-03-28 22:02:20 +00:00
5009068b56 fix(core): update 2021-03-28 22:02:19 +00:00
62136c8d20 1.0.16 2021-03-28 20:10:51 +00:00
06b7f7fd12 fix(core): update 2021-03-28 20:10:51 +00:00
07be13cf39 1.0.15 2021-03-28 19:57:46 +00:00
20e539edf0 fix(core): update 2021-03-28 19:57:45 +00:00
a06752b09f 1.0.14 2021-03-28 14:38:18 +00:00
d697fa2437 fix(core): update 2021-03-28 14:38:17 +00:00
a0cad2f4bc 1.0.13 2021-03-27 18:25:39 +00:00
240e34b7d0 fix(core): update 2021-03-27 18:25:39 +00:00
4d4dd59b9b 1.0.12 2021-03-27 18:21:39 +00:00
746ebe1490 fix(core): update 2021-03-27 18:21:38 +00:00
b6fc6b4f31 1.0.11 2021-03-27 16:52:06 +00:00
fae10a3240 fix(core): update 2021-03-27 16:52:06 +00:00
8390ba67b3 1.0.10 2020-12-07 22:56:24 +00:00
d5872511b8 fix(core): update 2020-12-07 22:56:24 +00:00
a322c9a929 1.0.9 2020-12-07 03:31:00 +00:00
6301d827e1 fix(core): update 2020-12-07 03:30:59 +00:00
9 changed files with 18408 additions and 3485 deletions

21633
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@designestate/dees-element",
"version": "1.0.8",
"version": "1.0.20",
"private": false,
"description": "a custom element class extending lit element class",
"main": "dist_ts/index.js",
@ -12,17 +12,19 @@
"build": "(tsbuild --web)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.11.2",
"@gitzone/tsbuild": "^2.1.27",
"@gitzone/tsbundle": "^1.0.87",
"@gitzone/tstest": "^1.0.57",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^16.9.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@designestate/dees-domtools": "^1.0.70",
"lit-element": "^2.4.0"
"@designestate/dees-domtools": "^1.0.93",
"@pushrocks/isounique": "^1.0.4",
"@pushrocks/smartrx": "^2.0.19",
"lit-element": "^2.5.1"
},
"browserslist": [
"last 1 chrome versions"

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.bdTheme('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,80 @@
import { CSSResult, unsafeCSS } from 'lit-element';
import * as plugins from './dees-element.plugins';
import * as domtools from '@designestate/dees-domtools';
export interface IBdVarTriplet {
cssVarName: string;
darkValue: string;
brightValue: string;
}
export class CssManager {
public domtoolsPromise = domtools.DomTools.setupDomTools();
public goBright: boolean = false;
public bdVarTripletStore: IBdVarTriplet[] = [];
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;
const existingTriplet = this.bdVarTripletStore.find(
(tripletArg) =>
tripletArg.darkValue === darkValueArg && tripletArg.brightValue === brightValueArg
);
if (existingTriplet) {
returnCssVar = existingTriplet.cssVarName;
} else {
const newTriplet: IBdVarTriplet = {
cssVarName: `--${plugins.isounique.uni()}`,
brightValue: brightValueArg,
darkValue: darkValueArg,
};
this.bdVarTripletStore.push(newTriplet);
this.domtoolsPromise.then(async (domtoolsArg) => {
await domtoolsArg.domReady.promise;
document.body.style.setProperty(newTriplet.cssVarName, this.goBright ? newTriplet.brightValue : newTriplet.darkValue);
});
returnCssVar = newTriplet.cssVarName;
}
return plugins.litElement.unsafeCSS(`var(${returnCssVar})`);
}
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,5 +1,17 @@
import { LitElement, property } from 'lit-element';
// pushrocks scope
import * as isounique from '@pushrocks/isounique';
import * as smartrx from '@pushrocks/smartrx';
export {
isounique,
smartrx
};
// third party scope
import { css, unsafeCSS, LitElement, property } from 'lit-element';
const litElement = {
css,
unsafeCSS,
LitElement,
property
};

View File

@ -1,27 +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
} from 'lit-element';
export class DeesElement extends plugins.litElement.LitElement {
@plugins.litElement.property({type: Boolean})
public goBright: boolean = false;
public domtoolsPromise = plugins.domtools.elementBasic.setup(this);
export { DeesElement } from './dees-element.classes.dees-element';
public connectedCallback() {
super.connectedCallback();
this.dispatchEvent(new CustomEvent('domtools-connected'));
}
public disconnectedCallback() {
super.disconnectedCallback();
this.dispatchEvent(new CustomEvent('domtools-disconnected'));
}
}
export const cssManager = new CssManager();