fix: Babel plugin no longer errors on array values being passed to animationName#276
Merged
Merged
Conversation
added 2 commits
November 22, 2022 14:38
Contributor
📊 Bundle size report🤖 This report was generated against ebd004e9e8935e099c1873bf2d4841c773bb8417 |
layershifter
left a comment
Member
There was a problem hiding this comment.
Let's also add some coverage.
packages/babel-preset/src/assets/normalizeStyleRules.test.ts
+ it('handles keyframes', () => {
+ expect(
+ normalizeStyleRules(
+ path.posix,
+ '/home/projects/foo',
+ '/home/projects/foo/src/styles/Component.styles.ts',
+
+ {
+ root: {
+ animationName: [{ from: { height: '20px' }, to: { height: '10px' } }],
+ },
+ },
+ ),
+ ).toEqual({
+ root: {
+ animationName: [{ from: { height: '20px' }, to: { height: '10px' } }],
+ },
+ });
+ });packages/babel-preset/__fixtures__/keyframes/code.ts
import { makeStyles } from '@griffel/react';
export const useStyles = makeStyles({
single: {
animationName: {
from: { transform: 'rotate(0deg)' },
to: { transform: 'rotate(360deg)' },
},
},
multiple: {
animationName: [
{
from: { transform: 'rotate(0deg)' },
to: { transform: 'rotate(360deg)' },
},
{
from: { height: '100px' },
to: { height: '200px' },
},
],
},
});packages/babel-preset/__fixtures__/keyframes/output.ts
import { __styles } from '@griffel/react';
export const useStyles = __styles(
{
single: {
Bv12yb3: ['f1g6ul6r', 'f1fp4ujf'],
},
multiple: {
Bv12yb3: ['f1e467oh', 'f1w9bd63'],
},
},
{
k: [
'@-webkit-keyframes f1q8eu9e{from{-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg);}to{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);}}',
'@-webkit-keyframes f55c0se{from{-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg);}to{-webkit-transform:rotate(-360deg);-moz-transform:rotate(-360deg);-ms-transform:rotate(-360deg);transform:rotate(-360deg);}}',
'@keyframes f1q8eu9e{from{-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg);}to{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);}}',
'@keyframes f55c0se{from{-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg);}to{-webkit-transform:rotate(-360deg);-moz-transform:rotate(-360deg);-ms-transform:rotate(-360deg);transform:rotate(-360deg);}}',
'@-webkit-keyframes f19fnzg9{from{height:100px;}to{height:200px;}}',
'@keyframes f19fnzg9{from{height:100px;}to{height:200px;}}',
],
d: [
'.f1g6ul6r{-webkit-animation-name:f1q8eu9e;animation-name:f1q8eu9e;}',
'.f1fp4ujf{-webkit-animation-name:f55c0se;animation-name:f55c0se;}',
'.f1e467oh{-webkit-animation-name:f1q8eu9e,f19fnzg9;animation-name:f1q8eu9e,f19fnzg9;}',
'.f1w9bd63{-webkit-animation-name:f55c0se,f19fnzg9;animation-name:f55c0se,f19fnzg9;}',
],
},
);packages/babel-preset/src/transformPlugin.test.ts
{
title: 'call of non existing module',
fixture: path.resolve(fixturesDir, 'non-existing-module-call', 'code.ts'),
outputFixture: path.resolve(fixturesDir, 'non-existing-module-call', 'output.ts'),
},
+ {
+ title: 'syntax: animationName',
+ fixture: path.resolve(fixturesDir, 'keyframes', 'code.ts'),
+ outputFixture: path.resolve(fixturesDir, 'keyframes', 'output.ts'),
+ },
added 3 commits
November 23, 2022 15:12
layershifter
approved these changes
Nov 24, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
This PR fixes an issue with the babel plugin that errored when an array of animations was being passed to
animationName. This happened because the plugin tried to parse each animation as an individual rule instead of as an object with rules inside of it.Related issue(s)