-
Notifications
You must be signed in to change notification settings - Fork 49
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
usage with styled-jsx and styles #103
Comments
@conarwelsh thank you for reporting this. I guess the issue is in our generator, we should combine the content of piped text into TemplateLiteral. Will check out deeper and let you know the results ;) |
Proposed SolutionCombine tokens between Then transform ProblemSo, when we give input like this style.
.wrapper {
color: red;
} It generates these tokens for pug text: { type: 'start-pipeless-text', ... }
{ type: 'text', ... ,
val: '.wrapper {' }
{ type: 'newline', ... }
{ type: 'text', ... ,
val: ' color: red;' }
{ type: 'newline', ... }
{ type: 'text', ... ,
val: '}' }
{ type: 'newline', ... }
{ type: 'text', ... ,
val: '' }
{ type: 'end-pipeless-text', ... } When we map these tokens to JSX we get something like this: { type: 'JSXText',
value: '.wrapper {' }
{ type: 'JSXExpressionContainer',
expression: {
type: 'StringLiteral',
value: '\n' } }
{ type: 'JSXExpressionContainer',
expression: {
type: 'StringLiteral',
value: ' color: red;' } }
{ type: 'JSXExpressionContainer',
expression: {
type: 'StringLiteral',
value: '\n' } }
{ type: 'JSXText',
value: '}'}
{ type: 'JSXExpressionContainer',
expression: {
type: 'StringLiteral',
value: '\n' } }
{ type: 'JSXText',
value: ''} To make it work it should return something like this: { type: 'JSXExpressionContainer',
expression: {
type: 'TemplateLiteral',
quasis: [{
type: 'TemplateElement',
value: '\n .wrapper {\n background: blue\n }\n '
}] } } Might be a bit different, picked that from astexplorer: https://astexplorer.net/#/gist/3fc6bec2eea654d23e0d4e7683cce74e/dc5a0bc575151295e7cbe5c5341172dc0d78cf89 |
@conarwelsh I'm gonna take care about this soon, but it will take some time. I assume to deliver this by Tuesday (I hope earlier though). |
@conarwelsh well, it might take more time than I expected due to personal circumstances. In the meantime you can apply a workaround: styled(jsx) ${`
.wrapper {
background: blue
}
`}
styled(jsx) ${`
.wrapper
background: blue
`} |
Hello! Similar situation here: I tried to use Pug and integrate external CSS and styles outside of the component, without luck in both cases. I believe the problem is related/smiliar to this issue. |
@2mittens hm, external styles should not be affected this plugin. Will it be possible for you to provide a repository or example on any sandbox where I can see the reproduced issue? |
Sure, you can find a simple example here: https://github.com/2mittens/pug-external-styled-jsx Let me know if you need anything else, thank you! |
Quick update, I found an obvious workaround to make external styles work with pug while also taking advantage of styled-jsx scoping:
|
The It seems like whatever is happening is due to the style-jsx logic executing after the pug transform. This seems to be a much larger issue than that the original author is reporting. Quite simply, these two plugins don't seem to work with each other at all. You can test with @stefan-contiero's example. |
Any news about this issue? |
@teetl6 unfortunately there is no updates. I'd like to discuss others' possible implementations or any code contribution regarding this problem... |
I am using Next.js, and would like to use Pug instead of JSX, and Stylus instead of normal CSS. However I am running into some headaches. Maybe you can spot a simple mistake I am missing? I am guessing it is just ordering of the plugins somehow but not sure how to change that. It is an empty repo so it is simple to reproduce, its just as follows:
pages/index.js
package.json
babel.config.js
The text was updated successfully, but these errors were encountered: