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

RCSS rule priority #20

Open
charliermarsh opened this issue Jun 14, 2014 · 4 comments
Open

RCSS rule priority #20

charliermarsh opened this issue Jun 14, 2014 · 4 comments

Comments

@charliermarsh
Copy link
Collaborator

I've been experimenting with converting a large LESS-based webapp to RCSS (or, at least, converting a few React components). One problem I've run into several times is that RCSS classes are pretty low in terms of style precedence. In other words, if I convert a single React component to RCSS, there are often some lingering LESS selectors with higher priority that negate a lot of changes (to make things worse, the larger the nesting, the higher the priority of the selector, per CSS-tricks).

As a work-around, I've had to utilize "!important" in an ugly way, so much so that I've considered adding an "auto-!important" option to RCSS.createClass that simply appends "!important" to every rule.

For illustrative purposes, it's also worth considering this proposal, where they apply styles inline, rather than through CSS classes, which immediately skirts around this issue of precedence.

It'd be good to have a discussion about whether or not this merits addressing (in a fully-RCSSified webapp, it wouldn't really be a problem) and what the potential workarounds might be. Intuitively, adding "auto-!important" actually seems weirdly reasonable, given that adding an RCSS class to a React component is such a deliberate move that it should be considered the most important styling.

@chenglou
Copy link
Owner

Ugh, my knee-jerk reaction is no to auto-!important. I'll give more thoughts about it.
Applying style inline should be possible. Except I goofed up the initial API and now there's this unrelated className key in your object. The new API might solve this? #11. Again, I'll think more about it.

@charliermarsh
Copy link
Collaborator Author

Yeah, I don't like !important either--it's clearly a hack. The new API looks good and would certainly solve some of these problems.

@chenglou
Copy link
Owner

facebook/react#1881
^ gonna see what happens to that issue next.

@charliermarsh
Copy link
Collaborator Author

Makes sense. I think we can just leave this issue be if we support using the style object inline (which we do now).

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