Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
2671
package-lock.json
generated
2671
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@designestate/dees-domtools",
|
||||
"version": "1.0.73",
|
||||
"version": "1.0.87",
|
||||
"private": false,
|
||||
"description": "tools to simplify complex css structures",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -14,23 +14,24 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsbundle": "^1.0.78",
|
||||
"@gitzone/tsbundle": "^1.0.80",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.14.9",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/node": "^14.14.33",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest": "^1.0.54",
|
||||
"@designestate/dees-comms": "^1.0.7",
|
||||
"@apiglobal/typedrequest": "^1.0.56",
|
||||
"@designestate/dees-comms": "^1.0.9",
|
||||
"@pushrocks/lik": "^4.0.20",
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartpromise": "^3.1.3",
|
||||
"@pushrocks/smartrouter": "^1.0.4",
|
||||
"@pushrocks/smartstate": "^1.0.17",
|
||||
"@pushrocks/smartrouter": "^1.0.7",
|
||||
"@pushrocks/smartrx": "^2.0.19",
|
||||
"@pushrocks/smartstate": "^1.0.21",
|
||||
"@pushrocks/webrequest": "^2.0.13",
|
||||
"@pushrocks/websetup": "^3.0.11",
|
||||
"@pushrocks/websetup": "^3.0.15",
|
||||
"@pushrocks/webstore": "^1.0.16",
|
||||
"lit-element": "^2.4.0",
|
||||
"sweet-scroll": "^4.0.0"
|
||||
|
@ -6,7 +6,6 @@ import { TViewport } from './domtools.breakpoints';
|
||||
import { Scroller } from './domtools.classes.scroller';
|
||||
import { delayForRandom } from '@pushrocks/smartdelay';
|
||||
import { WebSetup } from '@pushrocks/websetup';
|
||||
import { ElementInstrumenter } from './domtools.classes.elementinstrumenter';
|
||||
import { ThemeManager } from './domtools.classes.thememanager';
|
||||
|
||||
export interface IDomToolsState {
|
||||
@ -85,8 +84,6 @@ export class DomTools {
|
||||
smartdelay: plugins.smartdelay,
|
||||
};
|
||||
|
||||
|
||||
public elementInstrumenter = new ElementInstrumenter();
|
||||
public deesComms = new plugins.deesComms.DeesComms();
|
||||
public scroller = new plugins.SweetScroll({
|
||||
/* some options */
|
||||
@ -143,6 +140,14 @@ export class DomTools {
|
||||
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) {
|
||||
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
import * as plugins from './domtools.plugins';
|
||||
import { LitElement } from 'lit-element';
|
||||
|
||||
export class ElementInstrumenter {
|
||||
connectedElements = new plugins.lik.ObjectMap<LitElement>();
|
||||
|
||||
public instrumentElement(elementArg: LitElement) {
|
||||
const addToConnectedElementsFunc = (eventArg: CustomEvent) => {
|
||||
this.connectedElements.add(elementArg);
|
||||
};
|
||||
const removeFromConnectedElementsFunc = eventArg => {
|
||||
this.connectedElements.remove(elementArg);
|
||||
elementArg.removeEventListener('domtools-connected', addToConnectedElementsFunc);
|
||||
elementArg.removeEventListener('domtools-disconnected', removeFromConnectedElementsFunc);
|
||||
};
|
||||
elementArg.addEventListener('domtools-connected', addToConnectedElementsFunc);
|
||||
elementArg.addEventListener('domtools-disconnected', removeFromConnectedElementsFunc);
|
||||
|
||||
if (elementArg.parentElement) {
|
||||
this.connectedElements.add(elementArg);
|
||||
}
|
||||
}
|
||||
|
||||
public async forEachelement(eachFuncArg: (elementArg: LitElement) => Promise<void>) {
|
||||
for (const elementArg of this.connectedElements.getArray()) {
|
||||
await eachFuncArg(elementArg);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,25 +6,27 @@ 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;
|
||||
this.domtoolsRef.elementInstrumenter.connectedElements.eventSubject.subscribe(async eventData => {
|
||||
await this.setThemeStatusForElement(eventData.payload, this.goBrightBoolean);
|
||||
});
|
||||
}
|
||||
|
||||
private async setThemeStatusForElement (elementArg: LitElement, goBrightBool: boolean) {
|
||||
const goBright = (elementArg as any).goBright;
|
||||
if (typeof goBright === 'boolean') {
|
||||
(elementArg as any).goBright = goBrightBool;
|
||||
}
|
||||
// lets care
|
||||
this.goBrightBoolean = this.preferredColorSchemeMediaMatch.matches;
|
||||
this.preferredColorSchemeMediaMatch.addEventListener('change', (eventArg) => {
|
||||
this.goBrightBoolean = eventArg.matches;
|
||||
this.updateAllConnectedElements();
|
||||
});
|
||||
this.updateAllConnectedElements();
|
||||
}
|
||||
|
||||
private async updateAllConnectedElements() {
|
||||
this.domtoolsRef.elementInstrumenter.forEachelement(async elementArg => {
|
||||
await this.setThemeStatusForElement(elementArg, this.goBrightBoolean);
|
||||
});
|
||||
if (document.body && document.body.style) {
|
||||
document.body.style.background = this.goBrightBoolean ? '#fff' : '#000';
|
||||
}
|
||||
this.themeObservable.next(this.goBrightBoolean);
|
||||
}
|
||||
|
||||
public goBright() {
|
||||
|
@ -4,7 +4,9 @@ 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 ? `
|
||||
const returnStyles =
|
||||
navigator.userAgent.indexOf('Windows') !== -1
|
||||
? `
|
||||
/* width */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
@ -24,5 +26,6 @@ export const scrollBarStyles = (() => {
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #777;
|
||||
}
|
||||
` : ``;
|
||||
`
|
||||
: ``;
|
||||
})();
|
||||
|
@ -2,7 +2,20 @@ import * as plugins from './domtools.plugins';
|
||||
import { DomTools } from './domtools.classes.domtools';
|
||||
import { scrollBarStyles } from './domtools.css.theme';
|
||||
|
||||
import { html, LitElement } 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
|
||||
@ -11,10 +24,13 @@ export const styles = html`
|
||||
<style>
|
||||
* {
|
||||
transition: background 0.1s, color 0.1s;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:host {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
${scrollBarStyles}
|
||||
</style>
|
||||
`;
|
||||
@ -27,7 +43,8 @@ export const setup = async (elementArg?: LitElement): Promise<DomTools> => {
|
||||
const domTools = await DomTools.setupDomTools();
|
||||
|
||||
if (elementArg) {
|
||||
domTools.elementInstrumenter.instrumentElement(elementArg);
|
||||
// lets do something with the element
|
||||
// not used right now
|
||||
}
|
||||
|
||||
domTools.runOnce('elementBasicSetup', async () => {
|
||||
|
@ -1,9 +1,7 @@
|
||||
// designestate scope
|
||||
import * as deesComms from '@designestate/dees-comms';
|
||||
|
||||
export {
|
||||
deesComms
|
||||
};
|
||||
export { deesComms };
|
||||
|
||||
// apiglobal scope
|
||||
import * as typedrequest from '@apiglobal/typedrequest';
|
||||
@ -14,6 +12,7 @@ export { typedrequest };
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrouter from '@pushrocks/smartrouter';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
import * as smartstate from '@pushrocks/smartstate';
|
||||
import * as webrequest from '@pushrocks/webrequest';
|
||||
import * as websetup from '@pushrocks/websetup';
|
||||
@ -22,10 +21,20 @@ import * as webstore from '@pushrocks/webstore';
|
||||
// subscope lik
|
||||
import { ObjectMap } from '@pushrocks/lik/dist_ts/lik.objectmap';
|
||||
const lik = {
|
||||
ObjectMap
|
||||
ObjectMap,
|
||||
};
|
||||
|
||||
export { lik, smartdelay, smartpromise, smartrouter, smartstate, webrequest, websetup, webstore };
|
||||
export {
|
||||
lik,
|
||||
smartdelay,
|
||||
smartpromise,
|
||||
smartrouter,
|
||||
smartrx,
|
||||
smartstate,
|
||||
webrequest,
|
||||
websetup,
|
||||
webstore,
|
||||
};
|
||||
|
||||
// third party scope
|
||||
import SweetScroll from 'sweet-scroll';
|
||||
|
@ -7,6 +7,7 @@ import * as css from './domtools.css';
|
||||
export { css, breakpoints, elementBasic };
|
||||
export { DomTools } from './domtools.classes.domtools';
|
||||
export { TypedRequest } from '@apiglobal/typedrequest';
|
||||
export { IWebSetupConstructorOptions } from '@pushrocks/websetup';
|
||||
|
||||
import * as allPlugins from './domtools.plugins';
|
||||
|
||||
|
Reference in New Issue
Block a user