fix body + css
This commit is contained in:
parent
692fd5fe91
commit
88f1bb3c8b
32
css.js
32
css.js
|
@ -20,23 +20,29 @@ export function style(options) {
|
||||||
export const inline = (options) => {
|
export const inline = (options) => {
|
||||||
const rules = load(options);
|
const rules = load(options);
|
||||||
return function inlineCSS(tag) {
|
return function inlineCSS(tag) {
|
||||||
if (!options.inline || options.css === "none") return "";
|
if ((options.body || options.inline) && options.css !== "none") {
|
||||||
const styles = reduceVariables(rules, options)
|
const styles = reduceVariables(rules, options)
|
||||||
.filter(({ selectors }) => selectors && selectors.includes(tag))
|
.filter(({ selectors }) => selectors && selectors.includes(tag))
|
||||||
.reduce((style, { declarations }) => {
|
.reduce((style, { declarations }) => {
|
||||||
declarations.forEach(({ property, value }) => {
|
declarations.forEach(({ property, value }) => {
|
||||||
style = `${style}${property}:${value};`;
|
style = `${style}${property}:${value};`;
|
||||||
});
|
});
|
||||||
return style;
|
return style;
|
||||||
}, "");
|
}, "");
|
||||||
return styles !== "" ? ` style="${styles}"` : "";
|
return styles !== "" ? ` style="${styles}"` : "";
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function load(options) {
|
export function load(options) {
|
||||||
options.css =
|
if (options.css === "none") return [];
|
||||||
options.css ||
|
options.css = options.css
|
||||||
(!options.body || !options.inline ? "gmi-web.css" : "gmi.css");
|
? options.css
|
||||||
|
: options.body
|
||||||
|
? "gmi.css"
|
||||||
|
: "gmi-web.css";
|
||||||
if (
|
if (
|
||||||
["gmi.css", "gmi-web.css"].includes(options.css) ||
|
["gmi.css", "gmi-web.css"].includes(options.css) ||
|
||||||
existsSync(options.css)
|
existsSync(options.css)
|
||||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "gmi-web-cli",
|
"name": "gmi-web-cli",
|
||||||
"version": "1.0.0-rc.3",
|
"version": "1.0.2-rc.3",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
Loading…
Reference in a new issue