@pushwoosh/dumb-components 1.0.68 → 1.0.70

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.0.68",
3
+ "version": "1.0.70",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
+ import styled from 'styled-components';
2
3
  import { Color } from '@pushwoosh/kit-constants';
3
- import { Text } from '@pushwoosh/kit-typography';
4
+ import { variants } from '@pushwoosh/kit-typography/map';
4
5
  import { filters } from './filters';
5
6
  import { stringifyScalarOrVariable, unpackScalarOrValue } from './helpers';
6
7
  import { ifOperatorFns } from './parser';
@@ -77,14 +78,29 @@ export function renderToString(ast, context) {
77
78
  const outArr = renderNodesToArray(ast, context, (tagNode, children) => [`<${tagNode.name} ${Object.entries(tagNode.params).map(([key, value]) => `${key}=${stringifyScalarOrVariable(value)}`).join(' ')}>`, ...children, `</${tagNode.name}>`]);
78
79
  return outArr.join('');
79
80
  }
81
+ function getColor(color) {
82
+ const colorValue = Color[color];
83
+ if (colorValue) {
84
+ return colorValue;
85
+ }
86
+ return color;
87
+ }
88
+ const Txt = styled.span.withConfig({
89
+ displayName: "Txt",
90
+ componentId: "sc-nm71u5-0"
91
+ })(["", " ", ""], ({
92
+ $color
93
+ }) => $color && `color: ${$color};`, ({
94
+ $variant
95
+ }) => $variant && variants[$variant]);
80
96
  export function renderToReact(ast, context) {
81
97
  return renderNodesToArray(ast, context, (tagNode, children, key) => {
82
98
  const TagName = tagNode.name;
83
99
  const props = Object.fromEntries(Object.entries(tagNode.params).map(([key, value]) => [key, unpackScalarOrValue(value, context)]));
84
100
  if (TagName === 'text') {
85
- return [React.createElement(Text, {
101
+ return [React.createElement(Txt, {
86
102
  "$variant": props.variant,
87
- "$color": props.color && (Color[props.color] ?? props.color),
103
+ "$color": getColor(props.color),
88
104
  key: key
89
105
  }, children)];
90
106
  }