-
Notifications
You must be signed in to change notification settings - Fork 51
fix(fela): plugin order, invokeKeyframes #1741
Changes from all commits
10925d2
1b215f4
afb75f7
5100eb7
81140c3
a58b5c1
4e12229
5bbaf57
296553c
f4e501d
3c12ee7
4669bdb
f3caac2
2741c1e
a3ad8e2
1c77535
84123bb
c240c50
d73c9ff
c04ceb7
6b8be07
ef4f0c6
fd72ea2
eef1416
ed5eeae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,8 +24,11 @@ | |
| "eslint-plugin-jsx-a11y": "^6.2.1", | ||
| "eslint-plugin-react": "^7.12.4", | ||
| "eslint-plugin-react-hooks": "^1.6.0", | ||
| "fela": "^10.6.1", | ||
| "jest": "^24.5.0", | ||
| "jest-axe": "^3.1.1" | ||
| "jest-axe": "^3.1.1", | ||
| "jest-react-fela": "^10.6.1", | ||
| "react-fela": "^10.6.1" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same here |
||
| }, | ||
| "files": [ | ||
| "babel", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`CSS fallback values are rendered 1`] = ` | ||
| ".a { | ||
| color: red; | ||
| color: blue; | ||
| } | ||
|
|
||
|
|
||
| <div className=ui-box a />; | ||
| " | ||
| `; | ||
|
|
||
| exports[`array returned by keyframe results in CSS fallback values 1`] = ` | ||
| "@-webkit-keyframes k1 { | ||
| 0% { | ||
| color: blue; | ||
| color: red; | ||
| color: yellow; | ||
| } | ||
| 100% { | ||
| color: blue; | ||
| color: red; | ||
| color: yellow; | ||
| } | ||
| } | ||
| @-moz-keyframes k1 { | ||
| 0% { | ||
| color: blue; | ||
| color: red; | ||
| color: yellow; | ||
| } | ||
| 100% { | ||
| color: blue; | ||
| color: red; | ||
| color: yellow; | ||
| } | ||
| } | ||
| @keyframes k1 { | ||
| 0% { | ||
| color: blue; | ||
| color: red; | ||
| color: yellow; | ||
| } | ||
| 100% { | ||
| color: blue; | ||
| color: red; | ||
| color: yellow; | ||
| } | ||
| } | ||
| .a { | ||
| animation-name: k1; | ||
| } | ||
|
|
||
|
|
||
| <div className=ui-provider__box dir=ltr> | ||
| <div className=ui-box a /> | ||
| </div>; | ||
| " | ||
| `; | ||
|
|
||
| exports[`basic styles are rendered 1`] = ` | ||
| ".a { | ||
| color: red; | ||
| } | ||
|
|
||
|
|
||
| <div className=ui-box a />; | ||
| " | ||
| `; | ||
|
|
||
| exports[`keyframe colors are rendered 1`] = ` | ||
| "@-webkit-keyframes k1 { | ||
| from { | ||
| color: red; | ||
| } | ||
| to { | ||
| color: blue; | ||
| } | ||
| } | ||
| @-moz-keyframes k1 { | ||
| from { | ||
| color: red; | ||
| } | ||
| to { | ||
| color: blue; | ||
| } | ||
| } | ||
| @keyframes k1 { | ||
| from { | ||
| color: red; | ||
| } | ||
| to { | ||
| color: blue; | ||
| } | ||
| } | ||
| .a { | ||
| animation-name: k1; | ||
| } | ||
| .b { | ||
| animation-duration: 5s; | ||
| } | ||
|
|
||
|
|
||
| <div className=ui-provider__box dir=ltr> | ||
| <div className=ui-box a b /> | ||
| </div>; | ||
| " | ||
| `; | ||
|
|
||
| exports[`marginLeft is rendered into marginRight due to RTL 1`] = ` | ||
| ".a { | ||
| margin-right: 10px; | ||
| } | ||
|
|
||
|
|
||
| <div className=ui-provider__box dir=rtl> | ||
| <span className=ui-text a dir=auto> | ||
| Hello | ||
| </span> | ||
| </div>; | ||
| " | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,4 +56,12 @@ describe('felaRenderKeyframesPlugin', () => { | |
| animationDuration: '2s', | ||
| }) | ||
| }) | ||
|
|
||
| test('does not transform a list of strings', () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| const style = { | ||
| display: ['inline-grid', '-ms-inline-grid'], | ||
| } | ||
|
|
||
| expect(renderInvokeKeyframes(style, 'RULE', felaRenderer)).toMatchObject(style) | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import * as React from 'react' | ||
| import { createSnapshot } from 'jest-react-fela' | ||
| import { EmptyThemeProvider } from 'test/utils' | ||
| import Box from 'src/components/Box/Box' | ||
| import Provider from 'src/components/Provider/Provider' | ||
| import Text from 'src/components/Text/Text' | ||
| import { felaRenderer } from 'src/lib' | ||
|
|
||
| test('basic styles are rendered', () => { | ||
| const snapshot = createSnapshot( | ||
| <EmptyThemeProvider> | ||
| <Box styles={{ color: 'red' }} /> | ||
lucivpav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </EmptyThemeProvider>, | ||
| {}, | ||
| felaRenderer, | ||
| ) | ||
| expect(snapshot).toMatchSnapshot() | ||
| }) | ||
|
|
||
| test('CSS fallback values are rendered', () => { | ||
| const snapshot = createSnapshot( | ||
| <EmptyThemeProvider> | ||
| <Box styles={{ color: ['red', 'blue'] }} /> | ||
| </EmptyThemeProvider>, | ||
| {}, | ||
| felaRenderer, | ||
| ) | ||
| expect(snapshot).toMatchSnapshot() | ||
| }) | ||
|
|
||
| test('keyframe colors are rendered', () => { | ||
| const spinner = { | ||
| keyframe: ({ fromColor, toColor }) => ({ | ||
| from: { | ||
| color: fromColor, | ||
| }, | ||
| to: { | ||
| color: toColor, | ||
| }, | ||
| }), | ||
| keyframeParams: { | ||
| fromColor: 'red', | ||
| toColor: 'blue', | ||
| }, | ||
| duration: '5s', | ||
| } | ||
|
|
||
| const snapshot = createSnapshot( | ||
| <Provider theme={{ animations: { spinner } }}> | ||
| <Box animation="spinner" /> | ||
| </Provider>, | ||
| {}, | ||
| felaRenderer, | ||
| ) | ||
| expect(snapshot).toMatchSnapshot() | ||
| }) | ||
|
|
||
| test('array returned by keyframe results in CSS fallback values', () => { | ||
| const steps = ['0%', '100%'] | ||
|
|
||
| const spinner = { | ||
| keyframe: ({ steps }) => { | ||
| const obj = {} | ||
| steps.forEach((step: string, index) => { | ||
| ;(obj as any)[step] = { color: ['blue', 'red', 'yellow'] } | ||
| }) | ||
| return obj | ||
| }, | ||
| keyframeParams: { steps }, | ||
| } | ||
|
|
||
| const snapshot = createSnapshot( | ||
| <Provider theme={{ animations: { spinner } }}> | ||
| <Box animation="spinner" /> | ||
| </Provider>, | ||
| {}, | ||
| felaRenderer, | ||
| ) | ||
| expect(snapshot).toMatchSnapshot() | ||
| }) | ||
|
|
||
| test('marginLeft is rendered into marginRight due to RTL', () => { | ||
| const snapshot = createSnapshot( | ||
| <Provider rtl={true}> | ||
| <Text content="Hello" styles={{ marginLeft: '10px' }} /> | ||
| </Provider>, | ||
| {}, | ||
| felaRenderer, | ||
| ) | ||
| expect(snapshot).toMatchSnapshot() | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should wait for #1743 to be merged first and remove this change here.
@layershifter Do you agree?