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

Javascript evaluation behavior #1

Open
mistadikay opened this issue May 22, 2017 · 4 comments
Open

Javascript evaluation behavior #1

mistadikay opened this issue May 22, 2017 · 4 comments

Comments

@mistadikay
Copy link

Hey! Love this plugin, it helps me to migrate to JSS really quickly.

However, it looks like javascript evaluation is somewhat limited. For example, this will be evaluated:

preJSS`
  content {
    background: ${(props) => `#fff url(${props.bg}) no-repeat`};
  }
`

But this will not:

preJSS`
  content {
    background: #fff url(${(props) => props.bg}) no-repeat;
  }
`

Result will look like this:

.content-0-126 {
    background: #fff url($^var__b4437b02-7ad4-1a12-c124-a6b8a508e7fc) no-repeat;
}

Is it expected behavior? If it is, maybe it makes sense to document it?

@sukazavr
Copy link

I have the same issue.
@mistadikay did you find a solution?

@mistadikay
Copy link
Author

@sukazavr apparently it's just the way (react-)jss works — you can have functions only as a replacement of property values, but not inside of those values

@sukazavr
Copy link

@mistadikay but straight injections doesn't work too:

preJSS`
html {
  font-size: ${baseFontSizePx}px;
}
`

Trinspiled to:

html {
  font-size: $^var__19e1c95c-a11c-54e0-d0eb-f10f33336d5dpx;
}

Is it a function too?

@mistadikay
Copy link
Author

yeah, this wouldn't work:

preJSS`
html {
  font-size: ${baseFontSizePx}px;
}
`

this would work:

preJSS`
html {
  font-size: ${baseFontSizePx};
}
`

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