Compare commits
68 Commits
Author | SHA1 | Date | |
---|---|---|---|
98f0bc013d | |||
d32a544de2 | |||
070221d6c9 | |||
19714854ba | |||
50ebea1b5f | |||
df0527f3c1 | |||
b620b7393e | |||
ab5b9511fd | |||
da86e64056 | |||
effc331a67 | |||
fa24708a47 | |||
31126e30eb | |||
ef0a4eae80 | |||
e711302c28 | |||
1cfc07fe8e | |||
7f221c1a8c | |||
09f927c0d4 | |||
1042e79625 | |||
fced2efcbd | |||
83fe1d62e7 | |||
78bce9600c | |||
2860b5b6e0 | |||
b802935d27 | |||
b73a702b74 | |||
b3deb31ab5 | |||
6ea5482e3d | |||
0ead7215ff | |||
286bb0887a | |||
4456f00816 | |||
b60a1bebe0 | |||
94127227a6 | |||
b5af1b1226 | |||
a6f382dd7f | |||
0de00cb2c1 | |||
570a026cf8 | |||
48b5cc770c | |||
7ae2de5843 | |||
e4d87ae882 | |||
259a669e24 | |||
bf461dd1a0 | |||
63c9ae97d4 | |||
a83239e0d9 | |||
8da64f1b50 | |||
2d4c0e4e49 | |||
1c8f7fa59e | |||
a613c0aca2 | |||
127564cd71 | |||
e077bf5b25 | |||
64a3f57813 | |||
1315e8c3f6 | |||
d059862841 | |||
ad34affb9e | |||
011b3fb76a | |||
47099d02b5 | |||
f4029ed008 | |||
d5732822e4 | |||
c467a92e7c | |||
746c1148e3 | |||
d75e66ba78 | |||
7c805a075e | |||
5e1a44ad88 | |||
093eae2c97 | |||
991d318de6 | |||
c7c3650fe9 | |||
8d355f234f | |||
a5c22ec1db | |||
f5263a0cc4 | |||
4a022a7d1d |
22427
package-lock.json
generated
22427
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@designestate/dees-domtools",
|
"name": "@designestate/dees-domtools",
|
||||||
"version": "1.0.60",
|
"version": "1.0.94",
|
||||||
"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",
|
||||||
@ -13,26 +13,27 @@
|
|||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.27",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@gitzone/tsbundle": "^1.0.87",
|
||||||
"@gitzone/tstest": "^1.0.52",
|
"@gitzone/tstest": "^1.0.57",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.14.6",
|
"@types/node": "^16.9.1",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apiglobal/typedrequest": "^1.0.54",
|
"@apiglobal/typedrequest": "^1.0.56",
|
||||||
"@designestate/dees-comms": "^1.0.7",
|
"@designestate/dees-comms": "^1.0.9",
|
||||||
"@pushrocks/lik": "^4.0.17",
|
"@pushrocks/lik": "^4.0.22",
|
||||||
"@pushrocks/smartdelay": "^2.0.10",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/smartpromise": "^3.1.3",
|
"@pushrocks/smartpromise": "^3.1.6",
|
||||||
"@pushrocks/smartrouter": "^1.0.4",
|
"@pushrocks/smartrouter": "^1.0.11",
|
||||||
"@pushrocks/smartstate": "^1.0.17",
|
"@pushrocks/smartrx": "^2.0.19",
|
||||||
|
"@pushrocks/smartstate": "^1.0.21",
|
||||||
"@pushrocks/webrequest": "^2.0.13",
|
"@pushrocks/webrequest": "^2.0.13",
|
||||||
"@pushrocks/websetup": "^3.0.8",
|
"@pushrocks/websetup": "^3.0.15",
|
||||||
"@pushrocks/webstore": "^1.0.16",
|
"@pushrocks/webstore": "^1.0.16",
|
||||||
"lit-element": "^2.4.0",
|
"lit-element": "^2.5.1",
|
||||||
"sweet-scroll": "^4.0.0"
|
"sweet-scroll": "^4.0.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -4,8 +4,8 @@ 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';
|
import { Scroller } from './domtools.classes.scroller';
|
||||||
import { delayForRandom } from '@pushrocks/smartdelay';
|
|
||||||
import { WebSetup } from '@pushrocks/websetup';
|
import { WebSetup } from '@pushrocks/websetup';
|
||||||
|
import { ThemeManager } from './domtools.classes.thememanager';
|
||||||
|
|
||||||
export interface IDomToolsState {
|
export interface IDomToolsState {
|
||||||
virtualViewport: TViewport;
|
virtualViewport: TViewport;
|
||||||
@ -66,8 +66,8 @@ export class DomTools {
|
|||||||
|
|
||||||
public websetup: WebSetup = new WebSetup({
|
public websetup: WebSetup = new WebSetup({
|
||||||
metaObject: {
|
metaObject: {
|
||||||
title: 'loading...'
|
title: 'loading...',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
public smartstate = new plugins.smartstate.Smartstate();
|
public smartstate = new plugins.smartstate.Smartstate();
|
||||||
@ -80,12 +80,15 @@ export class DomTools {
|
|||||||
});
|
});
|
||||||
|
|
||||||
public convenience = {
|
public convenience = {
|
||||||
|
typedrequest: plugins.typedrequest,
|
||||||
smartdelay: plugins.smartdelay,
|
smartdelay: plugins.smartdelay,
|
||||||
};
|
};
|
||||||
|
|
||||||
public scroller: plugins.SweetScroll;
|
|
||||||
|
|
||||||
public deesComms = new plugins.deesComms.DeesComms();
|
public deesComms = new plugins.deesComms.DeesComms();
|
||||||
|
public scroller = new plugins.SweetScroll({
|
||||||
|
/* some options */
|
||||||
|
}); // 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) => {
|
async (statePart, payload) => {
|
||||||
@ -99,14 +102,7 @@ export class DomTools {
|
|||||||
public domReady = plugins.smartpromise.defer();
|
public domReady = plugins.smartpromise.defer();
|
||||||
public globalStylesReady = plugins.smartpromise.defer();
|
public globalStylesReady = plugins.smartpromise.defer();
|
||||||
|
|
||||||
constructor() {
|
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();
|
||||||
@ -144,12 +140,20 @@ export class DomTools {
|
|||||||
this.elements.headElement.appendChild(styleElement);
|
this.elements.headElement.appendChild(styleElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async setExternalCss(cssLinkArg: string) {
|
||||||
|
const cssTag = document.createElement('link');
|
||||||
|
cssTag.rel = 'stylesheet';
|
||||||
|
cssTag.crossOrigin = 'anonymous';
|
||||||
|
cssTag.href = cssLinkArg;
|
||||||
|
document.head.append(cssTag);
|
||||||
|
}
|
||||||
|
|
||||||
public setVirtualViewport(environmentArg: TViewport) {
|
public setVirtualViewport(environmentArg: TViewport) {
|
||||||
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
|
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setWebsiteInfo(optionsArg: plugins.websetup.IWebSetupConstructorOptions) {
|
public async setWebsiteInfo(optionsArg: plugins.websetup.IWebSetupConstructorOptions) {
|
||||||
this.websetup.setup(optionsArg);
|
await this.websetup.setup(optionsArg);
|
||||||
await this.websetup.readyPromise;
|
await this.websetup.readyPromise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
46
ts/domtools.classes.thememanager.ts
Normal file
46
ts/domtools.classes.thememanager.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { LitElement } from 'lit-element';
|
||||||
|
import { DomTools } from './domtools.classes.domtools';
|
||||||
|
import * as plugins from './domtools.plugins';
|
||||||
|
|
||||||
|
export class ThemeManager {
|
||||||
|
public domtoolsRef: DomTools;
|
||||||
|
|
||||||
|
public goBrightBoolean = false;
|
||||||
|
public preferredColorSchemeMediaMatch = window.matchMedia('(prefers-color-scheme: light)');
|
||||||
|
|
||||||
|
public themeObservable = new plugins.smartrx.rxjs.ReplaySubject<boolean>(1);
|
||||||
|
|
||||||
|
constructor(domtoolsRefArg: DomTools) {
|
||||||
|
this.domtoolsRef = domtoolsRefArg;
|
||||||
|
|
||||||
|
// lets care
|
||||||
|
this.goBrightBoolean = this.preferredColorSchemeMediaMatch.matches;
|
||||||
|
this.preferredColorSchemeMediaMatch.addEventListener('change', (eventArg) => {
|
||||||
|
this.goBrightBoolean = eventArg.matches;
|
||||||
|
this.updateAllConnectedElements();
|
||||||
|
});
|
||||||
|
this.updateAllConnectedElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateAllConnectedElements() {
|
||||||
|
if (document.body && document.body.style) {
|
||||||
|
document.body.style.background = this.goBrightBoolean ? '#fff' : '#000';
|
||||||
|
}
|
||||||
|
this.themeObservable.next(this.goBrightBoolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
public goBright() {
|
||||||
|
this.goBrightBoolean = true;
|
||||||
|
this.updateAllConnectedElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
public goDark() {
|
||||||
|
this.goBrightBoolean = false;
|
||||||
|
this.updateAllConnectedElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
public toggleDarkBright() {
|
||||||
|
this.goBrightBoolean = !this.goBrightBoolean;
|
||||||
|
this.updateAllConnectedElements();
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,9 @@ import { DomTools } from './domtools.classes.domtools';
|
|||||||
* changes scrollbar styles to be consistent across OS borders
|
* changes scrollbar styles to be consistent across OS borders
|
||||||
*/
|
*/
|
||||||
export const scrollBarStyles = (() => {
|
export const scrollBarStyles = (() => {
|
||||||
const returnStyles = navigator.userAgent.indexOf("Windows") !== -1 ? `
|
const returnStyles =
|
||||||
|
navigator.userAgent.indexOf('Windows') !== -1
|
||||||
|
? `
|
||||||
/* width */
|
/* width */
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 8px;
|
width: 8px;
|
||||||
@ -24,5 +26,6 @@ export const scrollBarStyles = (() => {
|
|||||||
::-webkit-scrollbar-thumb:hover {
|
::-webkit-scrollbar-thumb:hover {
|
||||||
background: #777;
|
background: #777;
|
||||||
}
|
}
|
||||||
` : ``;
|
`
|
||||||
|
: ``;
|
||||||
})();
|
})();
|
||||||
|
@ -2,7 +2,20 @@ import * as plugins from './domtools.plugins';
|
|||||||
import { DomTools } from './domtools.classes.domtools';
|
import { DomTools } from './domtools.classes.domtools';
|
||||||
import { scrollBarStyles } from './domtools.css.theme';
|
import { scrollBarStyles } from './domtools.css.theme';
|
||||||
|
|
||||||
import { html } from 'lit-element';
|
import { html, LitElement, css, unsafeCSS } from 'lit-element';
|
||||||
|
|
||||||
|
export const staticStyles = css`
|
||||||
|
* {
|
||||||
|
transition: background 0.1s, color 0.1s;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host {
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
${unsafeCSS(scrollBarStyles)}
|
||||||
|
`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* styles to be included in every webcomponent
|
* styles to be included in every webcomponent
|
||||||
@ -10,10 +23,14 @@ import { html } from 'lit-element';
|
|||||||
export const styles = html`
|
export const styles = html`
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
font-family: 'Roboto', sans-serif;
|
transition: background 0.1s, color 0.1s;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host {
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
${scrollBarStyles}
|
${scrollBarStyles}
|
||||||
</style>
|
</style>
|
||||||
`;
|
`;
|
||||||
@ -22,8 +39,14 @@ export const styles = html`
|
|||||||
* a basic setup for elements
|
* a basic setup for elements
|
||||||
* makes sure everything is in check
|
* makes sure everything is in check
|
||||||
*/
|
*/
|
||||||
export const setup = async () => {
|
export const setup = async (elementArg?: LitElement): Promise<DomTools> => {
|
||||||
const domTools = await DomTools.setupDomTools();
|
const domTools = await DomTools.setupDomTools();
|
||||||
|
|
||||||
|
if (elementArg) {
|
||||||
|
// lets do something with the element
|
||||||
|
// not used right now
|
||||||
|
}
|
||||||
|
|
||||||
domTools.runOnce('elementBasicSetup', async () => {
|
domTools.runOnce('elementBasicSetup', async () => {
|
||||||
// bodyStyles
|
// bodyStyles
|
||||||
domTools.setGlobalStyles(`
|
domTools.setGlobalStyles(`
|
||||||
@ -55,4 +78,5 @@ export const setup = async () => {
|
|||||||
${scrollBarStyles}
|
${scrollBarStyles}
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
return domTools;
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
// designestate scope
|
// designestate scope
|
||||||
import * as deesComms from '@designestate/dees-comms';
|
import * as deesComms from '@designestate/dees-comms';
|
||||||
|
|
||||||
export {
|
export { deesComms };
|
||||||
deesComms
|
|
||||||
};
|
|
||||||
|
|
||||||
// apiglobal scope
|
// apiglobal scope
|
||||||
import * as typedrequest from '@apiglobal/typedrequest';
|
import * as typedrequest from '@apiglobal/typedrequest';
|
||||||
@ -14,12 +12,29 @@ export { typedrequest };
|
|||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smartrouter from '@pushrocks/smartrouter';
|
import * as smartrouter from '@pushrocks/smartrouter';
|
||||||
|
import * as smartrx from '@pushrocks/smartrx';
|
||||||
import * as smartstate from '@pushrocks/smartstate';
|
import * as smartstate from '@pushrocks/smartstate';
|
||||||
import * as webrequest from '@pushrocks/webrequest';
|
import * as webrequest from '@pushrocks/webrequest';
|
||||||
import * as websetup from '@pushrocks/websetup';
|
import * as websetup from '@pushrocks/websetup';
|
||||||
import * as webstore from '@pushrocks/webstore';
|
import * as webstore from '@pushrocks/webstore';
|
||||||
|
|
||||||
export { smartdelay, smartpromise, smartrouter, smartstate, webrequest, websetup, webstore };
|
// subscope lik
|
||||||
|
import { ObjectMap } from '@pushrocks/lik/dist_ts/lik.objectmap';
|
||||||
|
const lik = {
|
||||||
|
ObjectMap,
|
||||||
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
lik,
|
||||||
|
smartdelay,
|
||||||
|
smartpromise,
|
||||||
|
smartrouter,
|
||||||
|
smartrx,
|
||||||
|
smartstate,
|
||||||
|
webrequest,
|
||||||
|
websetup,
|
||||||
|
webstore,
|
||||||
|
};
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import SweetScroll from 'sweet-scroll';
|
import SweetScroll from 'sweet-scroll';
|
||||||
|
@ -7,9 +7,13 @@ 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';
|
export { TypedRequest } from '@apiglobal/typedrequest';
|
||||||
|
export { IWebSetupConstructorOptions } from '@pushrocks/websetup';
|
||||||
|
export { rxjs } from '@pushrocks/smartrx';
|
||||||
|
|
||||||
import * as allPlugins from './domtools.plugins';
|
import * as allPlugins from './domtools.plugins';
|
||||||
|
|
||||||
export const plugins = {
|
export const plugins = {
|
||||||
|
smartdelay: allPlugins.smartdelay,
|
||||||
smartpromise: allPlugins.smartpromise,
|
smartpromise: allPlugins.smartpromise,
|
||||||
|
SweetScroll: allPlugins.SweetScroll
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user