Compare commits

...

73 Commits

Author SHA1 Message Date
7655fc0348 1.0.39 2020-07-27 17:11:01 +00:00
8aa5576318 fix(core): update 2020-07-27 17:11:00 +00:00
1ff54b0fcd 1.0.38 2020-07-15 18:58:40 +00:00
3901258272 fix(core): update 2020-07-15 18:58:40 +00:00
27380d1483 1.0.37 2020-07-15 18:12:27 +00:00
e2f9991f96 fix(core): update 2020-07-15 18:12:27 +00:00
133ce80b0a 1.0.36 2020-06-30 14:08:35 +00:00
cf12f45c9b fix(core): update 2020-06-30 14:08:35 +00:00
6cc5ec315e 1.0.35 2020-06-28 21:26:57 +00:00
88810bae2c fix(core): update 2020-06-28 21:26:57 +00:00
21369d8da5 1.0.34 2020-06-28 18:03:23 +00:00
a5973944ee fix(core): update 2020-06-28 18:03:22 +00:00
ad3f4b31fa 1.0.33 2020-06-28 17:40:03 +00:00
91b50ecde5 fix(core): update 2020-06-28 17:40:03 +00:00
45fecfbde8 1.0.32 2020-06-28 16:59:15 +00:00
e3e6d06969 fix(core): update 2020-06-28 16:59:14 +00:00
50ace4c236 1.0.31 2020-06-28 16:42:31 +00:00
90f68965bb fix(core): update 2020-06-28 16:42:30 +00:00
6c92a9cdf8 1.0.30 2020-06-28 15:49:47 +00:00
d4e24d615a fix(core): update 2020-06-28 15:49:46 +00:00
37b7dca212 1.0.29 2020-06-26 01:39:10 +00:00
7d9dc1ad65 fix(core): update 2020-06-26 01:39:10 +00:00
20f06e5935 1.0.28 2020-06-03 10:34:10 +00:00
d3fa33f0cc fix(core): update 2020-06-03 10:34:09 +00:00
aa91dad272 1.0.27 2020-06-03 09:07:32 +00:00
05a22599b8 fix(core): update 2020-06-03 09:07:31 +00:00
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
fb36c641a9 1.0.18 2020-05-27 18:59:45 +00:00
ae74e0b4f2 fix(core): update 2020-05-27 18:59:44 +00:00
d2a330e5d9 1.0.17 2020-05-25 22:14:38 +00:00
f40287fbb6 fix(core): update 2020-05-25 22:14:37 +00:00
e27bd8a53f 1.0.16 2020-05-25 16:22:05 +00:00
d6fc173a5b fix(core): update 2020-05-25 16:22:05 +00:00
52c245d655 1.0.15 2020-05-25 16:12:00 +00:00
c2e0c0ab19 fix(core): update 2020-05-25 16:11:59 +00:00
455d68338b 1.0.14 2020-05-25 15:57:47 +00:00
710e99a69a fix(core): update 2020-05-25 15:57:47 +00:00
e3939865aa 1.0.13 2020-05-24 19:56:46 +00:00
ba20508642 fix(core): update 2020-05-24 19:56:45 +00:00
bef4ea7bed 1.0.12 2020-05-24 18:54:10 +00:00
17a8151b2f fix(core): update 2020-05-24 18:54:10 +00:00
5aee15a23b 1.0.11 2020-05-23 17:18:15 +00:00
38d78b4e12 1.0.10 2020-05-23 17:13:10 +00:00
ec36a516c0 fix(core): update 2020-05-23 17:13:09 +00:00
1c844d35ca 1.0.9 2020-05-23 16:55:37 +00:00
ecb387f59e fix(core): update 2020-05-23 16:55:36 +00:00
9b3c92fef5 1.0.8 2020-05-23 16:43:37 +00:00
74cf94a69e fix(core): update 2020-05-23 16:43:36 +00:00
9f76d4e920 1.0.7 2020-05-23 16:36:30 +00:00
082ef21078 fix(core): update 2020-05-23 16:36:29 +00:00
4db0e6f5fc 1.0.6 2020-05-23 15:44:58 +00:00
40b8c5010d fix(core): update 2020-05-23 15:44:58 +00:00
16297dc630 1.0.5 2020-05-23 15:40:09 +00:00
7c3d131b46 fix(core): update 2020-05-23 15:40:08 +00:00
2032df467e 1.0.4 2020-05-23 15:02:10 +00:00
21bcd390d6 fix(core): update 2020-05-23 15:02:09 +00:00
5f4ff8f6a2 1.0.3 2020-05-23 15:00:01 +00:00
9782077fb9 fix(core): update 2020-05-23 15:00:01 +00:00
15 changed files with 10224 additions and 158 deletions

View File

@ -4,9 +4,9 @@
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "designestate", "gitscope": "designestate",
"gitrepo": "dees-csstools", "gitrepo": "dees-domtools",
"shortDescription": "tools to simplify complex css structures", "shortDescription": "tools to simplify complex css structures",
"npmPackagename": "@designestate/dees-csstools", "npmPackagename": "@designestate/dees-domtools",
"license": "MIT", "license": "MIT",
"projectDomain": "design.estate" "projectDomain": "design.estate"
} }

9989
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@designestate/dees-csstools", "name": "@designestate/dees-domtools",
"version": "1.0.2", "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",
@ -8,19 +8,30 @@
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/ --web)",
"build": "(tsbuild)", "build": "(tsbuild --web && tsbundle npm)",
"format": "(gitzone format)" "format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.15", "@gitzone/tsbundle": "^1.0.72",
"@pushrocks/tapbundle": "^3.0.7", "@gitzone/tstest": "^1.0.43",
"@types/node": "^10.11.7", "@pushrocks/tapbundle": "^3.2.9",
"tslint": "^5.11.0", "@types/node": "^14.0.23",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": {}, "dependencies": {
"@apiglobal/typedrequest": "^1.0.40",
"@pushrocks/lik": "^4.0.17",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrouter": "^1.0.4",
"@pushrocks/smartstate": "^1.0.16",
"@pushrocks/webrequest": "^2.0.10",
"@pushrocks/websetup": "^2.0.18",
"lit-element": "^2.3.1",
"sweet-scroll": "^4.0.0"
},
"files": [ "files": [
"ts/**/*", "ts/**/*",
"ts_web/**/*", "ts_web/**/*",
@ -32,5 +43,8 @@
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
],
"browserslist": [
"last 1 chrome versions"
] ]
} }

View File

@ -1,20 +1,27 @@
# @designestate/dees-csstools # @designestate/dees-domtools
tools to simplify complex css structures tools to simplify complex css structures
## Availabililty and Links ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@designestate/dees-csstools) * [npmjs.org (npm package)](https://www.npmjs.com/package/@designestate/dees-domtools)
* [gitlab.com (source)](https://gitlab.com/designestate/dees-csstools) * [gitlab.com (source)](https://gitlab.com/designestate/dees-domtools)
* [github.com (source mirror)](https://github.com/designestate/dees-csstools) * [github.com (source mirror)](https://github.com/designestate/dees-domtools)
* [docs (typedoc)](https://designestate.gitlab.io/dees-csstools/) * [docs (typedoc)](https://designestate.gitlab.io/dees-domtools/)
## Status for master ## Status for master
[![pipeline status](https://gitlab.com/designestate/dees-csstools/badges/master/pipeline.svg)](https://gitlab.com/designestate/dees-csstools/commits/master)
[![coverage report](https://gitlab.com/designestate/dees-csstools/badges/master/coverage.svg)](https://gitlab.com/designestate/dees-csstools/commits/master) Status Category | Status Badge
[![npm downloads per month](https://img.shields.io/npm/dm/@designestate/dees-csstools.svg)](https://www.npmjs.com/package/@designestate/dees-csstools) -- | --
[![Known Vulnerabilities](https://snyk.io/test/npm/@designestate/dees-csstools/badge.svg)](https://snyk.io/test/npm/@designestate/dees-csstools) GitLab Pipelines | [![pipeline status](https://gitlab.com/designestate/dees-domtools/badges/master/pipeline.svg)](https://lossless.cloud)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/designestate/dees-domtools/badges/master/coverage.svg)](https://lossless.cloud)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) npm | [![npm downloads per month](https://badgen.net/npm/dy/@designestate/dees-domtools)](https://lossless.cloud)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/designestate/dees-domtools)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@designestate/dees-domtools)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@designestate/dees-domtools)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@designestate/dees-domtools)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## Usage

9
test/test.browser.ts Normal file
View 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();

View File

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

View File

@ -1,2 +0,0 @@
const removeme = {};
export { removeme };

View File

@ -0,0 +1,71 @@
import { DomTools } from './domtools.classes.domtools';
export const desktop = 1240;
export const tablet = 1024;
export const phablet = 600;
export const phone = 400;
export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone';
export const getEnvironment = (): TViewport => {
if (
globalThis.deesDomTools &&
globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport
) {
return globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport;
} else {
return 'native';
}
};
export const cssForTablet = (contentArg) => {
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
return `
@media (max-width: ${tablet}px) {
${contentArg}
}
`;
} else if (
getEnvironment() === 'tablet' ||
getEnvironment() === 'phablet' ||
getEnvironment() === 'phone'
) {
return `
@media (min-width: 0px) {
${contentArg}
}
`;
}
};
export const cssForPhablet = (contentArg) => {
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
return `
@media (max-width: ${phablet}px) {
${contentArg}
}
`;
} else if (getEnvironment() === 'phablet' || getEnvironment() === 'phone') {
return `
@media (min-width: 0px) {
${contentArg}
}
`;
}
};
export const cssForPhone = (contentArg) => {
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
return `
@media (max-width: ${phone}px) {
${contentArg}
}
`;
} else if (getEnvironment() === 'phone') {
return `
@media (min-width: 0px) {
${contentArg}
}
`;
}
};

View File

@ -0,0 +1,137 @@
import * as plugins from './domtools.plugins';
import { Stringmap } from '@pushrocks/lik/dist_ts/lik.stringmap';
import { FastMap } from '@pushrocks/lik/dist_ts/lik.fastmap';
import { TViewport } from './domtools.breakpoints';
import { Scroller } from './domtools.classes.scroller';
export interface IDomToolsState {
virtualViewport: TViewport;
}
export class DomTools {
// ======
// STATIC
// ======
/**
* setups domtools
*/
public static async setupDomTools() {
let domToolsInstance: DomTools;
if (!globalThis.deesDomTools) {
globalThis.deesDomTools = new DomTools();
domToolsInstance = globalThis.deesDomTools;
// lets make sure the dom is ready
const readyStateChangedFunc = () => {
if (document.readyState === 'interactive' || document.readyState === 'complete') {
domToolsInstance.elements.headElement = document.querySelector('head');
domToolsInstance.elements.bodyElement = document.querySelector('body');
domToolsInstance.domReady.resolve();
}
};
document.addEventListener('readystatechange', readyStateChangedFunc);
domToolsInstance.domToolsReady.resolve();
} else {
domToolsInstance = globalThis.deesDomTools;
}
await domToolsInstance.domToolsReady.promise;
return domToolsInstance;
}
public static getDomToolsSync() {
const globalDomTools: DomTools = globalThis.deesDomTools;
if (!globalDomTools) {
throw new Error('You tried to access domtools synchronouly too early');
}
return globalThis.deesDomTools;
}
// ========
// INSTANCE
// ========
// elements
public elements: {
headElement: HTMLElement;
bodyElement: HTMLElement;
} = {
headElement: null,
bodyElement: null,
};
public smartstate = new plugins.smartstate.Smartstate();
public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', {
virtualViewport: 'native',
});
public router = new plugins.smartrouter.SmartRouter({
debug: false,
});
public scroller: plugins.SweetScroll;
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 runOnceResultMap = new FastMap();
/**
* run a function once and always get the Promise of the first execution
* @param identifierArg the indentifier arg identifies functions. functions with the same identifier are considered equal
* @param funcArg the actual func arg to run
*/
public async runOnce<T>(identifierArg: string, funcArg: () => Promise<T>) {
const runningId = `${identifierArg}+runningCheck`;
if (!this.runOnceTrackerStringMap.checkString(identifierArg)) {
this.runOnceTrackerStringMap.addString(identifierArg);
this.runOnceTrackerStringMap.addString(runningId);
const result = await funcArg();
this.runOnceResultMap.addToMap(identifierArg, result);
this.runOnceTrackerStringMap.removeString(runningId);
}
return await this.runOnceTrackerStringMap.registerUntilTrue(
(stringMap) => {
return !stringMap.includes(runningId);
},
() => {
return this.runOnceResultMap.getByKey(identifierArg);
}
);
}
// 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);
}
public async setWebsiteInfo(optionsArg: plugins.websetup.IWebSetupConstructorOptions) {
const websetup = new plugins.websetup.WebSetup(optionsArg);
await websetup.setup();
}
}

View File

@ -0,0 +1,5 @@
import * as plugins from './domtools.plugins';
export class Scroller {
// TODO: move sweet scroll over to here;
}

6
ts/domtools.colors.ts Normal file
View File

@ -0,0 +1,6 @@
export interface IDeesColorSet {
primaryAccent: string;
secondaryAccent: string;
primaryBackground: string;
secondaryBackground: string;
}

9
ts/domtools.css.ts Normal file
View File

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

View File

@ -0,0 +1,45 @@
import * as plugins from './domtools.plugins';
import { DomTools } from './domtools.classes.domtools';
import { html } from 'lit-element';
export const styles = html`
<style>
* {
font-family: 'Roboto', sans-serif;
box-sizing: border-box;
}
</style>
`;
/**
* a basic setup for elements
* makes sure everything is in check
*/
export const setup = async () => {
const domTools = await DomTools.setupDomTools();
domTools.runOnce('elementBasicSetup', async () => {
// bodyStyles
domTools.setGlobalStyles(`
body {
margin: 0px;
font-family: 'Roboto', sans-serif;
box-sizing: border-box;
}
`);
// material font
domTools.setGlobalStyles(`
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/materialicons/v42/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2');
}
`);
// Roboto Font
domTools.setGlobalStyles(`
@import url('https://fonts.googleapis.com/css?family=Roboto');
`);
});
};

18
ts/domtools.plugins.ts Normal file
View File

@ -0,0 +1,18 @@
// api glbal scope
import * as typedrequest from '@apiglobal/typedrequest';
export { typedrequest };
// pushrocks scope
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrouter from '@pushrocks/smartrouter';
import * as smartstate from '@pushrocks/smartstate';
import * as webrequest from '@pushrocks/webrequest';
import * as websetup from '@pushrocks/websetup';
export { smartpromise, smartrouter, smartstate, webrequest, websetup };
// third party scope
import SweetScroll from 'sweet-scroll';
export { SweetScroll };

View File

@ -1,3 +1,15 @@
import * as plugins from './dees-csstools.plugins'; export * from './domtools.colors';
export let standardExport = 'Hi there! :) This is an exported string'; import * as elementBasic from './domtools.elementbasic';
import * as breakpoints from './domtools.breakpoints';
import * as css from './domtools.css';
export { css, breakpoints, elementBasic };
export { DomTools } from './domtools.classes.domtools';
export { TypedRequest } from '@apiglobal/typedrequest';
import * as allPlugins from './domtools.plugins';
export const plugins = {
smartpromise: allPlugins.smartpromise,
};