Skip to content

Commit

Permalink
Merge pull request #582 from ben-rogerson/bugfix/tweak-styled-import-…
Browse files Browse the repository at this point in the history
…styled-components-preset
  • Loading branch information
ben-rogerson committed Dec 6, 2021
2 parents d1a7659 + df64f6f commit 4d7e207
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 18 deletions.
3 changes: 0 additions & 3 deletions __fixtures__/autoCssProp/config.json

This file was deleted.

4 changes: 4 additions & 0 deletions __fixtures__/cssPropEmotion/autoCssProp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import './macro' // twinImport

;<div css="" />
;<div className="" />
8 changes: 8 additions & 0 deletions __fixtures__/cssPropEmotion/autoCssPropWithStyled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import tw from './macro' // twinImport

// Css prop isn't handled by twin
tw.div`block`
;<div tw="block" />

const Test = tw.div``
;<Test tw="block" />
4 changes: 4 additions & 0 deletions __fixtures__/cssPropStyledComponents/autoCssProp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import './macro' // twinImport

;<div css="" />
;<div className="" />
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ import tw from './macro' // twinImport

tw.div`block`
;<div tw="block" />

const Test = tw.div``
;<Test tw="block" />
4 changes: 4 additions & 0 deletions __fixtures__/cssPropStyledComponents/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"preset": "styled-components",
"autoCssProp": false
}
100 changes: 86 additions & 14 deletions __snapshots__/plugin.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3714,9 +3714,39 @@ exports[`twin.macro autoCssProp.js: autoCssProp.js 1`] = `

import './macro' // twinImport

// Css prop isn't handled by twin
; <div css="" />
; <div className="" />
// Css prop isn't handled by twin
;<div css="" />
;<div className="" />

↓ ↓ ↓ ↓ ↓ ↓

;<div css="" />
;<div className="" />


`;

exports[`twin.macro autoCssProp.js: autoCssProp.js 2`] = `

import './macro' // twinImport

;<div css="" />
;<div className="" />

↓ ↓ ↓ ↓ ↓ ↓

;<div css="" />
;<div className="" />


`;

exports[`twin.macro autoCssProp.js: autoCssProp.js 3`] = `

import './macro' // twinImport

;<div css="" />
;<div className="" />

↓ ↓ ↓ ↓ ↓ ↓

Expand All @@ -3730,30 +3760,72 @@ exports[`twin.macro autoCssPropWithStyled.js: autoCssPropWithStyled.js 1`] = `

import tw from './macro' // twinImport

// Css prop isn't handled by twin
tw.div\`block\`
;<div tw="block" />

const Test = tw.div\`\`
;<Test tw="block" />

↓ ↓ ↓ ↓ ↓ ↓

import _styled3 from 'styled-components'
import _styled2 from 'styled-components'
import _styled from '@emotion/styled'

// twinImport
_styled2.div.withConfig({
displayName: 'plugintest',
componentId: 'sc-16ats9e-0',
})({
// Css prop isn't handled by twin
_styled.div({
display: 'block',
})

var _StyledDiv = _styled2('div').withConfig({
displayName: 'plugintest___StyledDiv',
componentId: 'sc-16ats9e-1',
})({
;<div
css={{
display: 'block',
}}
/>

const Test = _styled.div({})

;<Test
css={{
display: 'block',
}}
/>


`;

exports[`twin.macro autoCssPropWithStyled.js: autoCssPropWithStyled.js 2`] = `

import tw from './macro' // twinImport

tw.div\`block\`
;<div tw="block" />

const Test = tw.div\`\`
;<Test tw="block" />

↓ ↓ ↓ ↓ ↓ ↓

import _styled from 'styled-components'

// twinImport
_styled.div({
display: 'block',
})

;<_StyledDiv />
;<div
css={{
display: 'block',
}}
/>

const Test = _styled.div({})

;<Test
css={{
display: 'block',
}}
/>


`;
Expand Down
2 changes: 1 addition & 1 deletion src/config/userPresets.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
'styled-components': {
styled: {
import: 'default',
from: 'styled-components/macro',
from: 'styled-components',
},
css: {
import: 'css',
Expand Down

0 comments on commit 4d7e207

Please sign in to comment.