Compare commits

...

22 Commits

Author SHA1 Message Date
d9cdff2897 1.0.107 2022-01-24 06:56:32 +01:00
189060f11d fix(core): update 2022-01-24 06:56:30 +01:00
fc2dfa8018 1.0.106 2022-01-22 18:59:30 +01:00
be44cb7a78 fix(core): update 2022-01-22 18:59:29 +01:00
de6aba4289 1.0.105 2022-01-22 18:56:31 +01:00
3babbce2c5 fix(core): update 2022-01-22 18:56:30 +01:00
707956b7ee 1.0.104 2022-01-14 18:20:46 +01:00
c71a6170d5 fix(core): update 2022-01-14 18:20:45 +01:00
3f98f2867c 1.0.103 2021-12-13 23:18:07 +01:00
7c86f5a8f6 fix(core): update 2021-12-13 23:18:06 +01:00
472ec3158e 1.0.102 2021-11-26 17:36:00 +01:00
9a0d09d9de fix(core): update 2021-11-26 17:36:00 +01:00
5975ca7320 1.0.101 2021-11-26 16:21:11 +01:00
97583c650d fix(core): update 2021-11-26 16:21:11 +01:00
f5fd0662d3 1.0.100 2021-11-26 15:26:16 +01:00
14c91ed81f fix(core): update 2021-11-26 15:26:15 +01:00
1aabacdf87 1.0.99 2021-11-21 16:14:28 +01:00
1747afe04a fix(core): update 2021-11-21 16:14:27 +01:00
a1bd7f74a7 1.0.98 2021-11-21 16:08:28 +01:00
6ff89390b7 fix(core): update 2021-11-21 16:08:27 +01:00
2ad8d0a9fd 1.0.97 2021-11-21 15:52:49 +01:00
ae01670361 fix(core): update 2021-11-21 15:52:49 +01:00
12 changed files with 3219 additions and 2154 deletions

View File

@ -36,6 +36,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci

5050
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@designestate/dees-domtools",
"version": "1.0.96",
"version": "1.0.107",
"private": false,
"description": "tools to simplify complex css structures",
"main": "dist_ts/index.js",
@ -13,27 +13,27 @@
"format": "(gitzone format)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.27",
"@gitzone/tsbundle": "^1.0.87",
"@gitzone/tstest": "^1.0.57",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^16.10.1",
"@gitzone/tsbuild": "^2.1.29",
"@gitzone/tsbundle": "^1.0.89",
"@gitzone/tstest": "^1.0.60",
"@pushrocks/tapbundle": "^4.0.0",
"@types/node": "^17.0.10",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@apiglobal/typedrequest": "^1.0.58",
"@designestate/dees-comms": "^1.0.10",
"@pushrocks/lik": "^5.0.0",
"@apiglobal/typedrequest": "^1.0.65",
"@designestate/dees-comms": "^1.0.14",
"@pushrocks/lik": "^5.0.1",
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartrouter": "^1.0.11",
"@pushrocks/smartrx": "^2.0.19",
"@pushrocks/smartstate": "^1.0.21",
"@pushrocks/smartrouter": "^1.0.12",
"@pushrocks/smartrx": "^2.0.20",
"@pushrocks/smartstate": "^1.0.23",
"@pushrocks/webrequest": "^2.0.13",
"@pushrocks/websetup": "^3.0.15",
"@pushrocks/webstore": "^1.0.16",
"lit-element": "^3.0.0",
"@pushrocks/websetup": "^3.0.16",
"@pushrocks/webstore": "^1.0.18",
"lit": "^2.1.1",
"sweet-scroll": "^4.0.0"
},
"files": [

View File

@ -3,7 +3,7 @@ import * as domtools from '../ts/index';
tap.test('first test', async () => {
const domtoolsInstance = await domtools.DomTools.setupDomTools();
expect(domtoolsInstance).to.be.instanceof(domtools.DomTools);
expect(domtoolsInstance).toBeInstanceOf(domtools.DomTools);
});
tap.start();

View File

@ -1,71 +0,0 @@
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

@ -1,7 +1,7 @@
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 { TViewport } from './domtools.css.breakpoints';
import { Scroller } from './domtools.classes.scroller';
import { WebSetup } from '@pushrocks/websetup';
@ -9,6 +9,7 @@ import { ThemeManager } from './domtools.classes.thememanager';
export interface IDomToolsState {
virtualViewport: TViewport;
jwt: string;
}
export class DomTools {
@ -73,6 +74,7 @@ export class DomTools {
public smartstate = new plugins.smartstate.Smartstate();
public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', {
virtualViewport: 'native',
jwt: null
});
public router = new plugins.smartrouter.SmartRouter({
@ -90,7 +92,7 @@ export class DomTools {
}); // TODO: switch to scroller class
public themeManager = new ThemeManager(this);
private actionSetVirtualViewport = this.domToolsStatePart.createAction<TViewport>(
/* private actionSetVirtualViewport = this.domToolsStatePart.createAction<TViewport>(
async (statePart, payload) => {
const currentState = statePart.getState();
currentState.virtualViewport = payload;
@ -98,6 +100,10 @@ export class DomTools {
}
);
public setVirtualViewport(environmentArg: TViewport) {
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
} */
public domToolsReady = plugins.smartpromise.defer();
public domReady = plugins.smartpromise.defer();
public globalStylesReady = plugins.smartpromise.defer();
@ -106,6 +112,7 @@ export class DomTools {
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
@ -131,7 +138,10 @@ export class DomTools {
}
// setStuff
/**
* allows to set global styles
* @param stylesText the css text you want to set
*/
public async setGlobalStyles(stylesText: string) {
await this.domReady.promise;
const styleElement = document.createElement('style');
@ -140,6 +150,10 @@ export class DomTools {
this.elements.headElement.appendChild(styleElement);
}
/**
* allows setting external css files
* @param cssLinkArg a url to an external stylesheet
*/
public async setExternalCss(cssLinkArg: string) {
const cssTag = document.createElement('link');
cssTag.rel = 'stylesheet';
@ -148,10 +162,10 @@ export class DomTools {
document.head.append(cssTag);
}
public setVirtualViewport(environmentArg: TViewport) {
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
}
/**
* allows setting of website infos
* @param optionsArg the website info
*/
public async setWebsiteInfo(optionsArg: plugins.websetup.IWebSetupConstructorOptions) {
await this.websetup.setup(optionsArg);
await this.websetup.readyPromise;

View File

@ -1,4 +1,3 @@
import { LitElement } from 'lit-element';
import { DomTools } from './domtools.classes.domtools';
import * as plugins from './domtools.plugins';
@ -29,16 +28,25 @@ export class ThemeManager {
this.themeObservable.next(this.goBrightBoolean);
}
/**
* set the theme of the website to bright
*/
public goBright() {
this.goBrightBoolean = true;
this.updateAllConnectedElements();
}
/**
* set the theme of the website to dark
*/
public goDark() {
this.goBrightBoolean = false;
this.updateAllConnectedElements();
}
/**
* simply toggle between bright and dark
*/
public toggleDarkBright() {
this.goBrightBoolean = !this.goBrightBoolean;
this.updateAllConnectedElements();

View File

@ -0,0 +1,59 @@
import { DomTools } from './domtools.classes.domtools';
import { css, unsafeCSS } from 'lit';
/**
* changes scrollbar styles to be consistent across OS borders
*/
export const scrollBarStyles: string = (() => {
const returnStyles =
navigator.userAgent.indexOf('Mac OS X') !== -1
? css`
/* width */
::-webkit-scrollbar {
width: 8px;
}
/* Track */
::-webkit-scrollbar-track {
background: #111;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #666;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #777;
}
`.cssText
: ``;
return returnStyles;
})();
export const globalBaseStyles: string = css`
/* global material font */
@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 */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400');
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100;300;400');
/* global body styles */
body {
margin: 0px;
font-family: 'Roboto', sans-serif;
box-sizing: border-box;
}
/* scroll bar styles */
${unsafeCSS(scrollBarStyles)}
`.cssText;

View File

@ -0,0 +1,43 @@
import { DomTools } from './domtools.classes.domtools';
import { CSSResult, unsafeCSS } from 'lit';
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 cssForTablet = (cssArg: CSSResult) => {
return unsafeCSS(`
@container wccToolsViewport (max-width: ${tablet}px) {
${cssArg.cssText}
}
@media (max-width: ${tablet}px) {
${cssArg.cssText}
}
`);
};
export const cssForPhablet = (cssArg: CSSResult) => {
return unsafeCSS(`
@container wccToolsViewport (max-width: ${phablet}px) {
${cssArg.cssText}
}
@media (max-width: ${phablet}px) {
${cssArg.cssText}
}
`);
};
export const cssForPhone = (cssArg: CSSResult) => {
return unsafeCSS(`
@container wccToolsViewport (max-width: ${phone}px) {
${cssArg.cssText}
}
@media (max-width: ${phone}px) {
${cssArg.cssText}
}
`);
};

View File

@ -1,31 +0,0 @@
import { DomTools } from './domtools.classes.domtools';
/**
* changes scrollbar styles to be consistent across OS borders
*/
export const scrollBarStyles = (() => {
const returnStyles =
navigator.userAgent.indexOf('Windows') !== -1
? `
/* width */
::-webkit-scrollbar {
width: 8px;
}
/* Track */
::-webkit-scrollbar-track {
background: #111;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #666;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #777;
}
`
: ``;
})();

View File

@ -1,8 +1,8 @@
import * as plugins from './domtools.plugins';
import { DomTools } from './domtools.classes.domtools';
import { scrollBarStyles } from './domtools.css.theme';
import { scrollBarStyles, globalBaseStyles } from './domtools.css.basestyles';
import { html, LitElement, css, unsafeCSS } from 'lit-element';
import { html, LitElement, css, unsafeCSS } from 'lit';
export const staticStyles = css`
* {
@ -11,6 +11,7 @@ export const staticStyles = css`
}
:host {
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
}
@ -49,34 +50,7 @@ export const setup = async (elementArg?: LitElement): Promise<DomTools> => {
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/css2?family=Roboto:wght@100;300;400');
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100;300;400');
`);
// scrollbars
domTools.setGlobalStyles(`
${scrollBarStyles}
`);
domTools.setGlobalStyles(globalBaseStyles);
});
return domTools;
};

View File

@ -1,7 +1,7 @@
export * from './domtools.colors';
import * as elementBasic from './domtools.elementbasic';
import * as breakpoints from './domtools.breakpoints';
import * as breakpoints from './domtools.css.breakpoints';
import * as css from './domtools.css';
export { css, breakpoints, elementBasic };