Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
f5fd0662d3 | |||
14c91ed81f | |||
1aabacdf87 | |||
1747afe04a | |||
a1bd7f74a7 | |||
6ff89390b7 | |||
2ad8d0a9fd | |||
ae01670361 | |||
5657b0be1d | |||
781ae3c3b1 | |||
da79e623cc | |||
3ca6b5e34e | |||
98f0bc013d | |||
d32a544de2 |
1998
package-lock.json
generated
1998
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@designestate/dees-domtools",
|
||||
"version": "1.0.93",
|
||||
"version": "1.0.100",
|
||||
"private": false,
|
||||
"description": "tools to simplify complex css structures",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -13,18 +13,18 @@
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.27",
|
||||
"@gitzone/tsbundle": "^1.0.87",
|
||||
"@gitzone/tstest": "^1.0.57",
|
||||
"@gitzone/tsbuild": "^2.1.28",
|
||||
"@gitzone/tsbundle": "^1.0.88",
|
||||
"@gitzone/tstest": "^1.0.60",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/node": "^16.9.0",
|
||||
"@types/node": "^16.11.9",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest": "^1.0.56",
|
||||
"@designestate/dees-comms": "^1.0.9",
|
||||
"@pushrocks/lik": "^4.0.20",
|
||||
"@apiglobal/typedrequest": "^1.0.65",
|
||||
"@designestate/dees-comms": "^1.0.11",
|
||||
"@pushrocks/lik": "^5.0.0",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smartrouter": "^1.0.11",
|
||||
@ -33,7 +33,7 @@
|
||||
"@pushrocks/webrequest": "^2.0.13",
|
||||
"@pushrocks/websetup": "^3.0.15",
|
||||
"@pushrocks/webstore": "^1.0.16",
|
||||
"lit-element": "^2.5.1",
|
||||
"lit-element": "^3.0.2",
|
||||
"sweet-scroll": "^4.0.0"
|
||||
},
|
||||
"files": [
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { DomTools } from './domtools.classes.domtools';
|
||||
|
||||
import { CSSResult, unsafeCSS } from 'lit-element';
|
||||
|
||||
export const desktop = 1240;
|
||||
export const tablet = 1024;
|
||||
export const phablet = 600;
|
||||
@ -7,65 +9,35 @@ 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 = (cssArg: CSSResult) => {
|
||||
return unsafeCSS(`
|
||||
@container wccToolsViewport (min-width: ${tablet}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
@media (min-width: ${tablet}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`);
|
||||
};
|
||||
|
||||
export const cssForTablet = (contentArg) => {
|
||||
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
||||
return `
|
||||
@media (max-width: ${tablet}px) {
|
||||
${contentArg}
|
||||
export const cssForPhablet = (cssArg: CSSResult) => {
|
||||
return unsafeCSS(`
|
||||
@container wccToolsViewport (min-width: ${phablet}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`;
|
||||
} else if (
|
||||
getEnvironment() === 'tablet' ||
|
||||
getEnvironment() === 'phablet' ||
|
||||
getEnvironment() === 'phone'
|
||||
) {
|
||||
return `
|
||||
@media (min-width: 0px) {
|
||||
${contentArg}
|
||||
}
|
||||
`;
|
||||
@media (min-width: ${phablet}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`);
|
||||
};
|
||||
|
||||
export const cssForPhablet = (contentArg) => {
|
||||
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
||||
return `
|
||||
@media (max-width: ${phablet}px) {
|
||||
${contentArg}
|
||||
export const cssForPhone = (cssArg: CSSResult) => {
|
||||
return unsafeCSS(`
|
||||
@container wccToolsViewport (min-width: ${phone}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`;
|
||||
} 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}
|
||||
}
|
||||
`;
|
||||
@media (min-width: ${phone}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`);
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ export class DomTools {
|
||||
});
|
||||
|
||||
public convenience = {
|
||||
|
||||
typedrequest: plugins.typedrequest,
|
||||
smartdelay: plugins.smartdelay,
|
||||
};
|
||||
|
||||
@ -90,7 +90,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 +98,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 +110,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 +136,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 +148,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 +160,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;
|
||||
|
@ -5,7 +5,7 @@ import { DomTools } from './domtools.classes.domtools';
|
||||
*/
|
||||
export const scrollBarStyles = (() => {
|
||||
const returnStyles =
|
||||
navigator.userAgent.indexOf('Windows') !== -1
|
||||
navigator.userAgent.indexOf('Mac OS X') !== -1
|
||||
? `
|
||||
/* width */
|
||||
::-webkit-scrollbar {
|
||||
|
@ -15,5 +15,6 @@ import * as allPlugins from './domtools.plugins';
|
||||
export const plugins = {
|
||||
smartdelay: allPlugins.smartdelay,
|
||||
smartpromise: allPlugins.smartpromise,
|
||||
SweetScroll: allPlugins.SweetScroll
|
||||
SweetScroll: allPlugins.SweetScroll,
|
||||
smartstate: allPlugins.smartstate
|
||||
};
|
||||
|
Reference in New Issue
Block a user