Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
5aee15a23b | |||
38d78b4e12 | |||
ec36a516c0 | |||
1c844d35ca | |||
ecb387f59e |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@designestate/dees-domtools",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.11",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@designestate/dees-domtools",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.11",
|
||||
"private": false,
|
||||
"description": "tools to simplify complex css structures",
|
||||
"main": "dist_ts/index.js",
|
||||
|
5
ts/domtools.classes.domtools.ts
Normal file
5
ts/domtools.classes.domtools.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export class DeesDomTools {
|
||||
public static createDomTools = () => {
|
||||
globalThis.deesDomTools = new DeesDomTools();
|
||||
}
|
||||
}
|
7
ts/domtools.css.ts
Normal file
7
ts/domtools.css.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export const cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number) => {
|
||||
let returnString = ``;
|
||||
for (let i = 0; i < amountOfColumnsArg; i++) {
|
||||
returnString += ` calc((100%/${amountOfColumnsArg}) - (${gapSizeArg * (amountOfColumnsArg - 1)}px/${amountOfColumnsArg}))`;
|
||||
}
|
||||
return returnString;
|
||||
};
|
@ -1,5 +1,12 @@
|
||||
import { defer } from '@pushrocks/smartpromise';
|
||||
|
||||
const createStyleElement = (headElement: HTMLElement, styleText: string) => {
|
||||
const styleElement = document.createElement('style');
|
||||
styleElement.type = 'text/css';
|
||||
styleElement.appendChild(document.createTextNode(styleText));
|
||||
headElement.appendChild(styleElement);
|
||||
};
|
||||
|
||||
/**
|
||||
* a basic setup for elements
|
||||
* makes sure everything is in check
|
||||
@ -13,7 +20,7 @@ export const elementBasicSetup = async () => {
|
||||
|
||||
// lets make sure the dom is ready
|
||||
const documentReady = defer();
|
||||
document.onreadystatechange = () => {
|
||||
const readyStateChangedFunc = () => {
|
||||
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
||||
console.log('elementBasicSetup: element basic setup complete')
|
||||
documentReady.resolve();
|
||||
@ -21,6 +28,7 @@ export const elementBasicSetup = async () => {
|
||||
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!');
|
||||
@ -29,8 +37,18 @@ export const elementBasicSetup = async () => {
|
||||
const head = document.querySelector('head');
|
||||
const body = document.querySelector('body');
|
||||
|
||||
// bodyStyles
|
||||
const bodyStyles = `
|
||||
body {
|
||||
margin: 0px;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
`;
|
||||
createStyleElement(head, bodyStyles);
|
||||
|
||||
// material font
|
||||
const materialFontCss = `
|
||||
const materialFontStyles = `
|
||||
@font-face {
|
||||
font-family: 'Material Icons';
|
||||
font-style: normal;
|
||||
@ -38,11 +56,13 @@ export const elementBasicSetup = async () => {
|
||||
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);
|
||||
createStyleElement(head, materialFontStyles);
|
||||
|
||||
// Roboto Font
|
||||
const robotoFontCss = `
|
||||
@import url('https://fonts.googleapis.com/css?family=Roboto');
|
||||
`;
|
||||
createStyleElement(head, robotoFontCss);
|
||||
|
||||
globalThis.deesCssToolsReady.resolve();
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
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';
|
||||
import * as css from './domtools.css';
|
||||
|
||||
export {
|
||||
css,
|
||||
breakpoints
|
||||
};
|
||||
|
Reference in New Issue
Block a user