Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
6cc5ec315e | |||
88810bae2c | |||
21369d8da5 | |||
a5973944ee | |||
ad3f4b31fa | |||
91b50ecde5 | |||
45fecfbde8 | |||
e3e6d06969 | |||
50ace4c236 | |||
90f68965bb | |||
6c92a9cdf8 | |||
d4e24d615a | |||
37b7dca212 | |||
7d9dc1ad65 | |||
20f06e5935 | |||
d3fa33f0cc | |||
aa91dad272 | |||
05a22599b8 | |||
bd0b279fc2 | |||
8276a5b09b | |||
a9200859ec | |||
210a0ad8a1 | |||
2756a3cb68 | |||
acf0ea3874 | |||
284d2be0e3 | |||
dfb9175613 | |||
16a213f536 | |||
9869b0c6aa | |||
e63cb9669b | |||
06766c6895 | |||
48f1b02f0b | |||
f41550fa22 | |||
ac18ed0684 | |||
0ed59e850e | |||
fb36c641a9 | |||
ae74e0b4f2 | |||
d2a330e5d9 | |||
f40287fbb6 | |||
e27bd8a53f | |||
d6fc173a5b | |||
52c245d655 | |||
c2e0c0ab19 | |||
455d68338b | |||
710e99a69a | |||
e3939865aa | |||
ba20508642 | |||
bef4ea7bed | |||
17a8151b2f | |||
5aee15a23b | |||
38d78b4e12 | |||
ec36a516c0 | |||
1c844d35ca | |||
ecb387f59e | |||
9b3c92fef5 | |||
74cf94a69e | |||
9f76d4e920 | |||
082ef21078 | |||
4db0e6f5fc | |||
40b8c5010d | |||
16297dc630 | |||
7c3d131b46 | |||
2032df467e | |||
21bcd390d6 | |||
5f4ff8f6a2 | |||
9782077fb9 |
@ -4,9 +4,9 @@
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "designestate",
|
||||
"gitrepo": "dees-csstools",
|
||||
"gitrepo": "dees-domtools",
|
||||
"shortDescription": "tools to simplify complex css structures",
|
||||
"npmPackagename": "@designestate/dees-csstools",
|
||||
"npmPackagename": "@designestate/dees-domtools",
|
||||
"license": "MIT",
|
||||
"projectDomain": "design.estate"
|
||||
}
|
||||
|
2239
package-lock.json
generated
2239
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@designestate/dees-csstools",
|
||||
"version": "1.0.2",
|
||||
"name": "@designestate/dees-domtools",
|
||||
"version": "1.0.35",
|
||||
"private": false,
|
||||
"description": "tools to simplify complex css structures",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -8,19 +8,30 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web && tsbundle npm)",
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tsbundle": "^1.0.69",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.11.7",
|
||||
"tslint": "^5.11.0",
|
||||
"@types/node": "^14.0.5",
|
||||
"tslint": "^6.1.2",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest": "^1.0.38",
|
||||
"@pushrocks/lik": "^4.0.13",
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@pushrocks/smartrouter": "^1.0.2",
|
||||
"@pushrocks/smartstate": "^1.0.16",
|
||||
"@pushrocks/webrequest": "^2.0.9",
|
||||
"@pushrocks/websetup": "^2.0.16",
|
||||
"lit-element": "^2.3.1",
|
||||
"sweet-scroll": "^4.0.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
|
31
readme.md
31
readme.md
@ -1,20 +1,27 @@
|
||||
# @designestate/dees-csstools
|
||||
# @designestate/dees-domtools
|
||||
tools to simplify complex css structures
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@designestate/dees-csstools)
|
||||
* [gitlab.com (source)](https://gitlab.com/designestate/dees-csstools)
|
||||
* [github.com (source mirror)](https://github.com/designestate/dees-csstools)
|
||||
* [docs (typedoc)](https://designestate.gitlab.io/dees-csstools/)
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@designestate/dees-domtools)
|
||||
* [gitlab.com (source)](https://gitlab.com/designestate/dees-domtools)
|
||||
* [github.com (source mirror)](https://github.com/designestate/dees-domtools)
|
||||
* [docs (typedoc)](https://designestate.gitlab.io/dees-domtools/)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/designestate/dees-csstools/commits/master)
|
||||
[](https://gitlab.com/designestate/dees-csstools/commits/master)
|
||||
[](https://www.npmjs.com/package/@designestate/dees-csstools)
|
||||
[](https://snyk.io/test/npm/@designestate/dees-csstools)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
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
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as deesCsstools from '../ts/index';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
console.log(deesCsstools.standardExport);
|
||||
console.log('hi');
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -1,2 +0,0 @@
|
||||
const removeme = {};
|
||||
export { removeme };
|
71
ts/domtools.breakpoints.ts
Normal file
71
ts/domtools.breakpoints.ts
Normal 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}
|
||||
}
|
||||
`;
|
||||
}
|
||||
};
|
129
ts/domtools.classes.domtools.ts
Normal file
129
ts/domtools.classes.domtools.ts
Normal file
@ -0,0 +1,129 @@
|
||||
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;
|
||||
}
|
||||
|
||||
// ========
|
||||
// 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();
|
||||
}
|
||||
}
|
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;
|
||||
}
|
6
ts/domtools.colors.ts
Normal file
6
ts/domtools.colors.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface IDeesColorSet {
|
||||
primaryAccent: string;
|
||||
secondaryAccent: string;
|
||||
primaryBackground: string;
|
||||
secondaryBackground: string;
|
||||
}
|
9
ts/domtools.css.ts
Normal file
9
ts/domtools.css.ts
Normal 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;
|
||||
};
|
45
ts/domtools.elementbasic.ts
Normal file
45
ts/domtools.elementbasic.ts
Normal 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
18
ts/domtools.plugins.ts
Normal 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 };
|
10
ts/index.ts
10
ts/index.ts
@ -1,3 +1,9 @@
|
||||
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';
|
||||
|
Reference in New Issue
Block a user