@cssxjs/css-to-react-native 3.2.0-0

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.
Files changed (44) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +115 -0
  3. package/index.d.ts +17 -0
  4. package/index.js +930 -0
  5. package/package.json +68 -0
  6. package/src/TokenStream.js +74 -0
  7. package/src/__tests__/aspectRatio.js +23 -0
  8. package/src/__tests__/border.js +141 -0
  9. package/src/__tests__/borderColor.js +92 -0
  10. package/src/__tests__/boxModel.js +136 -0
  11. package/src/__tests__/boxShadow.js +167 -0
  12. package/src/__tests__/colors.js +31 -0
  13. package/src/__tests__/flex.js +122 -0
  14. package/src/__tests__/flexFlow.js +22 -0
  15. package/src/__tests__/font.js +117 -0
  16. package/src/__tests__/fontFamily.js +43 -0
  17. package/src/__tests__/fontVariant.js +15 -0
  18. package/src/__tests__/fontWeight.js +8 -0
  19. package/src/__tests__/index.js +238 -0
  20. package/src/__tests__/placeContent.js +19 -0
  21. package/src/__tests__/shadowOffsets.js +13 -0
  22. package/src/__tests__/textDecoration.js +165 -0
  23. package/src/__tests__/textDecorationLine.js +23 -0
  24. package/src/__tests__/textShadow.js +107 -0
  25. package/src/__tests__/transform.js +69 -0
  26. package/src/__tests__/units.js +132 -0
  27. package/src/devPropertiesWithoutUnitsRegExp.js +19 -0
  28. package/src/index.js +90 -0
  29. package/src/tokenTypes.js +112 -0
  30. package/src/transforms/aspectRatio.js +12 -0
  31. package/src/transforms/border.js +57 -0
  32. package/src/transforms/boxShadow.js +11 -0
  33. package/src/transforms/flex.js +65 -0
  34. package/src/transforms/flexFlow.js +37 -0
  35. package/src/transforms/font.js +63 -0
  36. package/src/transforms/fontFamily.js +20 -0
  37. package/src/transforms/fontVariant.js +14 -0
  38. package/src/transforms/index.js +78 -0
  39. package/src/transforms/placeContent.js +24 -0
  40. package/src/transforms/textDecoration.js +56 -0
  41. package/src/transforms/textDecorationLine.js +18 -0
  42. package/src/transforms/textShadow.js +10 -0
  43. package/src/transforms/transform.js +74 -0
  44. package/src/transforms/util.js +103 -0
@@ -0,0 +1,31 @@
1
+ import transformCss from '..'
2
+
3
+ it('transforms hex colors', () => {
4
+ expect(transformCss([['color', '#f00']])).toEqual({ color: '#f00' })
5
+ })
6
+
7
+ it('transforms rgb colors', () => {
8
+ expect(transformCss([['color', 'rgb(255, 0, 0)']])).toEqual({
9
+ color: 'rgb(255, 0, 0)',
10
+ })
11
+ })
12
+
13
+ it('transforms transparent color', () => {
14
+ expect(transformCss([['color', 'transparent']])).toEqual({
15
+ color: 'transparent',
16
+ })
17
+ })
18
+
19
+ it('transforms border shorthand with transparent color', () => {
20
+ expect(transformCss([['border', '2px dashed transparent']])).toEqual({
21
+ borderColor: 'transparent',
22
+ borderStyle: 'dashed',
23
+ borderWidth: 2,
24
+ })
25
+ })
26
+
27
+ it('transforms background shorthand with transparent color', () => {
28
+ expect(transformCss([['background', 'transparent']])).toEqual({
29
+ backgroundColor: 'transparent',
30
+ })
31
+ })
@@ -0,0 +1,122 @@
1
+ import transformCss from '..'
2
+
3
+ it('transforms flex shorthand with 3 values', () => {
4
+ expect(transformCss([['flex', '1 2 3px']])).toEqual({
5
+ flexGrow: 1,
6
+ flexShrink: 2,
7
+ flexBasis: 3,
8
+ })
9
+ })
10
+
11
+ it('transforms flex shorthand with 3 values in reverse order', () => {
12
+ expect(transformCss([['flex', '3px 1 2']])).toEqual({
13
+ flexGrow: 1,
14
+ flexShrink: 2,
15
+ flexBasis: 3,
16
+ })
17
+ })
18
+
19
+ it('transforms flex shorthand with 2 values of flex-grow and flex-shrink', () => {
20
+ expect(transformCss([['flex', '1 2']])).toEqual({
21
+ flexGrow: 1,
22
+ flexShrink: 2,
23
+ flexBasis: 0,
24
+ })
25
+ })
26
+
27
+ it('transforms flex shorthand with 2 values of flex-grow and flex-basis', () => {
28
+ expect(transformCss([['flex', '2 2px']])).toEqual({
29
+ flexGrow: 2,
30
+ flexShrink: 1,
31
+ flexBasis: 2,
32
+ })
33
+ })
34
+
35
+ it('transforms flex shorthand with 2 values of flex-grow and flex-basis (reversed)', () => {
36
+ expect(transformCss([['flex', '2px 2']])).toEqual({
37
+ flexGrow: 2,
38
+ flexShrink: 1,
39
+ flexBasis: 2,
40
+ })
41
+ })
42
+
43
+ it('transforms flex shorthand with 1 value of flex-grow', () => {
44
+ expect(transformCss([['flex', '2']])).toEqual({
45
+ flexGrow: 2,
46
+ flexShrink: 1,
47
+ flexBasis: 0,
48
+ })
49
+ })
50
+
51
+ it('transforms flex shorthand with 1 value of flex-basis', () => {
52
+ expect(transformCss([['flex', '10px']])).toEqual({
53
+ flexGrow: 1,
54
+ flexShrink: 1,
55
+ flexBasis: 10,
56
+ })
57
+ })
58
+
59
+ /*
60
+ A unitless zero that is not already preceded by two flex factors must be interpreted as a flex
61
+ factor. To avoid misinterpretation or invalid declarations, authors must specify a zero
62
+ <‘flex-basis’> component with a unit or precede it by two flex factors.
63
+ */
64
+ it('transforms flex shorthand with flex-grow/shrink taking priority over basis', () => {
65
+ expect(transformCss([['flex', '0 1 0']])).toEqual({
66
+ flexGrow: 0,
67
+ flexShrink: 1,
68
+ flexBasis: 0,
69
+ })
70
+ })
71
+
72
+ it('transforms flex shorthand with flex-basis set to auto', () => {
73
+ expect(transformCss([['flex', '0 1 auto']])).toEqual({
74
+ flexGrow: 0,
75
+ flexShrink: 1,
76
+ flexBasis: 'auto',
77
+ })
78
+ })
79
+
80
+ it('transforms flex shorthand with flex-basis set to percent', () => {
81
+ expect(transformCss([['flex', '1 2 30%']])).toEqual({
82
+ flexGrow: 1,
83
+ flexShrink: 2,
84
+ flexBasis: '30%',
85
+ })
86
+ })
87
+
88
+ it('transforms flex shorthand with flex-basis set to unsupported unit', () => {
89
+ expect(transformCss([['flex', '1 2 30em']])).toEqual({
90
+ flexGrow: 1,
91
+ flexShrink: 2,
92
+ flexBasis: '30em',
93
+ })
94
+ })
95
+
96
+ it('transforms flex shorthand with flex-basis set to auto appearing first', () => {
97
+ expect(transformCss([['flex', 'auto 0 1']])).toEqual({
98
+ flexGrow: 0,
99
+ flexShrink: 1,
100
+ flexBasis: 'auto',
101
+ })
102
+ })
103
+
104
+ it('transforms flex auto keyword', () => {
105
+ expect(transformCss([['flex', 'auto']])).toEqual({
106
+ flexGrow: 1,
107
+ flexShrink: 1,
108
+ flexBasis: 'auto',
109
+ })
110
+ })
111
+
112
+ it('transforms flex none keyword', () => {
113
+ expect(transformCss([['flex', 'none']])).toEqual({
114
+ flexGrow: 0,
115
+ flexShrink: 0,
116
+ flexBasis: 'auto',
117
+ })
118
+ })
119
+
120
+ it('does not transform invalid flex', () => {
121
+ expect(() => transformCss([['flex', '1 2px 3']])).toThrow()
122
+ })
@@ -0,0 +1,22 @@
1
+ import transformCss from '..'
2
+
3
+ it('transforms flexFlow shorthand with two values', () => {
4
+ expect(transformCss([['flex-flow', 'column wrap']])).toEqual({
5
+ flexDirection: 'column',
6
+ flexWrap: 'wrap',
7
+ })
8
+ })
9
+
10
+ it('transforms flexFlow shorthand missing flexDirection', () => {
11
+ expect(transformCss([['flex-flow', 'wrap']])).toEqual({
12
+ flexDirection: 'row',
13
+ flexWrap: 'wrap',
14
+ })
15
+ })
16
+
17
+ it('transforms flexFlow shorthand missing flexWrap', () => {
18
+ expect(transformCss([['flex-flow', 'column']])).toEqual({
19
+ flexDirection: 'column',
20
+ flexWrap: 'nowrap',
21
+ })
22
+ })
@@ -0,0 +1,117 @@
1
+ import transformCss from '..'
2
+
3
+ it('transforms font', () => {
4
+ expect(
5
+ transformCss([['font', 'bold italic small-caps 16px/18px "Helvetica"']])
6
+ ).toEqual({
7
+ fontFamily: 'Helvetica',
8
+ fontSize: 16,
9
+ fontWeight: 'bold',
10
+ fontStyle: 'italic',
11
+ fontVariant: ['small-caps'],
12
+ lineHeight: 18,
13
+ })
14
+ })
15
+
16
+ it('transforms font missing font-variant', () => {
17
+ expect(transformCss([['font', 'bold italic 16px/18px "Helvetica"']])).toEqual(
18
+ {
19
+ fontFamily: 'Helvetica',
20
+ fontSize: 16,
21
+ fontWeight: 'bold',
22
+ fontStyle: 'italic',
23
+ fontVariant: [],
24
+ lineHeight: 18,
25
+ }
26
+ )
27
+ })
28
+
29
+ it('transforms font missing font-style', () => {
30
+ expect(
31
+ transformCss([['font', 'bold small-caps 16px/18px "Helvetica"']])
32
+ ).toEqual({
33
+ fontFamily: 'Helvetica',
34
+ fontSize: 16,
35
+ fontWeight: 'bold',
36
+ fontStyle: 'normal',
37
+ fontVariant: ['small-caps'],
38
+ lineHeight: 18,
39
+ })
40
+ })
41
+
42
+ it('transforms font missing font-weight', () => {
43
+ expect(
44
+ transformCss([['font', 'italic small-caps 16px/18px "Helvetica"']])
45
+ ).toEqual({
46
+ fontFamily: 'Helvetica',
47
+ fontSize: 16,
48
+ fontWeight: 'normal',
49
+ fontStyle: 'italic',
50
+ fontVariant: ['small-caps'],
51
+ lineHeight: 18,
52
+ })
53
+ })
54
+
55
+ it('transforms font with font-weight normal', () => {
56
+ expect(transformCss([['font', 'normal 16px/18px "Helvetica"']])).toEqual({
57
+ fontFamily: 'Helvetica',
58
+ fontSize: 16,
59
+ fontWeight: 'normal',
60
+ fontStyle: 'normal',
61
+ fontVariant: [],
62
+ lineHeight: 18,
63
+ })
64
+ })
65
+
66
+ it('transforms font with font-weight and font-style normal', () => {
67
+ expect(
68
+ transformCss([['font', 'normal normal 16px/18px "Helvetica"']])
69
+ ).toEqual({
70
+ fontFamily: 'Helvetica',
71
+ fontSize: 16,
72
+ fontWeight: 'normal',
73
+ fontStyle: 'normal',
74
+ fontVariant: [],
75
+ lineHeight: 18,
76
+ })
77
+ })
78
+
79
+ it('transforms font with no font-weight, font-style, and font-variant', () => {
80
+ expect(transformCss([['font', '16px/18px "Helvetica"']])).toEqual({
81
+ fontFamily: 'Helvetica',
82
+ fontSize: 16,
83
+ fontWeight: 'normal',
84
+ fontStyle: 'normal',
85
+ fontVariant: [],
86
+ lineHeight: 18,
87
+ })
88
+ })
89
+
90
+ it('omits line height if not specified', () => {
91
+ expect(transformCss([['font', '16px "Helvetica"']])).toEqual({
92
+ fontFamily: 'Helvetica',
93
+ fontSize: 16,
94
+ fontWeight: 'normal',
95
+ fontStyle: 'normal',
96
+ fontVariant: [],
97
+ })
98
+ })
99
+
100
+ it('does not allow line height as multiple', () => {
101
+ expect(() => {
102
+ transformCss([['font', '16px/1.5 "Helvetica"']])
103
+ }).toThrow()
104
+ })
105
+
106
+ it('transforms font without quotes', () => {
107
+ expect(
108
+ transformCss([['font', 'bold italic small-caps 16px/18px Helvetica Neue']])
109
+ ).toEqual({
110
+ fontFamily: 'Helvetica Neue',
111
+ fontSize: 16,
112
+ fontWeight: 'bold',
113
+ fontStyle: 'italic',
114
+ fontVariant: ['small-caps'],
115
+ lineHeight: 18,
116
+ })
117
+ })
@@ -0,0 +1,43 @@
1
+ import transformCss from '..'
2
+
3
+ it('transforms font-family with double quotes', () => {
4
+ expect(transformCss([['font-family', '"Helvetica Neue"']])).toEqual({
5
+ fontFamily: 'Helvetica Neue',
6
+ })
7
+ })
8
+
9
+ it('transforms font-family with single quotes', () => {
10
+ expect(transformCss([['font-family', "'Helvetica Neue'"]])).toEqual({
11
+ fontFamily: 'Helvetica Neue',
12
+ })
13
+ })
14
+
15
+ it('transforms font-family without quotes', () => {
16
+ expect(transformCss([['font-family', 'Helvetica Neue']])).toEqual({
17
+ fontFamily: 'Helvetica Neue',
18
+ })
19
+ })
20
+
21
+ it('transforms font-family with quotes with otherwise invalid values', () => {
22
+ expect(transformCss([['font-family', '"Goudy Bookletter 1911"']])).toEqual({
23
+ fontFamily: 'Goudy Bookletter 1911',
24
+ })
25
+ })
26
+
27
+ it('transforms font-family with quotes with escaped values', () => {
28
+ expect(transformCss([['font-family', '"test\\A test"']])).toEqual({
29
+ fontFamily: 'test\ntest',
30
+ })
31
+ })
32
+
33
+ it('transforms font-family with quotes with escaped quote', () => {
34
+ expect(transformCss([['font-family', '"test\\"test"']])).toEqual({
35
+ fontFamily: 'test"test',
36
+ })
37
+ })
38
+
39
+ it('does not transform invalid unquoted font-family', () => {
40
+ expect(() =>
41
+ transformCss([['font-family', 'Goudy Bookletter 1911']])
42
+ ).toThrow()
43
+ })
@@ -0,0 +1,15 @@
1
+ import transformCss from '..'
2
+
3
+ it('transforms font variant as an array', () => {
4
+ expect(transformCss([['font-variant', 'tabular-nums']])).toEqual({
5
+ fontVariant: ['tabular-nums'],
6
+ })
7
+ })
8
+
9
+ it('transforms multiple font variant as an array', () => {
10
+ expect(
11
+ transformCss([['font-variant', 'tabular-nums oldstyle-nums']])
12
+ ).toEqual({
13
+ fontVariant: ['tabular-nums', 'oldstyle-nums'],
14
+ })
15
+ })
@@ -0,0 +1,8 @@
1
+ import transformCss from '..'
2
+
3
+ it('transforms font weights as strings', () => {
4
+ expect(transformCss([['font-weight', '400']])).toEqual({ fontWeight: '400' })
5
+ expect(transformCss([['font-weight', 'bold']])).toEqual({
6
+ fontWeight: 'bold',
7
+ })
8
+ })
@@ -0,0 +1,238 @@
1
+ import transformCss, { getStylesForProperty } from '..'
2
+
3
+ it('transforms numbers', () => {
4
+ expect(transformCss([['z-index', '0']])).toEqual({ zIndex: 0 })
5
+ })
6
+
7
+ it('warns if missing units on unspecialized transform', () => {
8
+ const consoleSpy = jest
9
+ .spyOn(global.console, 'warn')
10
+ .mockImplementation(() => {
11
+ // Silence the warning from the test output
12
+ })
13
+
14
+ transformCss([['top', '1']])
15
+ expect(consoleSpy).toHaveBeenCalledWith(
16
+ 'Expected style "top: 1" to contain units'
17
+ )
18
+
19
+ consoleSpy.mockRestore()
20
+ })
21
+
22
+ it('does not warn for unitless 0 length on unspecialized transform', () => {
23
+ const consoleSpy = jest.spyOn(global.console, 'warn')
24
+
25
+ transformCss([['top', '0']])
26
+ expect(consoleSpy).not.toHaveBeenCalled()
27
+
28
+ consoleSpy.mockRestore()
29
+ })
30
+
31
+ it('warns if adding etraneous units on unspecialized transform', () => {
32
+ const consoleSpy = jest
33
+ .spyOn(global.console, 'warn')
34
+ .mockImplementation(() => {
35
+ // Silence the warning from the test output
36
+ })
37
+
38
+ transformCss([['opacity', '1px']])
39
+ expect(consoleSpy).toHaveBeenCalledWith(
40
+ 'Expected style "opacity: 1px" to be unitless'
41
+ )
42
+
43
+ consoleSpy.mockRestore()
44
+ })
45
+
46
+ it('does not warn for unitless 0 length on unitless transform', () => {
47
+ const consoleSpy = jest.spyOn(global.console, 'warn')
48
+
49
+ transformCss([['opacity', '0']])
50
+ expect(consoleSpy).not.toHaveBeenCalled()
51
+
52
+ consoleSpy.mockRestore()
53
+ })
54
+
55
+ it('allows pixels in unspecialized transform', () => {
56
+ expect(transformCss([['top', '0px']])).toEqual({ top: 0 })
57
+ })
58
+
59
+ it('allows boolean values', () => {
60
+ expect(
61
+ transformCss([
62
+ ['boolTrue1', 'true'],
63
+ ['boolTrue2', 'TRUE'],
64
+ ['boolFalse1', 'false'],
65
+ ['boolFalse2', 'FALSE'],
66
+ ])
67
+ ).toEqual({
68
+ boolTrue1: true,
69
+ boolTrue2: true,
70
+ boolFalse1: false,
71
+ boolFalse2: false,
72
+ })
73
+ })
74
+
75
+ it('allows null values', () => {
76
+ expect(transformCss([['null1', 'null'], ['null2', 'NULL']])).toEqual({
77
+ null1: null,
78
+ null2: null,
79
+ })
80
+ })
81
+
82
+ it('allows undefined values', () => {
83
+ expect(
84
+ transformCss([['undefined1', 'undefined'], ['undefined2', 'UNDEFINED']])
85
+ ).toEqual({
86
+ undefined1: undefined,
87
+ undefined2: undefined,
88
+ })
89
+ })
90
+
91
+ it('allows CSS custom properties to pass through', () => {
92
+ expect(transformCss([['--my-prop', '0%']])).toEqual({ '--my-prop': '0%' })
93
+ })
94
+
95
+ it('allows percent in unspecialized transform', () => {
96
+ expect(transformCss([['top', '0%']])).toEqual({ top: '0%' })
97
+ })
98
+
99
+ it('allows decimal values', () => {
100
+ expect(getStylesForProperty('margin', '0.5px').marginTop).toBe(0.5)
101
+ expect(getStylesForProperty('margin', '1.5px').marginTop).toBe(1.5)
102
+ expect(getStylesForProperty('margin', '10.5px').marginTop).toBe(10.5)
103
+ expect(getStylesForProperty('margin', '100.5px').marginTop).toBe(100.5)
104
+ expect(getStylesForProperty('margin', '-0.5px').marginTop).toBe(-0.5)
105
+ expect(getStylesForProperty('margin', '-1.5px').marginTop).toBe(-1.5)
106
+ expect(getStylesForProperty('margin', '-10.5px').marginTop).toBe(-10.5)
107
+ expect(getStylesForProperty('margin', '-100.5px').marginTop).toBe(-100.5)
108
+ expect(getStylesForProperty('margin', '.5px').marginTop).toBe(0.5)
109
+ expect(getStylesForProperty('margin', '-.5px').marginTop).toBe(-0.5)
110
+ })
111
+
112
+ it('allows decimal values in transformed values', () => {
113
+ expect(transformCss([['border-radius', '1.5px']])).toEqual({
114
+ borderTopLeftRadius: 1.5,
115
+ borderTopRightRadius: 1.5,
116
+ borderBottomRightRadius: 1.5,
117
+ borderBottomLeftRadius: 1.5,
118
+ })
119
+ })
120
+
121
+ it('allows negative values in transformed values', () => {
122
+ expect(transformCss([['border-radius', '-1.5px']])).toEqual({
123
+ borderTopLeftRadius: -1.5,
124
+ borderTopRightRadius: -1.5,
125
+ borderBottomRightRadius: -1.5,
126
+ borderBottomLeftRadius: -1.5,
127
+ })
128
+ })
129
+
130
+ it('allows uppercase units', () => {
131
+ expect(transformCss([['top', '0PX']])).toEqual({ top: 0 })
132
+ expect(transformCss([['transform', 'rotate(30DEG)']])).toEqual({
133
+ transform: [{ rotate: '30deg' }],
134
+ })
135
+ })
136
+
137
+ it('allows percent values in transformed values', () => {
138
+ expect(transformCss([['margin', '10%']])).toEqual({
139
+ marginTop: '10%',
140
+ marginRight: '10%',
141
+ marginBottom: '10%',
142
+ marginLeft: '10%',
143
+ })
144
+ })
145
+
146
+ it('allows color values in transformed border-color values', () => {
147
+ expect(transformCss([['border-color', 'red']])).toEqual({
148
+ borderTopColor: 'red',
149
+ borderRightColor: 'red',
150
+ borderBottomColor: 'red',
151
+ borderLeftColor: 'red',
152
+ })
153
+ })
154
+
155
+ it('allows omitting units for 0', () => {
156
+ expect(transformCss([['margin', '10px 0']])).toEqual({
157
+ marginTop: 10,
158
+ marginRight: 0,
159
+ marginBottom: 10,
160
+ marginLeft: 0,
161
+ })
162
+ })
163
+
164
+ it('transforms strings', () => {
165
+ expect(transformCss([['color', 'red']])).toEqual({ color: 'red' })
166
+ })
167
+
168
+ it('converts to camel-case', () => {
169
+ expect(transformCss([['background-color', 'red']])).toEqual({
170
+ backgroundColor: 'red',
171
+ })
172
+ })
173
+
174
+ it('transforms background to backgroundColor', () => {
175
+ expect(transformCss([['background', '#f00']])).toEqual({
176
+ backgroundColor: '#f00',
177
+ })
178
+ })
179
+
180
+ it('transforms background to backgroundColor with rgb', () => {
181
+ expect(transformCss([['background', 'rgb(255, 0, 0)']])).toEqual({
182
+ backgroundColor: 'rgb(255, 0, 0)',
183
+ })
184
+ })
185
+
186
+ it('transforms background to backgroundColor with named colour', () => {
187
+ expect(transformCss([['background', 'red']])).toEqual({
188
+ backgroundColor: 'red',
189
+ })
190
+ })
191
+
192
+ it('allows blacklisting shorthands', () => {
193
+ const actualStyles = transformCss(
194
+ [['border-radius', '50px']],
195
+ ['borderRadius']
196
+ )
197
+ expect(actualStyles).toEqual({ borderRadius: 50 })
198
+ })
199
+
200
+ it('throws useful errors', () => {
201
+ expect(() => transformCss([['margin', '10']])).toThrow(
202
+ 'Failed to parse declaration "margin: 10"'
203
+ )
204
+ })
205
+
206
+ it('transforms background with var() for color', () => {
207
+ expect(transformCss([['background', 'var(--primary-color)']])).toEqual({
208
+ backgroundColor: 'var(--primary-color)',
209
+ })
210
+ })
211
+
212
+ it('transforms background with var() and named color fallback', () => {
213
+ expect(transformCss([['background', 'var(--primary-color, red)']])).toEqual({
214
+ backgroundColor: 'var(--primary-color, red)',
215
+ })
216
+ })
217
+
218
+ it('transforms background with var() and hex color fallback', () => {
219
+ expect(transformCss([['background', 'var(--primary-color, #f00)']])).toEqual({
220
+ backgroundColor: 'var(--primary-color, #f00)',
221
+ })
222
+ })
223
+
224
+ it('transforms background with var() and rgb color fallback', () => {
225
+ expect(
226
+ transformCss([['background', 'var(--primary-color, rgb(255, 0, 0))']])
227
+ ).toEqual({
228
+ backgroundColor: 'var(--primary-color, rgb(255,0,0))',
229
+ })
230
+ })
231
+
232
+ it('transforms background with var() and rgba color fallback', () => {
233
+ expect(
234
+ transformCss([['background', 'var(--primary-color, rgba(255, 0, 0, 0.5))']])
235
+ ).toEqual({
236
+ backgroundColor: 'var(--primary-color, rgba(255,0,0,0.5))',
237
+ })
238
+ })
@@ -0,0 +1,19 @@
1
+ import transformCss from '..'
2
+
3
+ it('transforms place content', () => {
4
+ expect(transformCss([['place-content', 'center center']])).toEqual({
5
+ alignContent: 'center',
6
+ justifyContent: 'center',
7
+ })
8
+ })
9
+
10
+ it('transforms place content with one value', () => {
11
+ expect(transformCss([['place-content', 'center']])).toEqual({
12
+ alignContent: 'center',
13
+ justifyContent: 'stretch',
14
+ })
15
+ })
16
+
17
+ it('does not allow justify content without align content', () => {
18
+ expect(() => transformCss([['place-content', 'space-evenly']])).toThrow()
19
+ })
@@ -0,0 +1,13 @@
1
+ import transformCss from '..'
2
+
3
+ it('transforms shadow offsets', () => {
4
+ expect(transformCss([['shadow-offset', '10px 5px']])).toEqual({
5
+ shadowOffset: { width: 10, height: 5 },
6
+ })
7
+ })
8
+
9
+ it('transforms text shadow offsets', () => {
10
+ expect(transformCss([['text-shadow-offset', '10px 5px']])).toEqual({
11
+ textShadowOffset: { width: 10, height: 5 },
12
+ })
13
+ })