Compare commits
73 Commits
Author | SHA1 | Date | |
---|---|---|---|
a7e1a02b52 | |||
9f974a97f5 | |||
d80f94db29 | |||
a32b6b425b | |||
9ca286697c | |||
07dcfbe531 | |||
ac919e2cce | |||
30e1822b5b | |||
b6c67a55e5 | |||
f20977e936 | |||
8ad5906e06 | |||
4008de283c | |||
1177ec6158 | |||
b8ced9a991 | |||
9b30853a56 | |||
acc1d7eea7 | |||
bb6818324d | |||
3dee5f9b68 | |||
ef92d1bde3 | |||
e394c999b2 | |||
68bcc10ee6 | |||
d2cd5ce6f3 | |||
29fb3a2f9b | |||
ef1e373fb3 | |||
d607968dfb | |||
45b2183c88 | |||
68f11d7e76 | |||
cc6f14551f | |||
12f6bb3317 | |||
b63fac3f75 | |||
61d7de2323 | |||
d6c7f5da97 | |||
36c7f8ae38 | |||
2cae90816d | |||
9e527d7fdb | |||
9e6887bc11 | |||
17a2504760 | |||
5622ea41e9 | |||
a0f6777930 | |||
265e5c2264 | |||
f15e4e2948 | |||
5b2218126c | |||
ae39ad12a1 | |||
dc71f41df3 | |||
41c93a0b27 | |||
192cd76012 | |||
b25be8c85e | |||
188690a845 | |||
85aa910046 | |||
7b8e9ecdf3 | |||
df79f7a27c | |||
a7527ab73c | |||
ffba30da5a | |||
c6204f5324 | |||
6411028376 | |||
c915c3a713 | |||
5009068b56 | |||
62136c8d20 | |||
06b7f7fd12 | |||
07be13cf39 | |||
20e539edf0 | |||
a06752b09f | |||
d697fa2437 | |||
a0cad2f4bc | |||
240e34b7d0 | |||
4d4dd59b9b | |||
746ebe1490 | |||
b6fc6b4f31 | |||
fae10a3240 | |||
8390ba67b3 | |||
d5872511b8 | |||
a322c9a929 | |||
6301d827e1 |
@ -12,6 +12,9 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
@ -36,6 +39,7 @@ auditProductionDependencies:
|
|||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
auditDevDependencies:
|
auditDevDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -22,5 +22,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"typescript.tsdk": "node_modules/typescript/lib"
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "designestate",
|
"gitscope": "designestate",
|
||||||
"gitrepo": "dees-element",
|
"gitrepo": "dees-element",
|
||||||
"shortDescription": "a custom element class extending lit element class",
|
"description": "a custom element class extending lit element class",
|
||||||
"npmPackagename": "@designestate/dees-element",
|
"npmPackagename": "@designestate/dees-element",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "design.estate"
|
"projectDomain": "design.estate"
|
||||||
|
23132
package-lock.json
generated
23132
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
@ -1,28 +1,31 @@
|
|||||||
{
|
{
|
||||||
"name": "@designestate/dees-element",
|
"name": "@designestate/dees-element",
|
||||||
"version": "1.0.8",
|
"version": "2.0.8",
|
||||||
"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",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web --allowimplicitany --skiplibcheck && tsbundle npm)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.61",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@gitzone/tsbundle": "^1.0.102",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tstest": "^1.0.70",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^5.0.3",
|
||||||
"@types/node": "^14.11.2",
|
"@types/node": "^17.0.25",
|
||||||
"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.70",
|
"@designestate/dees-domtools": "^2.0.6",
|
||||||
"lit-element": "^2.4.0"
|
"@pushrocks/isounique": "^1.0.5",
|
||||||
|
"@pushrocks/smartrx": "^2.0.25",
|
||||||
|
"lit": "^2.2.2"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
|
24
test/test.browser.ts
Normal file
24
test/test.browser.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
import * as deesElement from '../ts/index.js';
|
||||||
|
|
||||||
|
tap.test('should create a static element', async () => {
|
||||||
|
@deesElement.customElement('my-button')
|
||||||
|
class MyButton extends deesElement.DeesElement {
|
||||||
|
// STATIC
|
||||||
|
public static styles = [
|
||||||
|
deesElement.cssManager.defaultStyles,
|
||||||
|
deesElement.css`
|
||||||
|
.buttonClass {
|
||||||
|
background: ${deesElement.cssManager.bdTheme('blue', 'black')};
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
render() {
|
||||||
|
return deesElement.html`<div class="buttonClass">My Button</div>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -1,6 +0,0 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
|
||||||
import * as deesElement from '../ts/index';
|
|
||||||
|
|
||||||
tap.test('first test', async () => {});
|
|
||||||
|
|
||||||
tap.start();
|
|
83
ts/dees-element.classes.cssmanager.ts
Normal file
83
ts/dees-element.classes.cssmanager.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import { CSSResult, unsafeCSS } from 'lit';
|
||||||
|
import * as plugins from './dees-element.plugins.js';
|
||||||
|
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: CSSResult) {
|
||||||
|
return unsafeCSS(domtools.breakpoints.cssForTablet(contentArg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public cssForPhablet(contentArg: CSSResult) {
|
||||||
|
return unsafeCSS(domtools.breakpoints.cssForPhablet(contentArg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public cssForPhone(contentArg: CSSResult) {
|
||||||
|
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,
|
||||||
|
domtoolsArg.themeManager.goBrightBoolean ? newTriplet.brightValue : newTriplet.darkValue
|
||||||
|
);
|
||||||
|
});
|
||||||
|
returnCssVar = newTriplet.cssVarName;
|
||||||
|
}
|
||||||
|
return plugins.lit.unsafeCSS(`var(${returnCssVar}, ${darkValueArg})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
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.lit.unsafeCSS(returnString);
|
||||||
|
};
|
||||||
|
}
|
46
ts/dees-element.classes.dees-element.ts
Normal file
46
ts/dees-element.classes.dees-element.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import * as plugins from './dees-element.plugins.js';
|
||||||
|
|
||||||
|
export class DeesElement extends plugins.lit.LitElement {
|
||||||
|
// INSTANCE
|
||||||
|
@plugins.lit.property({ type: Boolean })
|
||||||
|
public goBright: boolean = false;
|
||||||
|
|
||||||
|
// domtools
|
||||||
|
public domtoolsPromise = plugins.domtools.elementBasic.setup(this);
|
||||||
|
|
||||||
|
@plugins.lit.property()
|
||||||
|
domtools?: plugins.domtools.DomTools;
|
||||||
|
|
||||||
|
private themeSubscription: plugins.smartrx.rxjs.Subscription;
|
||||||
|
|
||||||
|
private elementDomReadyDeferred = plugins.domtools.plugins.smartpromise.defer();
|
||||||
|
public elementDomReady = this.elementDomReadyDeferred.promise;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.domtoolsPromise.then((domtoolsArg) => {
|
||||||
|
this.domtools = domtoolsArg;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async connectedCallback() {
|
||||||
|
super.connectedCallback();
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
this.themeSubscription = domtools.themeManager.themeObservable.subscribe((goBrightArg) => {
|
||||||
|
this.goBright = goBrightArg;
|
||||||
|
});
|
||||||
|
this.dispatchEvent(new CustomEvent('deesElementConnected'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public firstUpdated(_changedProperties: Map<string | number | symbol, unknown>): void {
|
||||||
|
super.firstUpdated(_changedProperties);
|
||||||
|
this.elementDomReadyDeferred.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async disconnectedCallback() {
|
||||||
|
await this.domtoolsPromise;
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this.themeSubscription.unsubscribe();
|
||||||
|
this.dispatchEvent(new CustomEvent('deesElementDisconnected'));
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,19 @@
|
|||||||
import { LitElement, property } from 'lit-element';
|
// pushrocks scope
|
||||||
const litElement = {
|
import * as isounique from '@pushrocks/isounique';
|
||||||
|
import * as smartrx from '@pushrocks/smartrx';
|
||||||
|
|
||||||
|
export { isounique, smartrx };
|
||||||
|
|
||||||
|
// third party scope
|
||||||
|
import { css, unsafeCSS, LitElement } from 'lit';
|
||||||
|
import { property } from 'lit/decorators/property.js';
|
||||||
|
const lit = {
|
||||||
|
css,
|
||||||
|
unsafeCSS,
|
||||||
LitElement,
|
LitElement,
|
||||||
property
|
property,
|
||||||
};
|
};
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@designestate/dees-domtools';
|
||||||
|
|
||||||
export {
|
export { lit, domtools };
|
||||||
litElement,
|
|
||||||
domtools
|
|
||||||
};
|
|
||||||
|
39
ts/index.ts
39
ts/index.ts
@ -1,27 +1,20 @@
|
|||||||
import * as plugins from './dees-element.plugins';
|
import { CssManager } from './dees-element.classes.cssmanager.js';
|
||||||
|
|
||||||
export {
|
// lit exports
|
||||||
property,
|
export { html, TemplateResult, css, unsafeCSS, render } from 'lit';
|
||||||
html,
|
|
||||||
customElement,
|
|
||||||
TemplateResult,
|
|
||||||
internalProperty,
|
|
||||||
css,
|
|
||||||
unsafeCSS
|
|
||||||
} from 'lit-element';
|
|
||||||
|
|
||||||
export class DeesElement extends plugins.litElement.LitElement {
|
export { customElement } from 'lit/decorators/custom-element.js';
|
||||||
@plugins.litElement.property({type: Boolean})
|
|
||||||
public goBright: boolean = false;
|
|
||||||
public domtoolsPromise = plugins.domtools.elementBasic.setup(this);
|
|
||||||
|
|
||||||
public connectedCallback() {
|
export { property, state, query, queryAll, queryAsync } from 'lit/decorators.js';
|
||||||
super.connectedCallback();
|
|
||||||
this.dispatchEvent(new CustomEvent('domtools-connected'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public disconnectedCallback() {
|
// domtools exports
|
||||||
super.disconnectedCallback();
|
import * as domtools from '@designestate/dees-domtools';
|
||||||
this.dispatchEvent(new CustomEvent('domtools-disconnected'));
|
export { domtools };
|
||||||
}
|
|
||||||
}
|
// DeesElements exports
|
||||||
|
export { DeesElement } from './dees-element.classes.dees-element.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a singleton instance of CssManager
|
||||||
|
*/
|
||||||
|
export const cssManager = new CssManager();
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "es2017",
|
|
||||||
"module": "es2015",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"lib": ["es2017", "dom"],
|
|
||||||
"declaration": true,
|
|
||||||
"inlineSources": true,
|
|
||||||
"inlineSourceMap": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"outDir": "dist/",
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"experimentalDecorators": true
|
|
||||||
}
|
|
||||||
}
|
|
8
tsconfig.json
Normal file
8
tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2020",
|
||||||
|
"module": "es2020",
|
||||||
|
"moduleResolution": "node12",
|
||||||
|
"experimentalDecorators": true
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user