2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-05-15 11:59:37 +03:00

refactor(preset-html5): optimize style tag functions

This commit is contained in:
Nikolay Kostyurin
2018-08-06 02:44:27 +02:00
parent 064a37372b
commit 1aed2a684b
+9 -12
View File
@@ -6,20 +6,17 @@ const isTagNode = node => (typeof node === 'object' && Boolean(node.tag));
const isTagOf = (node, type) => (node.tag === type);
const createTagNode = tag => ({ tag, attrs: {}, content: [] });
const getStyleFromAttrs = (attrs) => {
const styles = [];
if (attrs.color) {
styles.push(`color:${attrs.color};`);
}
if (attrs.size) {
styles.push(`font-size:${attrs.size};`);
}
return styles.join(' ');
const styleMap = {
color: val => `color:${val};`,
size: val => `font-size:${val};`,
};
const getStyleFromAttrs = attrs =>
Object
.keys(attrs)
.reduce((acc, key) => (styleMap[key] ? acc.concat(styleMap[key](attrs[key])) : acc), [])
.join(' ');
const asListItems = (content) => {
const listItems = [];
let listIdx = 0;