@pushwoosh/dumb-components 1.0.68 → 1.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/polyglot/liquid/render.js +16 -1
package/package.json
CHANGED
|
@@ -77,6 +77,13 @@ export function renderToString(ast, context) {
|
|
|
77
77
|
const outArr = renderNodesToArray(ast, context, (tagNode, children) => [`<${tagNode.name} ${Object.entries(tagNode.params).map(([key, value]) => `${key}=${stringifyScalarOrVariable(value)}`).join(' ')}>`, ...children, `</${tagNode.name}>`]);
|
|
78
78
|
return outArr.join('');
|
|
79
79
|
}
|
|
80
|
+
function getColor(color) {
|
|
81
|
+
const colorValue = Color[color];
|
|
82
|
+
if (colorValue) {
|
|
83
|
+
return colorValue;
|
|
84
|
+
}
|
|
85
|
+
return color;
|
|
86
|
+
}
|
|
80
87
|
export function renderToReact(ast, context) {
|
|
81
88
|
return renderNodesToArray(ast, context, (tagNode, children, key) => {
|
|
82
89
|
const TagName = tagNode.name;
|
|
@@ -84,7 +91,15 @@ export function renderToReact(ast, context) {
|
|
|
84
91
|
if (TagName === 'text') {
|
|
85
92
|
return [React.createElement(Text, {
|
|
86
93
|
"$variant": props.variant,
|
|
87
|
-
"$color":
|
|
94
|
+
"$color": getColor(props.color),
|
|
95
|
+
key: key
|
|
96
|
+
}, children)];
|
|
97
|
+
}
|
|
98
|
+
if (TagName === 'color') {
|
|
99
|
+
return [React.createElement("span", {
|
|
100
|
+
style: {
|
|
101
|
+
color: getColor(props.color)
|
|
102
|
+
},
|
|
88
103
|
key: key
|
|
89
104
|
}, children)];
|
|
90
105
|
}
|