feat(Provider): add option for disabling animations#1377
Conversation
-added disableAnimations prop in the theme object
Codecov Report
@@ Coverage Diff @@
## master #1377 +/- ##
==========================================
- Coverage 73.26% 73.14% -0.12%
==========================================
Files 802 805 +3
Lines 6021 6073 +52
Branches 1755 1775 +20
==========================================
+ Hits 4411 4442 +31
- Misses 1604 1625 +21
Partials 6 6
Continue to review full report at Codecov.
|
… Provider -fixed regressions -changed the ProviderConsumer render method to provide the a context object containing everything expect just the theme
-exported mergeContexts from the lib index.ts
packages/react/src/themes/teams/components/Animation/animationStyles.ts
Outdated
Show resolved
Hide resolved
-fixed regressions -added tests for the new plugin
| ) => React.ReactNode | ||
| /** Styled applied to the root element of the rendered component. */ | ||
| rootCSS?: ICSSInJSStyle | ||
| rootCSS?: React.CSSProperties |
There was a problem hiding this comment.
As these are applied on div elements, we need the React.CSSProperties as a type
| animationName?: StardustAnimationName | string | 'none' | ||
| } | ||
|
|
||
| export interface ICSSInJSStyle extends CSSProperties { |
There was a problem hiding this comment.
This makes the ICSSInJSStyle not being able to accept something typed as React.CSSProperties. Not sure if this will be a problem, but if we don't add this, we will have to introduce new names for the animations defined as stardust animations (as {keyframe: function, params: {...}})
|
|
||
| const renderer = { renderKeyframe: jest.fn() } | ||
| renderKeyframesPlugin(style, 'RULE', renderer) | ||
| expect(renderer.renderKeyframe).toHaveBeenCalledWith(expect.any(Function), params) |
There was a problem hiding this comment.
Not sure how to check here that the keyframe was actually the first param, as the animationName is replaced with string after the plugin is invoked, so I cannot use the same reference. I tried extracting the keyframe function in a const, but then again jest reports it as a different function.
packages/react/src/themes/teams/components/Animation/animationStyles.ts
Outdated
Show resolved
Hide resolved
| root: () => ({ | ||
| display: 'inline-block', | ||
| }), | ||
| children: ({ props, variables, theme }) => { |
There was a problem hiding this comment.
It's strange to have children slot, but I don't have better idea
There was a problem hiding this comment.
I was struggling a bit with this one as well, but this is the most correct..
packages/react/test/specs/lib/felaDisableAnimationsPlugin-test.ts
Outdated
Show resolved
Hide resolved
# Conflicts: # packages/react/src/components/Icon/Icon.tsx # packages/react/src/themes/base/components/Icon/iconStyles.ts
|
Can we add a new dedicated example to docs for the |
|
@layershifter yes, will add some examples. Do you agree with adding examples in the Provider's page for the |
|
@mnajdova Not sure about |
|
I added for rtl and disableAnimations. As the renderer is now something we are calculating, will not specify example for it. I don't see why we should not have an example of how rtl is used, as we have it as an option on each example. |
# Conflicts: # packages/react/src/lib/renderComponent.tsx

Changes introduced in the API with this PR in order to fix #1273:
themeobject does not contain thertlandrendererprops anymore. These props, together with the new addeddisableAnimationsprop are hoisted at the top level of theProvider's props API:Prev:
Now:
ComponentStyleFunctionParaminterface is extended with thertlprop, which is not defined in thethemeanymore, as well as with the newdisableAnimationsprop.TODO