Compare commits

...

16 Commits

Author SHA1 Message Date
bd0b279fc2 1.0.26 2020-06-01 12:30:22 +00:00
8276a5b09b fix(core): update 2020-06-01 12:30:21 +00:00
a9200859ec 1.0.25 2020-05-27 23:53:32 +00:00
210a0ad8a1 fix(core): update 2020-05-27 23:53:32 +00:00
2756a3cb68 1.0.24 2020-05-27 22:41:09 +00:00
acf0ea3874 fix(core): update 2020-05-27 22:41:08 +00:00
284d2be0e3 1.0.23 2020-05-27 22:30:04 +00:00
dfb9175613 fix(core): update 2020-05-27 22:30:03 +00:00
16a213f536 1.0.22 2020-05-27 22:28:52 +00:00
9869b0c6aa fix(core): update 2020-05-27 22:28:52 +00:00
e63cb9669b 1.0.21 2020-05-27 22:06:06 +00:00
06766c6895 fix(core): update 2020-05-27 22:06:05 +00:00
48f1b02f0b 1.0.20 2020-05-27 21:59:28 +00:00
f41550fa22 fix(core): update 2020-05-27 21:59:28 +00:00
ac18ed0684 1.0.19 2020-05-27 21:15:39 +00:00
0ed59e850e fix(core): update 2020-05-27 21:15:38 +00:00
11 changed files with 100 additions and 55 deletions

54
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@designestate/dees-domtools", "name": "@designestate/dees-domtools",
"version": "1.0.18", "version": "1.0.26",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1072,16 +1072,15 @@
} }
}, },
"@pushrocks/lik": { "@pushrocks/lik": {
"version": "4.0.10", "version": "4.0.13",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-4.0.10.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-4.0.13.tgz",
"integrity": "sha512-qlVVIWo/Ysp/cyUyHi2mgtFyT0E9xXLCpewBAb7TrwnuRKrSMrmE4YsqPsGOhBxqziSEOPaXZmWaMLwKqjvQiQ==", "integrity": "sha512-Nde8rq1DjaDCREKlGGY/zS8g+eFu4zSU2jrbO4DdtYD+9oiauBMz2jzao3fr8401XpNW1Ex8T8FPdjUW8lUMow==",
"requires": { "requires": {
"@pushrocks/smartdelay": "^2.0.9", "@pushrocks/smartdelay": "^2.0.9",
"@pushrocks/smartmatch": "^1.0.7", "@pushrocks/smartmatch": "^1.0.7",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrx": "^2.0.12", "@pushrocks/smartrx": "^2.0.15",
"@pushrocks/smarttime": "^3.0.18", "@pushrocks/smarttime": "^3.0.18",
"@pushrocks/smartunique": "^3.0.3",
"@types/minimatch": "^3.0.3", "@types/minimatch": "^3.0.3",
"symbol-tree": "^3.2.4" "symbol-tree": "^3.2.4"
}, },
@ -1095,11 +1094,11 @@
} }
}, },
"@pushrocks/smartrx": { "@pushrocks/smartrx": {
"version": "2.0.12", "version": "2.0.15",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrx/-/smartrx-2.0.12.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrx/-/smartrx-2.0.15.tgz",
"integrity": "sha512-1iH5cn3Hvb8cnPlmeBL3oOZ/hkvuEQcQ6dykFeDMJkJQ0zrT5iSkzq8EA4fCmIe12aeMkL+38TOC79CCySb0Hg==", "integrity": "sha512-bvxyO19sUgWj7S/WflVO7QVYggTUXoM4rCYn+Akid844CC5zoSzIRx9Egm2xeMD6y4WbBbFWpHr67L7nEYxGWQ==",
"requires": { "requires": {
"@pushrocks/lik": "^4.0.8", "@pushrocks/lik": "^4.0.11",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
"rxjs": "^6.5.5" "rxjs": "^6.5.5"
} }
@ -1383,13 +1382,26 @@
} }
}, },
"@pushrocks/smartstate": { "@pushrocks/smartstate": {
"version": "1.0.15", "version": "1.0.16",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstate/-/smartstate-1.0.15.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstate/-/smartstate-1.0.16.tgz",
"integrity": "sha512-LuqA8othfyd6Ne/DaFt42K/mS7MUa9twbsFboOuXSUi/S6DNWy7Z62EHIsftrVHtgrenBeF+JZaJ8lLCVMHcng==", "integrity": "sha512-RUdeKuM2N5S3su9WEX2XoSE0VV12vMyR4vh4h2gV+uS4Syu4H13ntoN2MQfGh63JHkviICELZ0u+XqRtNvAO4g==",
"requires": { "requires": {
"@pushrocks/lik": "^4.0.0", "@pushrocks/lik": "^4.0.12",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrx": "^2.0.15",
"rxjs": "^6.5.5" "rxjs": "^6.5.5"
},
"dependencies": {
"@pushrocks/smartrx": {
"version": "2.0.15",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrx/-/smartrx-2.0.15.tgz",
"integrity": "sha512-bvxyO19sUgWj7S/WflVO7QVYggTUXoM4rCYn+Akid844CC5zoSzIRx9Egm2xeMD6y4WbBbFWpHr67L7nEYxGWQ==",
"requires": {
"@pushrocks/lik": "^4.0.11",
"@pushrocks/smartpromise": "^3.0.6",
"rxjs": "^6.5.5"
}
}
} }
}, },
"@pushrocks/smarttime": { "@pushrocks/smarttime": {
@ -1410,6 +1422,7 @@
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartunique/-/smartunique-3.0.3.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartunique/-/smartunique-3.0.3.tgz",
"integrity": "sha512-f+c3s2WzzjASoRHyYTLU0kHDVWREg4sZVdi5L42bTA3CTUWNrcGUC62h4wP4U4BiPl3bopTr3LPhClZHJ738oA==", "integrity": "sha512-f+c3s2WzzjASoRHyYTLU0kHDVWREg4sZVdi5L42bTA3CTUWNrcGUC62h4wP4U4BiPl3bopTr3LPhClZHJ738oA==",
"dev": true,
"requires": { "requires": {
"@types/shortid": "0.0.29", "@types/shortid": "0.0.29",
"@types/uuid": "^7.0.0", "@types/uuid": "^7.0.0",
@ -1630,7 +1643,8 @@
"@types/shortid": { "@types/shortid": {
"version": "0.0.29", "version": "0.0.29",
"resolved": "https://verdaccio.lossless.one/@types%2fshortid/-/shortid-0.0.29.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fshortid/-/shortid-0.0.29.tgz",
"integrity": "sha1-gJPuBBam4r8qpjOBCRFLP7/6Dps=" "integrity": "sha1-gJPuBBam4r8qpjOBCRFLP7/6Dps=",
"dev": true
}, },
"@types/through2": { "@types/through2": {
"version": "2.0.36", "version": "2.0.36",
@ -1661,7 +1675,8 @@
"@types/uuid": { "@types/uuid": {
"version": "7.0.4", "version": "7.0.4",
"resolved": "https://verdaccio.lossless.one/@types%2fuuid/-/uuid-7.0.4.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fuuid/-/uuid-7.0.4.tgz",
"integrity": "sha512-WGZCqBZZ0mXN2RxvLHL6/7RCu+OWs28jgQMP04LWfpyJlQUMTR6YU9CNJAKDgbw+EV/u687INXuLUc7FuML/4g==" "integrity": "sha512-WGZCqBZZ0mXN2RxvLHL6/7RCu+OWs28jgQMP04LWfpyJlQUMTR6YU9CNJAKDgbw+EV/u687INXuLUc7FuML/4g==",
"dev": true
}, },
"@types/which": { "@types/which": {
"version": "1.3.2", "version": "1.3.2",
@ -2621,7 +2636,8 @@
"nanoid": { "nanoid": {
"version": "2.1.11", "version": "2.1.11",
"resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-2.1.11.tgz", "resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-2.1.11.tgz",
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==" "integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==",
"dev": true
}, },
"no-case": { "no-case": {
"version": "2.3.2", "version": "2.3.2",
@ -3044,6 +3060,7 @@
"version": "2.2.15", "version": "2.2.15",
"resolved": "https://verdaccio.lossless.one/shortid/-/shortid-2.2.15.tgz", "resolved": "https://verdaccio.lossless.one/shortid/-/shortid-2.2.15.tgz",
"integrity": "sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==", "integrity": "sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==",
"dev": true,
"requires": { "requires": {
"nanoid": "^2.1.0" "nanoid": "^2.1.0"
} }
@ -3329,7 +3346,8 @@
"uuid": { "uuid": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://verdaccio.lossless.one/uuid/-/uuid-7.0.3.tgz", "resolved": "https://verdaccio.lossless.one/uuid/-/uuid-7.0.3.tgz",
"integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==" "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==",
"dev": true
}, },
"wcwidth": { "wcwidth": {
"version": "1.0.1", "version": "1.0.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "@designestate/dees-domtools", "name": "@designestate/dees-domtools",
"version": "1.0.18", "version": "1.0.26",
"private": false, "private": false,
"description": "tools to simplify complex css structures", "description": "tools to simplify complex css structures",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -22,9 +22,9 @@
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^4.0.10", "@pushrocks/lik": "^4.0.13",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartstate": "^1.0.15", "@pushrocks/smartstate": "^1.0.16",
"lit-element": "^2.3.1" "lit-element": "^2.3.1"
}, },
"files": [ "files": [

View File

@ -15,6 +15,8 @@ tools to simplify complex css structures
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) [![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
[![JavaScript Style Guide](https://badgen.net/bundlephobia/minzip/@material-ui/core)](https://prettier.io/)
## Usage ## Usage

View File

@ -1,24 +1,32 @@
import { DomTools } from './domtools.classes.domtools';
export const desktop = 1240; export const desktop = 1240;
export const tablet = 700; export const tablet = 700;
export const phablet = 500; export const phablet = 500;
export const phone = 340; export const phone = 400;
export type TEnvironment = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone'; export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone';
let environment: TEnvironment = 'native'; export const getEnvironment = (): TViewport => {
if (globalThis.deesDomTools && globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport) {
export const setEnvironment = envArg => { return globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport;
environment = envArg; } else {
return 'native';
}
}; };
export const cssForTablet = (contentArg) => { export const cssForTablet = (contentArg) => {
if (environment === 'native' || environment === 'desktop') { if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
return ` return `
@media (max-width: ${tablet}px) { @media (max-width: ${tablet}px) {
${contentArg} ${contentArg}
} }
`; `;
} else if (environment === 'tablet' || environment === 'phablet' || environment === 'phone') { } else if (
getEnvironment() === 'tablet' ||
getEnvironment() === 'phablet' ||
getEnvironment() === 'phone'
) {
return ` return `
@media (min-width: 0px) { @media (min-width: 0px) {
${contentArg} ${contentArg}
@ -28,13 +36,13 @@ export const cssForTablet = (contentArg) => {
}; };
export const cssForPhablet = (contentArg) => { export const cssForPhablet = (contentArg) => {
if (environment === 'native' || environment === 'desktop') { if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
return ` return `
@media (max-width: ${phablet}px) { @media (max-width: ${phablet}px) {
${contentArg} ${contentArg}
} }
`; `;
} else if (environment === 'phablet' || environment === 'phone') { } else if (getEnvironment() === 'phablet' || getEnvironment() === 'phone') {
return ` return `
@media (min-width: 0px) { @media (min-width: 0px) {
${contentArg} ${contentArg}
@ -44,13 +52,13 @@ export const cssForPhablet = (contentArg) => {
}; };
export const cssForPhone = (contentArg) => { export const cssForPhone = (contentArg) => {
if (environment === 'native' || environment === 'desktop') { if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
return ` return `
@media (max-width: ${phone}px) { @media (max-width: ${phone}px) {
${contentArg} ${contentArg}
} }
`; `;
} else if (environment === 'phone') { } else if (getEnvironment() === 'phone') {
return ` return `
@media (min-width: 0px) { @media (min-width: 0px) {
${contentArg} ${contentArg}

View File

@ -1,6 +1,11 @@
import * as plugins from './domtools.plugins'; import * as plugins from './domtools.plugins';
import { Stringmap } from '@pushrocks/lik/dist_ts/lik.stringmap'; import { Stringmap } from '@pushrocks/lik/dist_ts/lik.stringmap';
import { FastMap } from '@pushrocks/lik/dist_ts/lik.fastmap'; import { FastMap } from '@pushrocks/lik/dist_ts/lik.fastmap';
import { TViewport } from './domtools.breakpoints';
export interface IDomToolsState {
virtualViewport: TViewport;
}
export class DomTools { export class DomTools {
public static async setupDomTools() { public static async setupDomTools() {
@ -26,6 +31,15 @@ export class DomTools {
} }
public smartstate = new plugins.smartstate.Smartstate(); public smartstate = new plugins.smartstate.Smartstate();
public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', {
virtualViewport: 'native'
});
public actionSetVirtualViewport = this.domToolsStatePart.createAction<TViewport>(async (statePart, payload) => {
const currentState = statePart.getState();
currentState.virtualViewport = payload;
return currentState;
});
public domToolsReady = plugins.smartpromise.defer(); public domToolsReady = plugins.smartpromise.defer();
public domReady = plugins.smartpromise.defer(); public domReady = plugins.smartpromise.defer();
@ -37,9 +51,13 @@ export class DomTools {
bodyElement: HTMLElement; bodyElement: HTMLElement;
} = { } = {
headElement: null, headElement: null,
bodyElement: null, bodyElement: null
}; };
constructor() {
}
public async setGlobalStyles(stylesText: string) { public async setGlobalStyles(stylesText: string) {
await this.domReady.promise; await this.domReady.promise;
const styleElement = document.createElement('style'); const styleElement = document.createElement('style');
@ -57,18 +75,24 @@ export class DomTools {
*/ */
public async runOnce<T>(identifierArg: string, funcArg: () => Promise<T>) { public async runOnce<T>(identifierArg: string, funcArg: () => Promise<T>) {
const runningId = `${identifierArg}+runningCheck`; const runningId = `${identifierArg}+runningCheck`;
if(!this.runOnceTrackerStringMap.checkString(identifierArg)) { if (!this.runOnceTrackerStringMap.checkString(identifierArg)) {
this.runOnceTrackerStringMap.addString(identifierArg); this.runOnceTrackerStringMap.addString(identifierArg);
this.runOnceTrackerStringMap.addString(runningId); this.runOnceTrackerStringMap.addString(runningId);
const result = await funcArg(); const result = await funcArg();
this.runOnceResultMap.addToMap(identifierArg, result); this.runOnceResultMap.addToMap(identifierArg, result);
this.runOnceTrackerStringMap.removeString(runningId); this.runOnceTrackerStringMap.removeString(runningId);
} }
return await this.runOnceTrackerStringMap.registerUntilTrue(stringMap => { return await this.runOnceTrackerStringMap.registerUntilTrue(
return !stringMap.includes(runningId); stringMap => {
}, () => { return !stringMap.includes(runningId);
return this.runOnceResultMap.getByKey(identifierArg); },
}); () => {
return this.runOnceResultMap.getByKey(identifierArg);
}
);
} }
} setVirtualViewport(environmentArg: TViewport) {
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
}
}

View File

@ -1 +1 @@
import * as plugins from './domtools.plugins'; import * as plugins from './domtools.plugins';

View File

@ -3,4 +3,4 @@ export interface IDeesColorSet {
secondaryAccent: string; secondaryAccent: string;
primaryBackground: string; primaryBackground: string;
secondaryBackground: string; secondaryBackground: string;
} }

View File

@ -1,7 +1,8 @@
export const cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number) => { export const cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number) => {
let returnString = ``; let returnString = ``;
for (let i = 0; i < amountOfColumnsArg; i++) { for (let i = 0; i < amountOfColumnsArg; i++) {
returnString += ` calc((100%/${amountOfColumnsArg}) - (${gapSizeArg * (amountOfColumnsArg - 1)}px/${amountOfColumnsArg}))`; returnString += ` calc((100%/${amountOfColumnsArg}) - (${gapSizeArg *
(amountOfColumnsArg - 1)}px/${amountOfColumnsArg}))`;
} }
return returnString; return returnString;
}; };

View File

@ -1,7 +1,6 @@
import * as plugins from './domtools.plugins'; import * as plugins from './domtools.plugins';
import { DomTools } from './domtools.classes.domtools'; import { DomTools } from './domtools.classes.domtools';
import { html } from 'lit-element'; import { html } from 'lit-element';
export const styles = html` export const styles = html`
<style> <style>
@ -12,7 +11,6 @@ export const styles = html`
</style> </style>
`; `;
/** /**
* a basic setup for elements * a basic setup for elements
* makes sure everything is in check * makes sure everything is in check

View File

@ -2,7 +2,4 @@
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartstate from '@pushrocks/smartstate'; import * as smartstate from '@pushrocks/smartstate';
export { export { smartpromise, smartstate };
smartpromise,
smartstate
};

View File

@ -4,8 +4,5 @@ import * as elementBasic from './domtools.elementbasic';
import * as breakpoints from './domtools.breakpoints'; import * as breakpoints from './domtools.breakpoints';
import * as css from './domtools.css'; import * as css from './domtools.css';
export { export { css, breakpoints, elementBasic };
css, export { DomTools } from './domtools.classes.domtools';
breakpoints,
elementBasic
};