Repository navigation
Conversation
When importing class names or ids with the `:imports` pseudoselector,
this commit allows you to use these class names in CSS selectors by
wrapping them in a `:ref` pseudoselector. For example, if you have a
file which exports a CSS class like this...
```css
/* imported.css */
.classA {
}
:export {
classA: classA;
}
```
And import it into a CSS file like this...
```css
/* source.css */
:import("imported.css") {
localClassA: classA;
}
:ref(.localClassA) > .classB {
}
```
Then that last selector will be compiled down to somthing like
```css
/* compiled.css */
._imported_classA > ._source_classB {
}
```
|
Ek, the code coverage decreased because I added a bunch of guard branches that throw errors. Guess I could test some of them... |
|
Anybody interested in discussing this proposal? |
|
Is would be a addition to the CSS modules spec and should be discussed there. But we disallowed referencing class names from other modules by intent. This breaks encapsulation. You should better solve this problem by using parameters to your components. i. e.
|
|
wonderful PR |
|
It am looking for similar feature in CSS, and found ICSS actually define the It mentions that...
But the second bullet does not work with this CSS-Loader. It could be great if this loader could support that. |
When importing class names or ids with the
:importspseudoselector,this commit allows you to use these class names in CSS selectors by
wrapping them in a
:refpseudoselector. For example, if you have afile which exports a CSS class like this...
And import it into a CSS file like this...
Then that last selector will be compiled down to somthing like
The CSS Modules discussion around this is here css-modules/css-modules#102