Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type error with modifier #367

Merged
merged 3 commits into from
Nov 9, 2021

Conversation

timhwang21
Copy link
Contributor

Closes #268.

Copy link

@cscheffauer cscheffauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid to me!

@quantizor
Copy link
Contributor

Why are you trying to put a tagged template literal into the modifier field?

@timhwang21
Copy link
Contributor Author

Because that's what the README suggests for this use case.

If a rule is nested within another styled-component, the modifier option can be used with the css helper to target the nested rule.

const Button = styled.button`
  color: red;
`

const ButtonList = styled.div`
  display: flex;

  ${Button} {
    flex: 1 0 auto;
  }
`

import { css } from 'styled-components';

test('nested buttons are flexed', () => {
  const tree = renderer.create(<ButtonList><Button /></ButtonList>).toJSON()
  expect(tree).toHaveStyleRule('flex', '1 0 auto', {
    modifier: css`${Button}`,
  })
})

@quantizor
Copy link
Contributor

@timhwang21 ok cool, could you merge from main and run yarn to clear the lockfile merge conflict?

@timhwang21
Copy link
Contributor Author

Will do -- looks like @types/styled-components has been updated since then so I updated that to latest as well.

@quantizor quantizor enabled auto-merge (squash) November 9, 2021 17:42
@quantizor quantizor merged commit 4fcfd98 into styled-components:main Nov 9, 2021
@timhwang21 timhwang21 deleted the timothy/268 branch November 9, 2021 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type error with modifier?
4 participants