Compare commits

..

8 Commits

Author SHA1 Message Date
1c844d35ca 1.0.9 2020-05-23 16:55:37 +00:00
ecb387f59e fix(core): update 2020-05-23 16:55:36 +00:00
9b3c92fef5 1.0.8 2020-05-23 16:43:37 +00:00
74cf94a69e fix(core): update 2020-05-23 16:43:36 +00:00
9f76d4e920 1.0.7 2020-05-23 16:36:30 +00:00
082ef21078 fix(core): update 2020-05-23 16:36:29 +00:00
4db0e6f5fc 1.0.6 2020-05-23 15:44:58 +00:00
40b8c5010d fix(core): update 2020-05-23 15:44:58 +00:00
8 changed files with 60 additions and 30 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@designestate/dees-domtools",
"version": "1.0.5",
"version": "1.0.9",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@designestate/dees-domtools",
"version": "1.0.5",
"version": "1.0.9",
"private": false,
"description": "tools to simplify complex css structures",
"main": "dist_ts/index.js",

View File

@ -1,25 +0,0 @@
import { defer } from '@pushrocks/smartpromise';
/**
* a basic setup for elements
* makes sure everything is in check
*/
export const elementBasicSetup = async () => {
if (globalThis.deesCssToolsReady) {
await globalThis.deesCssToolsReady.promise;
} else {
globalThis.deesCssToolsReady = defer();
const documentReady = defer();
document.onreadystatechange = () => {
if (document.readyState === 'interactive') {
documentReady.resolve();
}
};
await documentReady.promise;
const head = document.querySelector('head');
const styleElement = document.createElement('style');
styleElement.type = 'text/css';
styleElement.appendChild(document.createTextNode(materialFontCss));
globalThis.deesCssToolsReady.resolve();
}
};

View File

@ -0,0 +1,5 @@
export class DeesDomTools {
public static createDomTools = () => {
globalThis.deesDomTools = new DeesDomTools();
}
}

View File

@ -0,0 +1,50 @@
import { defer } from '@pushrocks/smartpromise';
/**
* a basic setup for elements
* makes sure everything is in check
*/
export const elementBasicSetup = async () => {
if (globalThis.deesCssToolsReady) {
await globalThis.deesCssToolsReady.promise;
} else {
// lets prevent double execution
globalThis.deesCssToolsReady = defer();
// lets make sure the dom is ready
const documentReady = defer();
const readyStateChangedFunc = () => {
if (document.readyState === 'interactive' || document.readyState === 'complete') {
console.log('elementBasicSetup: element basic setup complete')
documentReady.resolve();
} else {
console.log('elementBasicSetup: document not yet ready');
}
};
document.addEventListener('readystatechange', readyStateChangedFunc);
console.log('elementBasicSetup: waiting for document to be ready');
await documentReady.promise;
console.log('elementBasicSetup: document ready!');
// lets get started
const head = document.querySelector('head');
const body = document.querySelector('body');
// material font
const materialFontCss = `
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/materialicons/v42/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2');
}
`;
const styleElement = document.createElement('style');
styleElement.type = 'text/css';
styleElement.appendChild(document.createTextNode(materialFontCss));
head.appendChild(styleElement);
globalThis.deesCssToolsReady.resolve();
}
};

View File

@ -1,7 +1,7 @@
export * from './csstools.elementbasicsetup';
export * from './csstools.elementbasicstyles';
export * from './domtools.elementbasicsetup';
export * from './domtools.elementbasicstyles';
import * as breakpoints from './csstools.breakpoints';
import * as breakpoints from './domtools.breakpoints';
export {
breakpoints