Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/templates/styledComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = ({
styleString,
propsString,
systemFunctions,
systemExpressions = '',
extensionImport
}) => `import styled from 'styled-components'
import {
Expand All @@ -15,13 +16,14 @@ import {
} from 'styled-system'
${extensionImport}

const ${name} = styled(${type})([], props => (${styleString}),
space,
fontSize,
width,
color,
${systemFunctions}
)
const ${name} = styled(${type})\`
\${styleString}
\${space}
\${fontSize}
\${width}
\${color}
${systemExpressions}
\`

${name}.defaultProps = ${propsString}

Expand Down
34 changes: 20 additions & 14 deletions test/snapshots/modules.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ Generated by [AVA](https://ava.li).
value: true␊
});␊
var _templateObject = _taggedTemplateLiteral(['\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n \\n'], ['\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n \\n']);␊
var _styledComponents = require('styled-components');␊
var _styledComponents2 = _interopRequireDefault(_styledComponents);␊
Expand All @@ -204,9 +206,9 @@ Generated by [AVA](https://ava.li).
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }␊
var Box = (0, _styledComponents2.default)('div')([], function (props) {
return {};
}, _styledSystem.space, _styledSystem.fontSize, _styledSystem.width, _styledSystem.color);␊
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var Box = (0, _styledComponents2.default)('div')(_templateObject, styleString, _styledSystem.space, _styledSystem.fontSize, _styledSystem.width, _styledSystem.color);␊
Box.defaultProps = {};␊
Expand All @@ -223,6 +225,8 @@ Generated by [AVA](https://ava.li).
value: true␊
});␊
var _templateObject = _taggedTemplateLiteral(['\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n \\n'], ['\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n \\n']);␊
var _styledComponents = require('styled-components');␊
var _styledComponents2 = _interopRequireDefault(_styledComponents);␊
Expand All @@ -231,9 +235,9 @@ Generated by [AVA](https://ava.li).
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }␊
var Text = (0, _styledComponents2.default)('p')([], function (props) {
return {};
}, _styledSystem.space, _styledSystem.fontSize, _styledSystem.width, _styledSystem.color);␊
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var Text = (0, _styledComponents2.default)('p')(_templateObject, styleString, _styledSystem.space, _styledSystem.fontSize, _styledSystem.width, _styledSystem.color);␊
Text.defaultProps = {␊
m: 0␊
Expand Down Expand Up @@ -287,6 +291,8 @@ Generated by [AVA](https://ava.li).
value: true␊
});␊
var _templateObject = _taggedTemplateLiteral(['\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n \\n'], ['\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n \\n']);␊
var _styledComponents = require('styled-components');␊
var _styledComponents2 = _interopRequireDefault(_styledComponents);␊
Expand All @@ -299,9 +305,9 @@ Generated by [AVA](https://ava.li).
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }␊
var Beep = (0, _styledComponents2.default)(_Box2.default)([], function (props) {
return {};
}, _styledSystem.space, _styledSystem.fontSize, _styledSystem.width, _styledSystem.color);␊
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var Beep = (0, _styledComponents2.default)(_Box2.default)(_templateObject, styleString, _styledSystem.space, _styledSystem.fontSize, _styledSystem.width, _styledSystem.color);␊
Beep.defaultProps = {␊
p: 3,␊
Expand All @@ -321,6 +327,8 @@ Generated by [AVA](https://ava.li).
value: true␊
});␊
var _templateObject = _taggedTemplateLiteral(['\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n', '\\n', '\\n', '\\n'], ['\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n ', '\\n', '\\n', '\\n', '\\n']);␊
var _styledComponents = require('styled-components');␊
var _styledComponents2 = _interopRequireDefault(_styledComponents);␊
Expand All @@ -333,11 +341,9 @@ Generated by [AVA](https://ava.li).
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }␊
var Flex = (0, _styledComponents2.default)(_Box2.default)([], function (props) {␊
return {␊
display: 'flex'␊
};␊
}, _styledSystem.space, _styledSystem.fontSize, _styledSystem.width, _styledSystem.color, _styledSystem.alignItems, _styledSystem.justifyContent, _styledSystem.flexDirection, _styledSystem.flexWrap);␊
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }␊
var Flex = (0, _styledComponents2.default)(_Box2.default)(_templateObject, styleString, _styledSystem.space, _styledSystem.fontSize, _styledSystem.width, _styledSystem.color, _styledSystem.alignItems, _styledSystem.justifyContent, _styledSystem.flexDirection, _styledSystem.flexWrap);␊
Flex.defaultProps = {};␊
Expand Down
Binary file modified test/snapshots/modules.js.snap
Binary file not shown.
29 changes: 14 additions & 15 deletions test/snapshots/templates.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,14 @@ Generated by [AVA](https://ava.li).
} from 'styled-system'␊
import Div from './Div'␊
const Box = styled(Div)([], props => ({}),␊
space,␊
fontSize,␊
width,␊
color,␊
const Box = styled(Div)`␊
${styleString}␊
${space}␊
${fontSize}␊
${width}␊
${color}␊
)
`
Box.defaultProps = {}␊
Expand All @@ -341,16 +342,14 @@ Generated by [AVA](https://ava.li).
} from 'styled-system'␊
const Hello = styled(h2)([], props => ((props, theme) => ({␊
fontFamily: 'inherit',␊
color: props.theme('colors.blue')␊
})),␊
space,␊
fontSize,␊
width,␊
color,␊
const Hello = styled(h2)`␊
${styleString}␊
${space}␊
${fontSize}␊
${width}␊
${color}␊
)
`
Hello.defaultProps = {␊
p: 2␊
Expand Down
Binary file modified test/snapshots/templates.js.snap
Binary file not shown.