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

Using padding: ${'.3rem'} 0; not work #32

Open
zhangyu921 opened this issue Jan 23, 2019 · 1 comment
Open

Using padding: ${'.3rem'} 0; not work #32

zhangyu921 opened this issue Jan 23, 2019 · 1 comment

Comments

@zhangyu921
Copy link

Bug report;

What is the current behavior?

.inner {
            padding: ${'.3rem'} 0; // not work
            //padding: ${`${px2rem(30)} 0`};  //good
}

What is the expected behavior?

Environment (include versions)

  • OS: mac os mojave
  • Browser: chrome
  • styled-jsx (version): 3.2
@AnatoleLucet
Copy link

To give a bit more context, when you use the template literals syntax (${...}) to inject a js value in your css which is somewhere after followed by a space and a character (; not included), the value you "injected" will not be included in the processed css.

Quick examples:

const aValueInPx = 5;

// ...

// working
any-css-property: ${aValueInPx};    // --> "any-css-property: 5;"
any-css-property: ${aValueInPx} ;   // --> "any-css-property: 5;"
any-css-property: ${aValueInPx}px;  // --> "any-css-property: 5px;"

// not working
any-css-property: ${aValueInPx}px 0;        // --> "any-css-property: px 0;"
any-css-property: ${aValueInPx}px anything; // --> "any-css-property: px anything;"

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