fix body + css

This commit is contained in:
Talon Poole 2021-02-20 21:57:13 +00:00
parent 692fd5fe91
commit 88f1bb3c8b
2 changed files with 20 additions and 14 deletions

32
css.js
View file

@ -20,23 +20,29 @@ export function style(options) {
export const inline = (options) => {
const rules = load(options);
return function inlineCSS(tag) {
if (!options.inline || options.css === "none") return "";
const styles = reduceVariables(rules, options)
.filter(({ selectors }) => selectors && selectors.includes(tag))
.reduce((style, { declarations }) => {
declarations.forEach(({ property, value }) => {
style = `${style}${property}:${value};`;
});
return style;
}, "");
return styles !== "" ? ` style="${styles}"` : "";
if ((options.body || options.inline) && options.css !== "none") {
const styles = reduceVariables(rules, options)
.filter(({ selectors }) => selectors && selectors.includes(tag))
.reduce((style, { declarations }) => {
declarations.forEach(({ property, value }) => {
style = `${style}${property}:${value};`;
});
return style;
}, "");
return styles !== "" ? ` style="${styles}"` : "";
} else {
return "";
}
};
};
export function load(options) {
options.css =
options.css ||
(!options.body || !options.inline ? "gmi-web.css" : "gmi.css");
if (options.css === "none") return [];
options.css = options.css
? options.css
: options.body
? "gmi.css"
: "gmi-web.css";
if (
["gmi.css", "gmi-web.css"].includes(options.css) ||
existsSync(options.css)

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "gmi-web-cli",
"version": "1.0.0-rc.3",
"version": "1.0.2-rc.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {