@cssxjs/css-to-react-native 3.2.0-0 → 3.2.0-1
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/index.js +808 -279
- package/package.json +1 -1
- package/src/__tests__/animation.js +417 -0
- package/src/__tests__/boxModel.js +6 -1
- package/src/__tests__/boxShadow.js +31 -74
- package/src/__tests__/index.js +10 -2
- package/src/__tests__/transition.js +186 -0
- package/src/__tests__/units.js +1 -4
- package/src/index.js +135 -7
- package/src/tokenTypes.js +21 -0
- package/src/transforms/animation.js +336 -0
- package/src/transforms/boxShadow.js +5 -6
- package/src/transforms/index.js +30 -0
- package/src/transforms/transition.js +238 -0
package/package.json
CHANGED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import transformCss from '..'
|
|
2
|
+
|
|
3
|
+
it('transforms animation shorthand', () => {
|
|
4
|
+
expect(transformCss([['animation', 'fadeIn 300ms ease']])).toEqual({
|
|
5
|
+
animationName: 'fadeIn',
|
|
6
|
+
animationDuration: '300ms',
|
|
7
|
+
animationTimingFunction: 'ease',
|
|
8
|
+
animationDelay: '0s',
|
|
9
|
+
animationIterationCount: 1,
|
|
10
|
+
animationDirection: 'normal',
|
|
11
|
+
animationFillMode: 'none',
|
|
12
|
+
animationPlayState: 'running',
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('transforms animation with all properties', () => {
|
|
17
|
+
expect(
|
|
18
|
+
transformCss([
|
|
19
|
+
[
|
|
20
|
+
'animation',
|
|
21
|
+
'slideIn 500ms ease-in-out 100ms infinite alternate forwards paused',
|
|
22
|
+
],
|
|
23
|
+
])
|
|
24
|
+
).toEqual({
|
|
25
|
+
animationName: 'slideIn',
|
|
26
|
+
animationDuration: '500ms',
|
|
27
|
+
animationTimingFunction: 'ease-in-out',
|
|
28
|
+
animationDelay: '100ms',
|
|
29
|
+
animationIterationCount: 'infinite',
|
|
30
|
+
animationDirection: 'alternate',
|
|
31
|
+
animationFillMode: 'forwards',
|
|
32
|
+
animationPlayState: 'paused',
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('transforms multiple animations', () => {
|
|
37
|
+
expect(
|
|
38
|
+
transformCss([['animation', 'fadeIn 300ms ease, slideIn 500ms linear']])
|
|
39
|
+
).toEqual({
|
|
40
|
+
animationName: ['fadeIn', 'slideIn'],
|
|
41
|
+
animationDuration: ['300ms', '500ms'],
|
|
42
|
+
animationTimingFunction: ['ease', 'linear'],
|
|
43
|
+
animationDelay: ['0s', '0s'],
|
|
44
|
+
animationIterationCount: [1, 1],
|
|
45
|
+
animationDirection: ['normal', 'normal'],
|
|
46
|
+
animationFillMode: ['none', 'none'],
|
|
47
|
+
animationPlayState: ['running', 'running'],
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('transforms animation none', () => {
|
|
52
|
+
expect(transformCss([['animation', 'none']])).toEqual({
|
|
53
|
+
animationName: 'none',
|
|
54
|
+
animationDuration: '0s',
|
|
55
|
+
animationTimingFunction: 'ease',
|
|
56
|
+
animationDelay: '0s',
|
|
57
|
+
animationIterationCount: 1,
|
|
58
|
+
animationDirection: 'normal',
|
|
59
|
+
animationFillMode: 'none',
|
|
60
|
+
animationPlayState: 'running',
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('transforms animation-name', () => {
|
|
65
|
+
expect(transformCss([['animation-name', 'fadeIn']])).toEqual({
|
|
66
|
+
animationName: 'fadeIn',
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('transforms animation-name with multiple animations', () => {
|
|
71
|
+
expect(transformCss([['animation-name', 'fadeIn, slideIn']])).toEqual({
|
|
72
|
+
animationName: ['fadeIn', 'slideIn'],
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('inlines @keyframes into animation-name', () => {
|
|
77
|
+
expect(
|
|
78
|
+
transformCss([
|
|
79
|
+
['@keyframes fadeIn', 'from { opacity: 0; } to { opacity: 1; }'],
|
|
80
|
+
['animation-name', 'fadeIn'],
|
|
81
|
+
])
|
|
82
|
+
).toEqual({
|
|
83
|
+
animationName: { from: { opacity: 0 }, to: { opacity: 1 } },
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('inlines @keyframes for multiple animation-name values', () => {
|
|
88
|
+
expect(
|
|
89
|
+
transformCss([
|
|
90
|
+
['@keyframes fadeIn', 'from { opacity: 0; } to { opacity: 1; }'],
|
|
91
|
+
[
|
|
92
|
+
'@keyframes slideIn',
|
|
93
|
+
'from { transform: translateX(-100px); } to { transform: translateX(0px); }',
|
|
94
|
+
],
|
|
95
|
+
['animation-name', 'fadeIn, slideIn'],
|
|
96
|
+
])
|
|
97
|
+
).toEqual({
|
|
98
|
+
animationName: [
|
|
99
|
+
{ from: { opacity: 0 }, to: { opacity: 1 } },
|
|
100
|
+
{
|
|
101
|
+
from: { transform: [{ translateX: -100 }] },
|
|
102
|
+
to: { transform: [{ translateX: 0 }] },
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('transforms animation-duration', () => {
|
|
109
|
+
expect(transformCss([['animation-duration', '300ms']])).toEqual({
|
|
110
|
+
animationDuration: '300ms',
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('transforms animation-duration with multiple values', () => {
|
|
115
|
+
expect(transformCss([['animation-duration', '300ms, 500ms, 1s']])).toEqual({
|
|
116
|
+
animationDuration: ['300ms', '500ms', '1s'],
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('transforms animation-timing-function', () => {
|
|
121
|
+
expect(transformCss([['animation-timing-function', 'ease-in-out']])).toEqual({
|
|
122
|
+
animationTimingFunction: 'ease-in-out',
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('transforms animation-timing-function with multiple values', () => {
|
|
127
|
+
expect(
|
|
128
|
+
transformCss([['animation-timing-function', 'ease, linear, ease-in-out']])
|
|
129
|
+
).toEqual({
|
|
130
|
+
animationTimingFunction: ['ease', 'linear', 'ease-in-out'],
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('transforms animation-timing-function with cubic-bezier', () => {
|
|
135
|
+
expect(
|
|
136
|
+
transformCss([
|
|
137
|
+
['animation-timing-function', 'cubic-bezier(0.4, 0, 0.2, 1)'],
|
|
138
|
+
])
|
|
139
|
+
).toEqual({
|
|
140
|
+
animationTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('transforms animation-delay', () => {
|
|
145
|
+
expect(transformCss([['animation-delay', '100ms']])).toEqual({
|
|
146
|
+
animationDelay: '100ms',
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it('transforms animation-delay with multiple values', () => {
|
|
151
|
+
expect(transformCss([['animation-delay', '100ms, 200ms, 0s']])).toEqual({
|
|
152
|
+
animationDelay: ['100ms', '200ms', '0s'],
|
|
153
|
+
})
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
it('transforms animation-iteration-count', () => {
|
|
157
|
+
expect(transformCss([['animation-iteration-count', 'infinite']])).toEqual({
|
|
158
|
+
animationIterationCount: 'infinite',
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('transforms animation-iteration-count with multiple values', () => {
|
|
163
|
+
expect(
|
|
164
|
+
transformCss([['animation-iteration-count', 'infinite, 2, 3']])
|
|
165
|
+
).toEqual({
|
|
166
|
+
animationIterationCount: ['infinite', 2, 3],
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('transforms animation-direction', () => {
|
|
171
|
+
expect(transformCss([['animation-direction', 'alternate']])).toEqual({
|
|
172
|
+
animationDirection: 'alternate',
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('transforms animation-direction with multiple values', () => {
|
|
177
|
+
expect(
|
|
178
|
+
transformCss([['animation-direction', 'alternate, reverse, normal']])
|
|
179
|
+
).toEqual({
|
|
180
|
+
animationDirection: ['alternate', 'reverse', 'normal'],
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('transforms animation-fill-mode', () => {
|
|
185
|
+
expect(transformCss([['animation-fill-mode', 'forwards']])).toEqual({
|
|
186
|
+
animationFillMode: 'forwards',
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
it('transforms animation-fill-mode with multiple values', () => {
|
|
191
|
+
expect(
|
|
192
|
+
transformCss([['animation-fill-mode', 'forwards, backwards, both']])
|
|
193
|
+
).toEqual({
|
|
194
|
+
animationFillMode: ['forwards', 'backwards', 'both'],
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('transforms animation-play-state', () => {
|
|
199
|
+
expect(transformCss([['animation-play-state', 'paused']])).toEqual({
|
|
200
|
+
animationPlayState: 'paused',
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('transforms animation-play-state with multiple values', () => {
|
|
205
|
+
expect(
|
|
206
|
+
transformCss([['animation-play-state', 'paused, running, paused']])
|
|
207
|
+
).toEqual({
|
|
208
|
+
animationPlayState: ['paused', 'running', 'paused'],
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('inlines @keyframes into animationName', () => {
|
|
213
|
+
expect(
|
|
214
|
+
transformCss([
|
|
215
|
+
['@keyframes fadeIn', 'from { opacity: 0; } to { opacity: 1; }'],
|
|
216
|
+
['animation', 'fadeIn 300ms ease'],
|
|
217
|
+
])
|
|
218
|
+
).toEqual({
|
|
219
|
+
animationName: { from: { opacity: 0 }, to: { opacity: 1 } },
|
|
220
|
+
animationDuration: '300ms',
|
|
221
|
+
animationTimingFunction: 'ease',
|
|
222
|
+
animationDelay: '0s',
|
|
223
|
+
animationIterationCount: 1,
|
|
224
|
+
animationDirection: 'normal',
|
|
225
|
+
animationFillMode: 'none',
|
|
226
|
+
animationPlayState: 'running',
|
|
227
|
+
})
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
it('inlines @keyframes with percentages', () => {
|
|
231
|
+
expect(
|
|
232
|
+
transformCss([
|
|
233
|
+
[
|
|
234
|
+
'@keyframes pulse',
|
|
235
|
+
'0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; }',
|
|
236
|
+
],
|
|
237
|
+
['animation', 'pulse 1s infinite'],
|
|
238
|
+
])
|
|
239
|
+
).toEqual({
|
|
240
|
+
animationName: {
|
|
241
|
+
'0%': { opacity: 1 },
|
|
242
|
+
'50%': { opacity: 0.5 },
|
|
243
|
+
'100%': { opacity: 1 },
|
|
244
|
+
},
|
|
245
|
+
animationDuration: '1s',
|
|
246
|
+
animationTimingFunction: 'ease',
|
|
247
|
+
animationDelay: '0s',
|
|
248
|
+
animationIterationCount: 'infinite',
|
|
249
|
+
animationDirection: 'normal',
|
|
250
|
+
animationFillMode: 'none',
|
|
251
|
+
animationPlayState: 'running',
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
it('inlines @keyframes with transform', () => {
|
|
256
|
+
expect(
|
|
257
|
+
transformCss([
|
|
258
|
+
[
|
|
259
|
+
'@keyframes slideIn',
|
|
260
|
+
'from { transform: translateX(-100px); } to { transform: translateX(0px); }',
|
|
261
|
+
],
|
|
262
|
+
['animation', 'slideIn 500ms ease-out'],
|
|
263
|
+
])
|
|
264
|
+
).toEqual({
|
|
265
|
+
animationName: {
|
|
266
|
+
from: { transform: [{ translateX: -100 }] },
|
|
267
|
+
to: { transform: [{ translateX: 0 }] },
|
|
268
|
+
},
|
|
269
|
+
animationDuration: '500ms',
|
|
270
|
+
animationTimingFunction: 'ease-out',
|
|
271
|
+
animationDelay: '0s',
|
|
272
|
+
animationIterationCount: 1,
|
|
273
|
+
animationDirection: 'normal',
|
|
274
|
+
animationFillMode: 'none',
|
|
275
|
+
animationPlayState: 'running',
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
it('inlines multiple @keyframes for multiple animations', () => {
|
|
280
|
+
expect(
|
|
281
|
+
transformCss([
|
|
282
|
+
['@keyframes fadeIn', 'from { opacity: 0; } to { opacity: 1; }'],
|
|
283
|
+
[
|
|
284
|
+
'@keyframes slideIn',
|
|
285
|
+
'from { transform: translateX(-100px); } to { transform: translateX(0px); }',
|
|
286
|
+
],
|
|
287
|
+
['animation', 'fadeIn 300ms ease, slideIn 500ms linear'],
|
|
288
|
+
])
|
|
289
|
+
).toEqual({
|
|
290
|
+
animationName: [
|
|
291
|
+
{ from: { opacity: 0 }, to: { opacity: 1 } },
|
|
292
|
+
{
|
|
293
|
+
from: { transform: [{ translateX: -100 }] },
|
|
294
|
+
to: { transform: [{ translateX: 0 }] },
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
animationDuration: ['300ms', '500ms'],
|
|
298
|
+
animationTimingFunction: ['ease', 'linear'],
|
|
299
|
+
animationDelay: ['0s', '0s'],
|
|
300
|
+
animationIterationCount: [1, 1],
|
|
301
|
+
animationDirection: ['normal', 'normal'],
|
|
302
|
+
animationFillMode: ['none', 'none'],
|
|
303
|
+
animationPlayState: ['running', 'running'],
|
|
304
|
+
})
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
it('keeps animation name as string if no matching @keyframes', () => {
|
|
308
|
+
expect(transformCss([['animation', 'unknownAnimation 300ms ease']])).toEqual({
|
|
309
|
+
animationName: 'unknownAnimation',
|
|
310
|
+
animationDuration: '300ms',
|
|
311
|
+
animationTimingFunction: 'ease',
|
|
312
|
+
animationDelay: '0s',
|
|
313
|
+
animationIterationCount: 1,
|
|
314
|
+
animationDirection: 'normal',
|
|
315
|
+
animationFillMode: 'none',
|
|
316
|
+
animationPlayState: 'running',
|
|
317
|
+
})
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
it('handles animation with numeric iteration count', () => {
|
|
321
|
+
expect(transformCss([['animation', 'bounce 1s ease 3']])).toEqual({
|
|
322
|
+
animationName: 'bounce',
|
|
323
|
+
animationDuration: '1s',
|
|
324
|
+
animationTimingFunction: 'ease',
|
|
325
|
+
animationDelay: '0s',
|
|
326
|
+
animationIterationCount: 3,
|
|
327
|
+
animationDirection: 'normal',
|
|
328
|
+
animationFillMode: 'none',
|
|
329
|
+
animationPlayState: 'running',
|
|
330
|
+
})
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
it('handles @keyframes with multiple selectors', () => {
|
|
334
|
+
expect(
|
|
335
|
+
transformCss([
|
|
336
|
+
[
|
|
337
|
+
'@keyframes bounce',
|
|
338
|
+
'0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-20px); }',
|
|
339
|
+
],
|
|
340
|
+
['animation', 'bounce 1s infinite'],
|
|
341
|
+
])
|
|
342
|
+
).toEqual({
|
|
343
|
+
animationName: {
|
|
344
|
+
'0%': { transform: [{ translateY: 0 }] },
|
|
345
|
+
'100%': { transform: [{ translateY: 0 }] },
|
|
346
|
+
'50%': { transform: [{ translateY: -20 }] },
|
|
347
|
+
},
|
|
348
|
+
animationDuration: '1s',
|
|
349
|
+
animationTimingFunction: 'ease',
|
|
350
|
+
animationDelay: '0s',
|
|
351
|
+
animationIterationCount: 'infinite',
|
|
352
|
+
animationDirection: 'normal',
|
|
353
|
+
animationFillMode: 'none',
|
|
354
|
+
animationPlayState: 'running',
|
|
355
|
+
})
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
it('handles @keyframes with CSS comments', () => {
|
|
359
|
+
expect(
|
|
360
|
+
transformCss([
|
|
361
|
+
[
|
|
362
|
+
'@keyframes fadeIn',
|
|
363
|
+
`
|
|
364
|
+
/* Start state */
|
|
365
|
+
from {
|
|
366
|
+
opacity: 0; /* fully transparent */
|
|
367
|
+
}
|
|
368
|
+
/* End state */
|
|
369
|
+
to {
|
|
370
|
+
opacity: 1; /* fully visible */
|
|
371
|
+
}
|
|
372
|
+
`,
|
|
373
|
+
],
|
|
374
|
+
['animation', 'fadeIn 300ms ease'],
|
|
375
|
+
])
|
|
376
|
+
).toEqual({
|
|
377
|
+
animationName: { from: { opacity: 0 }, to: { opacity: 1 } },
|
|
378
|
+
animationDuration: '300ms',
|
|
379
|
+
animationTimingFunction: 'ease',
|
|
380
|
+
animationDelay: '0s',
|
|
381
|
+
animationIterationCount: 1,
|
|
382
|
+
animationDirection: 'normal',
|
|
383
|
+
animationFillMode: 'none',
|
|
384
|
+
animationPlayState: 'running',
|
|
385
|
+
})
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
it('handles @keyframes with multi-line comments', () => {
|
|
389
|
+
expect(
|
|
390
|
+
transformCss([
|
|
391
|
+
[
|
|
392
|
+
'@keyframes slide',
|
|
393
|
+
`
|
|
394
|
+
/*
|
|
395
|
+
* This is a multi-line comment
|
|
396
|
+
* describing the animation
|
|
397
|
+
*/
|
|
398
|
+
0% { transform: translateX(0px); }
|
|
399
|
+
100% { transform: translateX(100px); }
|
|
400
|
+
`,
|
|
401
|
+
],
|
|
402
|
+
['animation', 'slide 500ms linear'],
|
|
403
|
+
])
|
|
404
|
+
).toEqual({
|
|
405
|
+
animationName: {
|
|
406
|
+
'0%': { transform: [{ translateX: 0 }] },
|
|
407
|
+
'100%': { transform: [{ translateX: 100 }] },
|
|
408
|
+
},
|
|
409
|
+
animationDuration: '500ms',
|
|
410
|
+
animationTimingFunction: 'linear',
|
|
411
|
+
animationDelay: '0s',
|
|
412
|
+
animationIterationCount: 1,
|
|
413
|
+
animationDirection: 'normal',
|
|
414
|
+
animationFillMode: 'none',
|
|
415
|
+
animationPlayState: 'running',
|
|
416
|
+
})
|
|
417
|
+
})
|
|
@@ -76,7 +76,12 @@ it('transforms margin, allowing unitless zero, percentages', () => {
|
|
|
76
76
|
})
|
|
77
77
|
|
|
78
78
|
it('transforms shorthand and overrides previous values', () => {
|
|
79
|
-
expect(
|
|
79
|
+
expect(
|
|
80
|
+
transformCss([
|
|
81
|
+
['margin-top', '2px'],
|
|
82
|
+
['margin', '1px'],
|
|
83
|
+
])
|
|
84
|
+
).toEqual({
|
|
80
85
|
marginTop: 1,
|
|
81
86
|
marginRight: 1,
|
|
82
87
|
marginBottom: 1,
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import transformCss from '..'
|
|
2
2
|
|
|
3
|
-
it('transforms box-shadow
|
|
3
|
+
it('transforms box-shadow to boxShadow in web format', () => {
|
|
4
4
|
expect(transformCss([['box-shadow', '10px 20px 30px red']])).toEqual({
|
|
5
|
-
|
|
6
|
-
shadowRadius: 30,
|
|
7
|
-
shadowColor: 'red',
|
|
8
|
-
shadowOpacity: 1,
|
|
5
|
+
boxShadow: '10px 20px 30px red',
|
|
9
6
|
})
|
|
10
7
|
})
|
|
11
8
|
|
|
12
9
|
it('transforms box-shadow without blur-radius', () => {
|
|
13
10
|
expect(transformCss([['box-shadow', '10px 20px red']])).toEqual({
|
|
14
|
-
|
|
15
|
-
shadowRadius: 0,
|
|
16
|
-
shadowColor: 'red',
|
|
17
|
-
shadowOpacity: 1,
|
|
11
|
+
boxShadow: '10px 20px red',
|
|
18
12
|
})
|
|
19
13
|
})
|
|
20
14
|
|
|
21
15
|
it('transforms box-shadow without color', () => {
|
|
22
16
|
expect(transformCss([['box-shadow', '10px 20px']])).toEqual({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
boxShadow: '10px 20px',
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('transforms box-shadow with spread radius', () => {
|
|
22
|
+
expect(transformCss([['box-shadow', '10px 20px 5px 15px red']])).toEqual({
|
|
23
|
+
boxShadow: '10px 20px 5px 15px red',
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('transforms box-shadow with inset', () => {
|
|
28
|
+
expect(transformCss([['box-shadow', 'inset 10px 20px 30px red']])).toEqual({
|
|
29
|
+
boxShadow: 'inset 10px 20px 30px red',
|
|
27
30
|
})
|
|
28
31
|
})
|
|
29
32
|
|
|
@@ -31,10 +34,7 @@ it('transforms box-shadow with rgb color', () => {
|
|
|
31
34
|
expect(
|
|
32
35
|
transformCss([['box-shadow', '10px 20px rgb(100, 100, 100)']])
|
|
33
36
|
).toEqual({
|
|
34
|
-
|
|
35
|
-
shadowRadius: 0,
|
|
36
|
-
shadowColor: 'rgb(100, 100, 100)',
|
|
37
|
-
shadowOpacity: 1,
|
|
37
|
+
boxShadow: '10px 20px rgb(100, 100, 100)',
|
|
38
38
|
})
|
|
39
39
|
})
|
|
40
40
|
|
|
@@ -42,54 +42,29 @@ it('transforms box-shadow with rgba color', () => {
|
|
|
42
42
|
expect(
|
|
43
43
|
transformCss([['box-shadow', '10px 20px rgba(100, 100, 100, 0.5)']])
|
|
44
44
|
).toEqual({
|
|
45
|
-
|
|
46
|
-
shadowRadius: 0,
|
|
47
|
-
shadowColor: 'rgba(100, 100, 100, 0.5)',
|
|
48
|
-
shadowOpacity: 1,
|
|
45
|
+
boxShadow: '10px 20px rgba(100, 100, 100, 0.5)',
|
|
49
46
|
})
|
|
50
47
|
})
|
|
51
48
|
|
|
52
|
-
it('transforms box-
|
|
49
|
+
it('transforms multiple box-shadows', () => {
|
|
53
50
|
expect(
|
|
54
|
-
transformCss([['box-shadow', '10px 20px
|
|
51
|
+
transformCss([['box-shadow', '10px 20px red, 5px 10px blue']])
|
|
55
52
|
).toEqual({
|
|
56
|
-
|
|
57
|
-
shadowRadius: 0,
|
|
58
|
-
shadowColor: 'hsl(120, 100%, 50%)',
|
|
59
|
-
shadowOpacity: 1,
|
|
53
|
+
boxShadow: '10px 20px red, 5px 10px blue',
|
|
60
54
|
})
|
|
61
55
|
})
|
|
62
56
|
|
|
63
|
-
it('transforms box-shadow
|
|
64
|
-
expect(
|
|
65
|
-
|
|
66
|
-
).toEqual({
|
|
67
|
-
shadowOffset: { width: 10, height: 20 },
|
|
68
|
-
shadowRadius: 0,
|
|
69
|
-
shadowColor: 'hsla(120, 100%, 50%, 0.7)',
|
|
70
|
-
shadowOpacity: 1,
|
|
57
|
+
it('transforms box-shadow none', () => {
|
|
58
|
+
expect(transformCss([['box-shadow', 'none']])).toEqual({
|
|
59
|
+
boxShadow: 'none',
|
|
71
60
|
})
|
|
72
61
|
})
|
|
73
62
|
|
|
74
|
-
it('transforms box-shadow and throws if multiple colors are used', () => {
|
|
75
|
-
expect(() =>
|
|
76
|
-
transformCss([['box-shadow', '0 0 0 red yellow green blue']])
|
|
77
|
-
).toThrow()
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it('transforms box-shadow enforces offset to be present', () => {
|
|
81
|
-
expect(() => transformCss([['box-shadow', 'red']])).toThrow()
|
|
82
|
-
expect(() => transformCss([['box-shadow', '10px red']])).toThrow()
|
|
83
|
-
})
|
|
84
|
-
|
|
85
63
|
it('transforms box-shadow with var() for color', () => {
|
|
86
64
|
expect(
|
|
87
65
|
transformCss([['box-shadow', '10px 20px var(--primary-color)']])
|
|
88
66
|
).toEqual({
|
|
89
|
-
|
|
90
|
-
shadowRadius: 0,
|
|
91
|
-
shadowColor: 'var(--primary-color)',
|
|
92
|
-
shadowOpacity: 1,
|
|
67
|
+
boxShadow: '10px 20px var(--primary-color)',
|
|
93
68
|
})
|
|
94
69
|
})
|
|
95
70
|
|
|
@@ -97,10 +72,7 @@ it('transforms box-shadow with var() and blur-radius', () => {
|
|
|
97
72
|
expect(
|
|
98
73
|
transformCss([['box-shadow', '10px 20px 30px var(--primary-color)']])
|
|
99
74
|
).toEqual({
|
|
100
|
-
|
|
101
|
-
shadowRadius: 30,
|
|
102
|
-
shadowColor: 'var(--primary-color)',
|
|
103
|
-
shadowOpacity: 1,
|
|
75
|
+
boxShadow: '10px 20px 30px var(--primary-color)',
|
|
104
76
|
})
|
|
105
77
|
})
|
|
106
78
|
|
|
@@ -108,10 +80,7 @@ it('transforms box-shadow with var() and named color fallback', () => {
|
|
|
108
80
|
expect(
|
|
109
81
|
transformCss([['box-shadow', '10px 20px var(--primary-color, red)']])
|
|
110
82
|
).toEqual({
|
|
111
|
-
|
|
112
|
-
shadowRadius: 0,
|
|
113
|
-
shadowColor: 'var(--primary-color, red)',
|
|
114
|
-
shadowOpacity: 1,
|
|
83
|
+
boxShadow: '10px 20px var(--primary-color, red)',
|
|
115
84
|
})
|
|
116
85
|
})
|
|
117
86
|
|
|
@@ -119,10 +88,7 @@ it('transforms box-shadow with var() and hex color fallback', () => {
|
|
|
119
88
|
expect(
|
|
120
89
|
transformCss([['box-shadow', '10px 20px var(--primary-color, #f00)']])
|
|
121
90
|
).toEqual({
|
|
122
|
-
|
|
123
|
-
shadowRadius: 0,
|
|
124
|
-
shadowColor: 'var(--primary-color, #f00)',
|
|
125
|
-
shadowOpacity: 1,
|
|
91
|
+
boxShadow: '10px 20px var(--primary-color, #f00)',
|
|
126
92
|
})
|
|
127
93
|
})
|
|
128
94
|
|
|
@@ -132,10 +98,7 @@ it('transforms box-shadow with var() and rgb color fallback', () => {
|
|
|
132
98
|
['box-shadow', '10px 20px var(--primary-color, rgb(255, 0, 0))'],
|
|
133
99
|
])
|
|
134
100
|
).toEqual({
|
|
135
|
-
|
|
136
|
-
shadowRadius: 0,
|
|
137
|
-
shadowColor: 'var(--primary-color, rgb(255,0,0))',
|
|
138
|
-
shadowOpacity: 1,
|
|
101
|
+
boxShadow: '10px 20px var(--primary-color, rgb(255, 0, 0))',
|
|
139
102
|
})
|
|
140
103
|
})
|
|
141
104
|
|
|
@@ -148,10 +111,7 @@ it('transforms box-shadow with var() and rgba color fallback', () => {
|
|
|
148
111
|
],
|
|
149
112
|
])
|
|
150
113
|
).toEqual({
|
|
151
|
-
|
|
152
|
-
shadowRadius: 0,
|
|
153
|
-
shadowColor: 'var(--primary-color, rgba(100,100,100,0.5))',
|
|
154
|
-
shadowOpacity: 1,
|
|
114
|
+
boxShadow: '10px 20px var(--primary-color, rgba(100, 100, 100, 0.5))',
|
|
155
115
|
})
|
|
156
116
|
})
|
|
157
117
|
|
|
@@ -159,9 +119,6 @@ it('transforms box-shadow with var() color before offset', () => {
|
|
|
159
119
|
expect(
|
|
160
120
|
transformCss([['box-shadow', 'var(--primary-color) 10px 20px 30px']])
|
|
161
121
|
).toEqual({
|
|
162
|
-
|
|
163
|
-
shadowRadius: 30,
|
|
164
|
-
shadowColor: 'var(--primary-color)',
|
|
165
|
-
shadowOpacity: 1,
|
|
122
|
+
boxShadow: 'var(--primary-color) 10px 20px 30px',
|
|
166
123
|
})
|
|
167
124
|
})
|
package/src/__tests__/index.js
CHANGED
|
@@ -73,7 +73,12 @@ it('allows boolean values', () => {
|
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
it('allows null values', () => {
|
|
76
|
-
expect(
|
|
76
|
+
expect(
|
|
77
|
+
transformCss([
|
|
78
|
+
['null1', 'null'],
|
|
79
|
+
['null2', 'NULL'],
|
|
80
|
+
])
|
|
81
|
+
).toEqual({
|
|
77
82
|
null1: null,
|
|
78
83
|
null2: null,
|
|
79
84
|
})
|
|
@@ -81,7 +86,10 @@ it('allows null values', () => {
|
|
|
81
86
|
|
|
82
87
|
it('allows undefined values', () => {
|
|
83
88
|
expect(
|
|
84
|
-
transformCss([
|
|
89
|
+
transformCss([
|
|
90
|
+
['undefined1', 'undefined'],
|
|
91
|
+
['undefined2', 'UNDEFINED'],
|
|
92
|
+
])
|
|
85
93
|
).toEqual({
|
|
86
94
|
undefined1: undefined,
|
|
87
95
|
undefined2: undefined,
|