-
Notifications
You must be signed in to change notification settings - Fork 11
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
About more universal Nested Rules #26
Comments
I also want to use css-in-js: const st = cssInJS({
box: {
color: 'red',
width: 100,
height: 40,
'&:hover': {
color: 'blue',
'.hiddenBtn': {
opacity: 1
},
'& > .normalBtn': {
marginRight: 10
}
}
}
}) babel: const st = {
box: 'dir_filename_js-styles-box',
hiddenBtn: 'dir_filename_js-styles-hiddenBtn',
normalBtn: 'dir_filename_js-styles-normalBtn'
} css: .dir_filename_js-styles-box {
color: red;
width: 100px;
height: 40px;
}
.dir_filename_js-styles-box:hover {
color: blue;
}
.dir_filename_js-styles-box:hover .dir_filename_js-styles-hiddenBtn {
opacity: 1;
}
.dir_filename_js-styles-box:hover > .dir_filename_js-styles-normalBtn {
marginRight: 10px;
} |
Hi Alfred, sorry for the delay.
Sure! Happy to merge any of the improvements you're talking about. Thanks! |
I'll try it if I have some time. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently
babel-plugin-css-in-js
support some nested rules using global selectors$
, but they are very limited. I'm considering implementing nested rules for a universal case used in css pre-processes such as less and stylus. ( see the example below )Component:
css-in-js
babel:
css
[Image1]
In the First
box
inImage1
.box .hiddenBtn
selector works well. But in the second box,.box .hiddenBtn
selector will select all.hiddenBtn
in the box.it might be a bug. (Because developers always can write
.box .hiddenBtn
selector instead of.box > .hiddenBtn
selector, I don't mention about.box > .hiddenBtn
selector here )So I like the globally unique (randomized) className this plugin creates. Ever since I use this plugin, no matter how big the application was, there was no bug affected by the unintentional css rule. In order to keep this benefit, in nested rules, both
box
andhiddenBtn
must be uniqued.The global selector concept is great for theme, but I want to implement nested rules with a more universal concept that is used by other pre-processors that operate independently of the global selector nested rules.
Could I make some PR?
The text was updated successfully, but these errors were encountered: