Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
7655fc0348 | |||
8aa5576318 | |||
1ff54b0fcd | |||
3901258272 | |||
27380d1483 | |||
e2f9991f96 | |||
133ce80b0a | |||
cf12f45c9b | |||
6cc5ec315e | |||
88810bae2c | |||
21369d8da5 | |||
a5973944ee | |||
ad3f4b31fa | |||
91b50ecde5 | |||
45fecfbde8 | |||
e3e6d06969 | |||
50ace4c236 | |||
90f68965bb | |||
6c92a9cdf8 | |||
d4e24d615a | |||
37b7dca212 | |||
7d9dc1ad65 | |||
20f06e5935 | |||
d3fa33f0cc | |||
aa91dad272 | |||
05a22599b8 | |||
bd0b279fc2 | |||
8276a5b09b | |||
a9200859ec | |||
210a0ad8a1 | |||
2756a3cb68 | |||
acf0ea3874 |
9189
package-lock.json
generated
9189
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@designestate/dees-domtools",
|
"name": "@designestate/dees-domtools",
|
||||||
"version": "1.0.23",
|
"version": "1.0.39",
|
||||||
"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",
|
||||||
@ -14,18 +14,23 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.0.22",
|
||||||
"@gitzone/tsbundle": "^1.0.69",
|
"@gitzone/tsbundle": "^1.0.72",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.43",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.2.9",
|
||||||
"@types/node": "^14.0.5",
|
"@types/node": "^14.0.23",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.2",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^4.0.12",
|
"@apiglobal/typedrequest": "^1.0.40",
|
||||||
|
"@pushrocks/lik": "^4.0.17",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
|
"@pushrocks/smartrouter": "^1.0.4",
|
||||||
"@pushrocks/smartstate": "^1.0.16",
|
"@pushrocks/smartstate": "^1.0.16",
|
||||||
"lit-element": "^2.3.1"
|
"@pushrocks/webrequest": "^2.0.10",
|
||||||
|
"@pushrocks/websetup": "^2.0.18",
|
||||||
|
"lit-element": "^2.3.1",
|
||||||
|
"sweet-scroll": "^4.0.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@ -38,5 +43,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
21
readme.md
21
readme.md
@ -8,13 +8,20 @@ tools to simplify complex css structures
|
|||||||
* [docs (typedoc)](https://designestate.gitlab.io/dees-domtools/)
|
* [docs (typedoc)](https://designestate.gitlab.io/dees-domtools/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/designestate/dees-domtools/commits/master)
|
|
||||||
[](https://gitlab.com/designestate/dees-domtools/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@designestate/dees-domtools)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@designestate/dees-domtools)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
9
test/test.browser.ts
Normal file
9
test/test.browser.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
import * as domtools from '../ts/index';
|
||||||
|
|
||||||
|
tap.test('first test', async () => {
|
||||||
|
const domtoolsInstance = await domtools.DomTools.setupDomTools();
|
||||||
|
expect(domtoolsInstance).to.be.instanceof(domtools.DomTools);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -1,8 +0,0 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
|
||||||
import * as deesCsstools from '../ts/index';
|
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
|
||||||
console.log('hi');
|
|
||||||
});
|
|
||||||
|
|
||||||
tap.start();
|
|
@ -1,21 +1,24 @@
|
|||||||
import { DomTools } from './domtools.classes.domtools';
|
import { DomTools } from './domtools.classes.domtools';
|
||||||
|
|
||||||
export const desktop = 1240;
|
export const desktop = 1240;
|
||||||
export const tablet = 700;
|
export const tablet = 1024;
|
||||||
export const phablet = 500;
|
export const phablet = 600;
|
||||||
export const phone = 340;
|
export const phone = 400;
|
||||||
|
|
||||||
export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone';
|
export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone';
|
||||||
|
|
||||||
export const getEnvironment = (): TViewport => {
|
export const getEnvironment = (): TViewport => {
|
||||||
if (globalThis.deesDomTools && globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport) {
|
if (
|
||||||
|
globalThis.deesDomTools &&
|
||||||
|
globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport
|
||||||
|
) {
|
||||||
return globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport;
|
return globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport;
|
||||||
} else {
|
} else {
|
||||||
return 'native';
|
return 'native';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const cssForTablet = async (contentArg) => {
|
export const cssForTablet = (contentArg) => {
|
||||||
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
||||||
return `
|
return `
|
||||||
@media (max-width: ${tablet}px) {
|
@media (max-width: ${tablet}px) {
|
||||||
@ -35,7 +38,7 @@ export const cssForTablet = async (contentArg) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const cssForPhablet = async (contentArg) => {
|
export const cssForPhablet = (contentArg) => {
|
||||||
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
||||||
return `
|
return `
|
||||||
@media (max-width: ${phablet}px) {
|
@media (max-width: ${phablet}px) {
|
||||||
@ -51,7 +54,7 @@ export const cssForPhablet = async (contentArg) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const cssForPhone = async (contentArg) => {
|
export const cssForPhone = (contentArg) => {
|
||||||
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
||||||
return `
|
return `
|
||||||
@media (max-width: ${phone}px) {
|
@media (max-width: ${phone}px) {
|
||||||
|
@ -3,11 +3,19 @@ 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';
|
import { TViewport } from './domtools.breakpoints';
|
||||||
|
|
||||||
|
import { Scroller } from './domtools.classes.scroller';
|
||||||
|
|
||||||
export interface IDomToolsState {
|
export interface IDomToolsState {
|
||||||
virtualViewport: TViewport;
|
virtualViewport: TViewport;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DomTools {
|
export class DomTools {
|
||||||
|
// ======
|
||||||
|
// STATIC
|
||||||
|
// ======
|
||||||
|
/**
|
||||||
|
* setups domtools
|
||||||
|
*/
|
||||||
public static async setupDomTools() {
|
public static async setupDomTools() {
|
||||||
let domToolsInstance: DomTools;
|
let domToolsInstance: DomTools;
|
||||||
if (!globalThis.deesDomTools) {
|
if (!globalThis.deesDomTools) {
|
||||||
@ -30,48 +38,64 @@ export class DomTools {
|
|||||||
return domToolsInstance;
|
return domToolsInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public smartstate = new plugins.smartstate.Smartstate();
|
public static getDomToolsSync() {
|
||||||
public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', {
|
const globalDomTools: DomTools = globalThis.deesDomTools;
|
||||||
virtualViewport: 'native'
|
if (!globalDomTools) {
|
||||||
});
|
throw new Error('You tried to access domtools synchronouly too early');
|
||||||
|
}
|
||||||
public actionSetVirtualViewport = this.domToolsStatePart.createAction<TViewport>(async (statePart, payload) => {
|
return globalThis.deesDomTools;
|
||||||
const currentState = statePart.getState();
|
}
|
||||||
currentState.virtualViewport = payload;
|
|
||||||
return currentState;
|
|
||||||
});
|
|
||||||
|
|
||||||
public domToolsReady = plugins.smartpromise.defer();
|
|
||||||
public domReady = plugins.smartpromise.defer();
|
|
||||||
public globalStylesReady = plugins.smartpromise.defer();
|
|
||||||
|
|
||||||
|
// ========
|
||||||
|
// INSTANCE
|
||||||
|
// ========
|
||||||
// elements
|
// elements
|
||||||
public elements: {
|
public elements: {
|
||||||
headElement: HTMLElement;
|
headElement: HTMLElement;
|
||||||
bodyElement: HTMLElement;
|
bodyElement: HTMLElement;
|
||||||
} = {
|
} = {
|
||||||
headElement: null,
|
headElement: null,
|
||||||
bodyElement: null
|
bodyElement: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
public smartstate = new plugins.smartstate.Smartstate();
|
||||||
|
public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', {
|
||||||
}
|
virtualViewport: 'native',
|
||||||
|
});
|
||||||
|
|
||||||
public async setGlobalStyles(stylesText: string) {
|
public router = new plugins.smartrouter.SmartRouter({
|
||||||
await this.domReady.promise;
|
debug: false,
|
||||||
const styleElement = document.createElement('style');
|
});
|
||||||
styleElement.type = 'text/css';
|
|
||||||
styleElement.appendChild(document.createTextNode(stylesText));
|
public scroller: plugins.SweetScroll;
|
||||||
this.elements.headElement.appendChild(styleElement);
|
|
||||||
|
private actionSetVirtualViewport = this.domToolsStatePart.createAction<TViewport>(
|
||||||
|
async (statePart, payload) => {
|
||||||
|
const currentState = statePart.getState();
|
||||||
|
currentState.virtualViewport = payload;
|
||||||
|
return currentState;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
public domToolsReady = plugins.smartpromise.defer();
|
||||||
|
public domReady = plugins.smartpromise.defer();
|
||||||
|
public globalStylesReady = plugins.smartpromise.defer();
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
// lets care about third party stuff
|
||||||
|
this.domToolsReady.promise.then(() => {
|
||||||
|
this.scroller = new plugins.SweetScroll({
|
||||||
|
/* some options */
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private runOnceTrackerStringMap = new Stringmap();
|
private runOnceTrackerStringMap = new Stringmap();
|
||||||
private runOnceResultMap = new FastMap();
|
private runOnceResultMap = new FastMap();
|
||||||
/**
|
/**
|
||||||
* run a function once and always get the Promise of the first execution
|
* run a function once and always get the Promise of the first execution
|
||||||
* @param identifierArg
|
* @param identifierArg the indentifier arg identifies functions. functions with the same identifier are considered equal
|
||||||
* @param funcArg
|
* @param funcArg the actual func arg to run
|
||||||
*/
|
*/
|
||||||
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`;
|
||||||
@ -83,7 +107,7 @@ export class DomTools {
|
|||||||
this.runOnceTrackerStringMap.removeString(runningId);
|
this.runOnceTrackerStringMap.removeString(runningId);
|
||||||
}
|
}
|
||||||
return await this.runOnceTrackerStringMap.registerUntilTrue(
|
return await this.runOnceTrackerStringMap.registerUntilTrue(
|
||||||
stringMap => {
|
(stringMap) => {
|
||||||
return !stringMap.includes(runningId);
|
return !stringMap.includes(runningId);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
@ -92,7 +116,22 @@ export class DomTools {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
setVirtualViewport(environmentArg: TViewport) {
|
// setStuff
|
||||||
|
|
||||||
|
public async setGlobalStyles(stylesText: string) {
|
||||||
|
await this.domReady.promise;
|
||||||
|
const styleElement = document.createElement('style');
|
||||||
|
styleElement.type = 'text/css';
|
||||||
|
styleElement.appendChild(document.createTextNode(stylesText));
|
||||||
|
this.elements.headElement.appendChild(styleElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setVirtualViewport(environmentArg: TViewport) {
|
||||||
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
|
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async setWebsiteInfo(optionsArg: plugins.websetup.IWebSetupConstructorOptions) {
|
||||||
|
const websetup = new plugins.websetup.WebSetup(optionsArg);
|
||||||
|
await websetup.setup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
import * as plugins from './domtools.plugins';
|
|
5
ts/domtools.classes.scroller.ts
Normal file
5
ts/domtools.classes.scroller.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import * as plugins from './domtools.plugins';
|
||||||
|
|
||||||
|
export class Scroller {
|
||||||
|
// TODO: move sweet scroll over to here;
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
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 *
|
returnString += ` calc((100%/${amountOfColumnsArg}) - (${
|
||||||
(amountOfColumnsArg - 1)}px/${amountOfColumnsArg}))`;
|
gapSizeArg * (amountOfColumnsArg - 1)
|
||||||
|
}px/${amountOfColumnsArg}))`;
|
||||||
}
|
}
|
||||||
return returnString;
|
return returnString;
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,18 @@
|
|||||||
|
// api glbal scope
|
||||||
|
import * as typedrequest from '@apiglobal/typedrequest';
|
||||||
|
|
||||||
|
export { typedrequest };
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import * as smartrouter from '@pushrocks/smartrouter';
|
||||||
import * as smartstate from '@pushrocks/smartstate';
|
import * as smartstate from '@pushrocks/smartstate';
|
||||||
|
import * as webrequest from '@pushrocks/webrequest';
|
||||||
|
import * as websetup from '@pushrocks/websetup';
|
||||||
|
|
||||||
export { smartpromise, smartstate };
|
export { smartpromise, smartrouter, smartstate, webrequest, websetup };
|
||||||
|
|
||||||
|
// third party scope
|
||||||
|
import SweetScroll from 'sweet-scroll';
|
||||||
|
|
||||||
|
export { SweetScroll };
|
||||||
|
@ -6,3 +6,10 @@ import * as css from './domtools.css';
|
|||||||
|
|
||||||
export { css, breakpoints, elementBasic };
|
export { css, breakpoints, elementBasic };
|
||||||
export { DomTools } from './domtools.classes.domtools';
|
export { DomTools } from './domtools.classes.domtools';
|
||||||
|
export { TypedRequest } from '@apiglobal/typedrequest';
|
||||||
|
|
||||||
|
import * as allPlugins from './domtools.plugins';
|
||||||
|
|
||||||
|
export const plugins = {
|
||||||
|
smartpromise: allPlugins.smartpromise,
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user