mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-20 20:00:33 +03:00
refactor(preset-html5): optimize style tag functions
This commit is contained in:
@@ -6,20 +6,17 @@ const isTagNode = node => (typeof node === 'object' && Boolean(node.tag));
|
|||||||
const isTagOf = (node, type) => (node.tag === type);
|
const isTagOf = (node, type) => (node.tag === type);
|
||||||
const createTagNode = tag => ({ tag, attrs: {}, content: [] });
|
const createTagNode = tag => ({ tag, attrs: {}, content: [] });
|
||||||
|
|
||||||
const getStyleFromAttrs = (attrs) => {
|
const styleMap = {
|
||||||
const styles = [];
|
color: val => `color:${val};`,
|
||||||
|
size: val => `font-size:${val};`,
|
||||||
if (attrs.color) {
|
|
||||||
styles.push(`color:${attrs.color};`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attrs.size) {
|
|
||||||
styles.push(`font-size:${attrs.size};`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return styles.join(' ');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getStyleFromAttrs = attrs =>
|
||||||
|
Object
|
||||||
|
.keys(attrs)
|
||||||
|
.reduce((acc, key) => (styleMap[key] ? acc.concat(styleMap[key](attrs[key])) : acc), [])
|
||||||
|
.join(' ');
|
||||||
|
|
||||||
const asListItems = (content) => {
|
const asListItems = (content) => {
|
||||||
const listItems = [];
|
const listItems = [];
|
||||||
let listIdx = 0;
|
let listIdx = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user