-
Notifications
You must be signed in to change notification settings - Fork 261
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
Class re-writing mode #27
Comments
Definitely looking forward to have such option, not only it will help excluding less performant attr styles, but also:
|
Some elaboration on this. If there's a tag selector: p { } it becomes .$prefix_p { } and each element gets a class with its tag name. ie: If there's a class selector: .woot { } it becomes .$prefix_woot { } If there's an attribute selector: [title=woot] {
color: blue
} it becomes .$prefix[title=woot] {
color: blue
} and we make sure each element gets a generic random class as well, maybe by passing true as the last arg |
The following will produce conflicts .p {}
p {} .$prefix_p { }
.$prefix_p {} class and ids should probably use a different delimiter to differentiate it from tag selectors. .$prefix_p { } /* tag */
.$prefix__p {} /* class */ |
also it breaks the specificity model. The current behaviour is the right one because it bumps the specificity of every selector by className=_styledJsxConcat('h4sh', originalExpression) Result: p.h4sh {}
.p.h4sh {}
*.h4sh {}
#test.h4sh {}
/* and so on */ |
why is the hash after the user defined selector?
to generate
and have the hash added to just the parent element |
Also |
For wildcard we can give a class to every element with the prefix
…On Wed, Jan 4, 2017 at 6:18 AM Giuseppe ***@***.***> wrote:
.h4sh p will affect the entire subtree.
Also * { color: red } converted to .h4sh* { color: red } won't work
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAy8ZC8NhVaUQnbVm_MgZWOiSigVTTmks5rO6pAgaJpZM4LHR2n>
.
|
@giuseppeg
shouldn't the selector so
becomes
then @rauchg does that mean you also have to apply the namespace to the elements children, and how far down the tree does this happen if that's the case. |
"affect the entire subtree" means that you're affecting elements of children components you don't know about |
Obviously you could force people to use |
You could auto insert the h1 span, h2 {} will generate. h1[data-jsx="woot"] span[data-jsx="woot"], h2[data-jsx="woot"] {} |
@thysultan size is not a problem gzip will do the magic since it is very repetitive data.
I meant that in styled-jsx styles shouldn't cross the boundaries of the current component and therefore don't leak into nested components. If you use the children selector <div>
<p>
<span>zeit <span>rocks</span></span>
</p>
</div> and want to style the innermost span > span { color: red } If you need to style it with the children selector the css should be: div > p > span > span { color: red } How would you do that? Also now you've increased the specificity of the selector. |
see #247 |
Could someone please explain how this resolves the styled-jsx not working with antd components issue? I still could not get styled-jsx working with antd. antd components' class name doesn't have the random number generated by style-jsx. Therefore, it never matches the style. The workaround I have are:
I think either of the solutions is not ideal. Would be great to have a consistent solution across the whole project which is having styled-jsx to handle all the styling. Thank you very much for any help in advance. |
@yxh10 Do you have any idea about your question? I have the same problem now. |
@yxh10 I'm also having this same issue |
In case anyone is dealing with this problem in the future, seems it can now be handled by either using: I feel that using
I guess as long as the components have sufficiently unique ids/classNames to prevent css conflicts, it shouldn't be a big problem. |
除了 resolve tag 有什么更为优雅的解决方案吗? |
For background: #4 (comment)
The transformation we might have to use would look like this:
becomes
and the implementation of
_styledJsxPrefix
would perform class prefixingThe text was updated successfully, but these errors were encountered: