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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user