Skip to content

Commit

Permalink
fix(styled-components): fix keyframes error in v5
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Apr 29, 2020
1 parent 15affbb commit ccf3469
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/styled-components/src/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createSystemComponent } from '@xstyled/system'
import { css } from './css'

function getCreateStyle(baseCreateStyle) {
const createStyle = (...args) => baseCreateStyle([css(...args)])
const createStyle = (...args) => baseCreateStyle`${css(...args)}`
createStyle.attrs = (attrs) => {
const nextCreateStyle = baseCreateStyle.attrs(attrs)
return getCreateStyle(nextCreateStyle)
Expand Down
22 changes: 22 additions & 0 deletions packages/styled-components/src/styled.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ describe('#styled', () => {
expect(container.firstChild).toHaveAttribute('aria-label', 'label')
expect(container.firstChild).toHaveStyle('margin: 8px;')
})

it('works with keyframes', () => {
const animation = keyframes`
from {
transform: translateX(0%);
}
to {
transform: translateX(100%);
}
`
const Dummy = styled.div`
${css`
animation: ${animation};
`}
`
const { container } = render(<Dummy />)

expect(container.firstChild).toHaveStyle(
`animation: ${animation.getName()};`,
)
})
})

describe('#styled.xxx', () => {
Expand Down

0 comments on commit ccf3469

Please sign in to comment.