Compare commits
94 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
bd6ba6d6db | |||
317bc63bc7 | |||
22eeb7809b | |||
fdd550ec21 | |||
9db1f92ba3 | |||
772d0b0b97 | |||
a68e9e1bf9 | |||
f9507b0dbd | |||
f8c1a0135a | |||
7d884f6556 | |||
8a8ee5cd7b | |||
1660381be6 | |||
f0ad441415 | |||
27c087b693 | |||
63463a751c | |||
a01f5a5b8a | |||
bb1ad4e037 | |||
eb871161f9 | |||
090e5b4d42 | |||
8168dd1a0c | |||
de15bc0d1c | |||
13fa3d655e | |||
18b93b860d | |||
e8e6416b6f | |||
fbe2f381c9 | |||
3cb0aceaad | |||
6d6c92eee4 | |||
4385909677 | |||
2dc36d8170 | |||
ffbde62744 | |||
7bde843e43 | |||
faa7adcffe |
18700
package-lock.json
generated
18700
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@designestate/dees-domtools",
|
"name": "@designestate/dees-domtools",
|
||||||
"version": "1.0.44",
|
"version": "1.0.91",
|
||||||
"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",
|
||||||
@ -14,22 +14,25 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@gitzone/tsbundle": "^1.0.80",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tstest": "^1.0.52",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.10.1",
|
"@types/node": "^14.14.33",
|
||||||
"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.43",
|
"@apiglobal/typedrequest": "^1.0.56",
|
||||||
"@pushrocks/lik": "^4.0.17",
|
"@designestate/dees-comms": "^1.0.9",
|
||||||
|
"@pushrocks/lik": "^4.0.20",
|
||||||
"@pushrocks/smartdelay": "^2.0.10",
|
"@pushrocks/smartdelay": "^2.0.10",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.1.3",
|
||||||
"@pushrocks/smartrouter": "^1.0.4",
|
"@pushrocks/smartrouter": "^1.0.7",
|
||||||
"@pushrocks/smartstate": "^1.0.17",
|
"@pushrocks/smartrx": "^2.0.19",
|
||||||
"@pushrocks/webrequest": "^2.0.10",
|
"@pushrocks/smartstate": "^1.0.21",
|
||||||
"@pushrocks/websetup": "^2.0.18",
|
"@pushrocks/webrequest": "^2.0.13",
|
||||||
|
"@pushrocks/websetup": "^3.0.15",
|
||||||
|
"@pushrocks/webstore": "^1.0.16",
|
||||||
"lit-element": "^2.4.0",
|
"lit-element": "^2.4.0",
|
||||||
"sweet-scroll": "^4.0.0"
|
"sweet-scroll": "^4.0.0"
|
||||||
},
|
},
|
||||||
|
@ -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 { setupGlobalTheme } from './domtools.css.theme';
|
import { ThemeManager } from './domtools.classes.thememanager';
|
||||||
|
|
||||||
export interface IDomToolsState {
|
export interface IDomToolsState {
|
||||||
virtualViewport: TViewport;
|
virtualViewport: TViewport;
|
||||||
@ -24,9 +24,6 @@ export class DomTools {
|
|||||||
globalThis.deesDomTools = new DomTools();
|
globalThis.deesDomTools = new DomTools();
|
||||||
domToolsInstance = globalThis.deesDomTools;
|
domToolsInstance = globalThis.deesDomTools;
|
||||||
|
|
||||||
// lets setup theming
|
|
||||||
setupGlobalTheme(domToolsInstance);
|
|
||||||
|
|
||||||
// lets make sure the dom is ready
|
// lets make sure the dom is ready
|
||||||
const readyStateChangedFunc = () => {
|
const readyStateChangedFunc = () => {
|
||||||
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
||||||
@ -47,7 +44,7 @@ export class DomTools {
|
|||||||
/**
|
/**
|
||||||
* if you can, use the static asysnc .setupDomTools() function instead since it is safer to use.
|
* if you can, use the static asysnc .setupDomTools() function instead since it is safer to use.
|
||||||
*/
|
*/
|
||||||
public static getGlobalDomToolsSync() {
|
public static getGlobalDomToolsSync(): DomTools {
|
||||||
const globalDomTools: DomTools = globalThis.deesDomTools;
|
const globalDomTools: DomTools = globalThis.deesDomTools;
|
||||||
if (!globalDomTools) {
|
if (!globalDomTools) {
|
||||||
throw new Error('You tried to access domtools synchronously too early');
|
throw new Error('You tried to access domtools synchronously too early');
|
||||||
@ -67,6 +64,12 @@ export class DomTools {
|
|||||||
bodyElement: null,
|
bodyElement: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public websetup: WebSetup = new WebSetup({
|
||||||
|
metaObject: {
|
||||||
|
title: 'loading...',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
public smartstate = new plugins.smartstate.Smartstate();
|
public smartstate = new plugins.smartstate.Smartstate();
|
||||||
public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', {
|
public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', {
|
||||||
virtualViewport: 'native',
|
virtualViewport: 'native',
|
||||||
@ -77,10 +80,15 @@ export class DomTools {
|
|||||||
});
|
});
|
||||||
|
|
||||||
public convenience = {
|
public convenience = {
|
||||||
|
|
||||||
smartdelay: plugins.smartdelay,
|
smartdelay: plugins.smartdelay,
|
||||||
};
|
};
|
||||||
|
|
||||||
public scroller: plugins.SweetScroll;
|
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) => {
|
||||||
@ -94,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();
|
||||||
@ -139,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) {
|
||||||
const websetup = new plugins.websetup.WebSetup(optionsArg);
|
await this.websetup.setup(optionsArg);
|
||||||
await websetup.setup();
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -1,27 +1,31 @@
|
|||||||
import { DomTools } from './domtools.classes.domtools';
|
import { DomTools } from './domtools.classes.domtools';
|
||||||
|
|
||||||
export const setupGlobalTheme = (domToolsInstance: DomTools) => {
|
/**
|
||||||
const styles = `
|
* changes scrollbar styles to be consistent across OS borders
|
||||||
/* width */
|
*/
|
||||||
::-webkit-scrollbar {
|
export const scrollBarStyles = (() => {
|
||||||
width: 8px;
|
const returnStyles =
|
||||||
}
|
navigator.userAgent.indexOf('Windows') !== -1
|
||||||
|
? `
|
||||||
/* Track */
|
/* width */
|
||||||
::-webkit-scrollbar-track {
|
::-webkit-scrollbar {
|
||||||
background: #111;
|
width: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle */
|
|
||||||
::-webkit-scrollbar-thumb {
|
|
||||||
background: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Handle on hover */
|
|
||||||
::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: #777;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
domToolsInstance.setGlobalStyles(styles);
|
/* Track */
|
||||||
};
|
::-webkit-scrollbar-track {
|
||||||
|
background: #111;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle */
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
background: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle on hover */
|
||||||
|
::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #777;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
: ``;
|
||||||
|
})();
|
||||||
|
@ -1,13 +1,37 @@
|
|||||||
import * as plugins from './domtools.plugins';
|
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 { 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
|
||||||
|
*/
|
||||||
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}
|
||||||
</style>
|
</style>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -15,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(`
|
||||||
@ -39,7 +69,14 @@ export const setup = async () => {
|
|||||||
|
|
||||||
// Roboto Font
|
// Roboto Font
|
||||||
domTools.setGlobalStyles(`
|
domTools.setGlobalStyles(`
|
||||||
@import url('https://fonts.googleapis.com/css?family=Roboto');
|
@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}
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
return domTools;
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
// api glbal scope
|
// designestate scope
|
||||||
|
import * as deesComms from '@designestate/dees-comms';
|
||||||
|
|
||||||
|
export { deesComms };
|
||||||
|
|
||||||
|
// apiglobal scope
|
||||||
import * as typedrequest from '@apiglobal/typedrequest';
|
import * as typedrequest from '@apiglobal/typedrequest';
|
||||||
|
|
||||||
export { typedrequest };
|
export { typedrequest };
|
||||||
@ -7,11 +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';
|
||||||
|
|
||||||
export { smartdelay, smartpromise, smartrouter, smartstate, webrequest, websetup };
|
// 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