Skip to content

Commit d643460

Browse files
committed
handle styled.x(fn)
1 parent a43b7fa commit d643460

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/visitors/displayNameAndId.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ export default t => (path, state) => {
139139
? isStyled(t)(path.node.tag, state)
140140
: isStyled(t)(path.node.callee, state) &&
141141
path.node.callee.property &&
142-
path.node.callee.property.name !== 'withConfig' &&
143-
t.isObjectExpression(path.node.arguments[0])
142+
path.node.callee.property.name !== 'withConfig'
144143
) {
145144
const displayName =
146145
useDisplayName(state) &&

test/__snapshots__/index.test.js.snap

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,14 @@ styled.div.withConfig({
170170
})({
171171
color: red
172172
});
173-
const notStyled =
173+
const StyledFunctionForm =
174174
/*#__PURE__*/
175-
styled.div('')\`\`; // not transpiled by styled components but should add pure comment
176-
175+
styled.div.withConfig({
176+
displayName: \\"annotate-styled-calls-with-pure-comments__StyledFunctionForm\\",
177+
componentId: \\"sc-6tnjs3-8\\"
178+
})(p => ({
179+
color: p.color || 'red'
180+
}));
177181
const normalFunc = add(5, 3);"
178182
`;
179183

test/fixtures/annotate-styled-calls-with-pure-comments/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ let Component
88
Component = styled.div``
99
const WrappedComponent = styled(Inner)``
1010
const StyledObjectForm = styled.div({ color: red })
11-
const notStyled = styled.div('')`` // not transpiled by styled components but should add pure comment
11+
const StyledFunctionForm = styled.div(p => ({ color: p.color || 'red' }))
1212
const normalFunc = add(5, 3)

0 commit comments

Comments
 (0)