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

Confusing example #19

Closed
bslipek opened this issue Jun 13, 2017 · 1 comment
Closed

Confusing example #19

bslipek opened this issue Jun 13, 2017 · 1 comment

Comments

@bslipek
Copy link

bslipek commented Jun 13, 2017

In this example:

const Button = styled.button`
  color: ${prop('theme.colors.white', '#fff')};
  font-size: ${ifProp({ size: 'large' }, prop('theme.sizes.lg', '20px'), prop('theme.sizes.md', '14px'))};
  background-color: ${prop('tgeme.colors.black', '#000')};
  
  ${ifProp('disabled', css`
    background-color: ${prop('theme.colors.gray', '#999')};
    pointer-events: none;
  `)}
`

we have ${ifProp('disabled', css but css is neither defined nor needed.

So it should be like that:

const Button = styled.button`
  color: ${prop('theme.colors.white', '#fff')};
  font-size: ${ifProp({ size: 'large' }, prop('theme.sizes.lg', '20px'), prop('theme.sizes.md', '14px'))};
  background-color: ${prop('tgeme.colors.black', '#000')};
  
  ${ifProp('disabled', `
    background-color: ${prop('theme.colors.gray', '#999')};
    pointer-events: none;
  `)}
`
@diegohaz
Copy link
Owner

Hey, @bslipek.

That's css from styled-components: https://www.styled-components.com/docs/api#css

And that's needed to handle interpolations (prop('theme.colors...). For instance, try to remove css here: https://www.webpackbin.com/bins/-KmWrYsZMKqn0pbntMy3

I would accept a PR adding a import styled, { css } from 'styled-components' though, if you think it might help to avoid the confusion.

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

No branches or pull requests

2 participants