Compare commits

...

44 Commits

Author SHA1 Message Date
5657b0be1d 1.0.96 2021-09-27 12:35:39 +02:00
781ae3c3b1 fix(core): update 2021-09-27 12:35:39 +02:00
da79e623cc 1.0.95 2021-09-16 16:49:24 +02:00
3ca6b5e34e fix(core): update 2021-09-16 16:49:24 +02:00
98f0bc013d 1.0.94 2021-09-13 20:35:34 +02:00
d32a544de2 fix(core): update 2021-09-13 20:35:33 +02:00
070221d6c9 1.0.93 2021-09-08 23:10:04 +02:00
19714854ba fix(core): update 2021-09-08 23:10:04 +02:00
50ebea1b5f 1.0.92 2021-09-08 22:42:33 +02:00
df0527f3c1 fix(core): update 2021-09-08 22:42:32 +02:00
b620b7393e 1.0.91 2021-09-01 21:05:55 +02:00
ab5b9511fd fix(core): update 2021-09-01 21:05:54 +02:00
da86e64056 1.0.90 2021-09-01 00:37:05 +02:00
effc331a67 fix(core): update 2021-09-01 00:37:05 +02:00
fa24708a47 1.0.89 2021-08-26 20:24:29 +02:00
31126e30eb fix(core): update 2021-08-26 20:24:28 +02:00
ef0a4eae80 1.0.88 2021-08-19 22:12:22 +02:00
e711302c28 fix(core): update 2021-08-19 22:12:22 +02:00
1cfc07fe8e 1.0.87 2021-03-28 21:51:12 +00:00
7f221c1a8c fix(core): update 2021-03-28 21:51:11 +00:00
09f927c0d4 1.0.86 2021-03-10 17:01:33 +00:00
1042e79625 fix(core): update 2021-03-10 17:01:32 +00:00
fced2efcbd 1.0.85 2021-03-10 16:57:26 +00:00
83fe1d62e7 fix(core): update 2021-03-10 16:57:25 +00:00
78bce9600c 1.0.84 2020-12-07 23:23:02 +00:00
2860b5b6e0 fix(core): update 2020-12-07 23:23:02 +00:00
b802935d27 1.0.83 2020-12-07 21:54:54 +00:00
b73a702b74 fix(core): update 2020-12-07 21:54:53 +00:00
b3deb31ab5 1.0.82 2020-12-07 05:25:26 +00:00
6ea5482e3d fix(core): update 2020-12-07 05:25:25 +00:00
0ead7215ff 1.0.81 2020-12-07 03:47:39 +00:00
286bb0887a fix(core): update 2020-12-07 03:47:39 +00:00
4456f00816 1.0.80 2020-12-07 03:13:34 +00:00
b60a1bebe0 fix(core): update 2020-12-07 03:13:34 +00:00
94127227a6 1.0.79 2020-12-01 21:06:54 +00:00
b5af1b1226 fix(core): update 2020-12-01 21:06:53 +00:00
a6f382dd7f 1.0.78 2020-12-01 17:31:38 +00:00
0de00cb2c1 fix(core): update 2020-12-01 17:31:37 +00:00
570a026cf8 1.0.77 2020-11-30 20:03:05 +00:00
48b5cc770c fix(core): update 2020-11-30 20:03:05 +00:00
7ae2de5843 1.0.76 2020-11-30 10:25:00 +00:00
e4d87ae882 fix(core): update 2020-11-30 10:25:00 +00:00
259a669e24 1.0.75 2020-11-29 23:56:20 +00:00
bf461dd1a0 fix(core): update 2020-11-29 23:56:19 +00:00
9 changed files with 18813 additions and 3974 deletions

22630
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@designestate/dees-domtools", "name": "@designestate/dees-domtools",
"version": "1.0.74", "version": "1.0.96",
"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.9", "@types/node": "^16.10.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.58",
"@designestate/dees-comms": "^1.0.7", "@designestate/dees-comms": "^1.0.10",
"@pushrocks/lik": "^4.0.20", "@pushrocks/lik": "^5.0.0",
"@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.11", "@pushrocks/websetup": "^3.0.15",
"@pushrocks/webstore": "^1.0.16", "@pushrocks/webstore": "^1.0.16",
"lit-element": "^2.4.0", "lit-element": "^3.0.0",
"sweet-scroll": "^4.0.0" "sweet-scroll": "^4.0.0"
}, },
"files": [ "files": [

View File

@ -4,9 +4,7 @@ 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 { ElementInstrumenter } from './domtools.classes.elementinstrumenter';
import { ThemeManager } from './domtools.classes.thememanager'; import { ThemeManager } from './domtools.classes.thememanager';
export interface IDomToolsState { export interface IDomToolsState {
@ -82,11 +80,10 @@ export class DomTools {
}); });
public convenience = { public convenience = {
typedrequest: plugins.typedrequest,
smartdelay: plugins.smartdelay, smartdelay: plugins.smartdelay,
}; };
public elementInstrumenter = new ElementInstrumenter();
public deesComms = new plugins.deesComms.DeesComms(); public deesComms = new plugins.deesComms.DeesComms();
public scroller = new plugins.SweetScroll({ public scroller = new plugins.SweetScroll({
/* some options */ /* some options */
@ -143,6 +140,14 @@ 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);
} }

View File

@ -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);
}
}
}

View File

@ -4,37 +4,29 @@ import * as plugins from './domtools.plugins';
export class ThemeManager { export class ThemeManager {
public domtoolsRef: DomTools; public domtoolsRef: DomTools;
public goBrightBoolean = false; public goBrightBoolean = false;
public preferredColorSchemeMediaMatch = window.matchMedia('(prefers-color-scheme: light)'); public preferredColorSchemeMediaMatch = window.matchMedia('(prefers-color-scheme: light)');
public themeObservable = new plugins.smartrx.rxjs.ReplaySubject<boolean>(1);
constructor(domtoolsRefArg: DomTools) { constructor(domtoolsRefArg: DomTools) {
this.domtoolsRef = domtoolsRefArg; this.domtoolsRef = domtoolsRefArg;
// lets take care of elements being added that need to know of the current theme
this.domtoolsRef.elementInstrumenter.connectedElements.eventSubject.subscribe(async eventData => {
await this.setThemeStatusForElement(eventData.payload, this.goBrightBoolean);
});
// lets care // lets care
this.goBrightBoolean = this.preferredColorSchemeMediaMatch.matches; this.goBrightBoolean = this.preferredColorSchemeMediaMatch.matches;
this.preferredColorSchemeMediaMatch.addEventListener('change', eventArg => { this.preferredColorSchemeMediaMatch.addEventListener('change', (eventArg) => {
this.goBrightBoolean = eventArg.matches; this.goBrightBoolean = eventArg.matches;
this.updateAllConnectedElements(); this.updateAllConnectedElements();
}); });
} this.updateAllConnectedElements();
private async setThemeStatusForElement (elementArg: LitElement, goBrightBool: boolean) {
const goBright = (elementArg as any).goBright;
if (typeof goBright === 'boolean') {
(elementArg as any).goBright = goBrightBool;
}
} }
private async updateAllConnectedElements() { private async updateAllConnectedElements() {
this.domtoolsRef.elementInstrumenter.forEachelement(async elementArg => { if (document.body && document.body.style) {
await this.setThemeStatusForElement(elementArg, this.goBrightBoolean); document.body.style.background = this.goBrightBoolean ? '#fff' : '#000';
}); }
this.themeObservable.next(this.goBrightBoolean);
} }
public goBright() { public goBright() {
@ -51,4 +43,4 @@ export class ThemeManager {
this.goBrightBoolean = !this.goBrightBoolean; this.goBrightBoolean = !this.goBrightBoolean;
this.updateAllConnectedElements(); this.updateAllConnectedElements();
} }
} }

View File

@ -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;
} }
` : ``; `
: ``;
})(); })();

View File

@ -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, 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 * styles to be included in every webcomponent
@ -11,10 +24,13 @@ export const styles = html`
<style> <style>
* { * {
transition: background 0.1s, color 0.1s; transition: background 0.1s, color 0.1s;
font-family: 'Roboto', sans-serif;
box-sizing: border-box; box-sizing: border-box;
} }
:host {
font-family: 'Roboto', sans-serif;
}
${scrollBarStyles} ${scrollBarStyles}
</style> </style>
`; `;
@ -27,7 +43,8 @@ export const setup = async (elementArg?: LitElement): Promise<DomTools> => {
const domTools = await DomTools.setupDomTools(); const domTools = await DomTools.setupDomTools();
if (elementArg) { if (elementArg) {
domTools.elementInstrumenter.instrumentElement(elementArg); // lets do something with the element
// not used right now
} }
domTools.runOnce('elementBasicSetup', async () => { domTools.runOnce('elementBasicSetup', async () => {

View File

@ -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,18 +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';
// subscope lik // subscope lik
import { ObjectMap } from '@pushrocks/lik/dist_ts/lik.objectmap'; import { ObjectMap } from '@pushrocks/lik/dist_ts/lik.objectmap';
const lik = { 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 // third party scope
import SweetScroll from 'sweet-scroll'; import SweetScroll from 'sweet-scroll';

View File

@ -7,9 +7,14 @@ 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,
smartstate: allPlugins.smartstate
}; };