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

CSS-modules: composes #50

Closed
kenOfYugen opened this issue May 22, 2019 · 4 comments
Closed

CSS-modules: composes #50

kenOfYugen opened this issue May 22, 2019 · 4 comments

Comments

@kenOfYugen
Copy link

Jetpack is awesome @KidkArolis !
I have created a test case for CSS-modules here, npm t should point it out.
CSS-modules seem to work, but I can't get composes to inherit properties.
No matter what I tried, I couldn't fix it, hence the issue report.

.parent {
  background-color: black;
  color: green;
}

.child {
  composes: parent;
  color: red;
}

Expected:

.child {
  background-color: black;
  color: red;
}

Actual:

.child {
  color: red;
}
@KidkArolis
Copy link
Owner

Thanks! I'm using css modules quite a bit with jetpack, but never used composes. Will have a look at this issue soon.

@KidkArolis
Copy link
Owner

KidkArolis commented May 23, 2019

Heya, had a quick look, it's an issue with the way the HTML is constructed in your test case, you're missing the quotes around the class name:

-<p class=${styles.child}>Should have black BG, red text</p>
+<p class="${styles.child}">Should have black BG, red text</p>

Results in:

-<p class="styles--child___Ta3_R" styles--parent___1dfVw="">Should have black BG, red text</p>
+<p class="styles--child___Ta3_R styles--parent___1dfVw">Should have black BG, red text</p>

Or for better readability, replacing class names with just child and parent:

-<p class="child" parent="">Should have black BG, red text</p>
+<p class="child parent">Should have black BG, red text</p>

@kenOfYugen
Copy link
Author

Ahh, thanks for taking a look. My test was bad too, sorry for wasting your time.

Leaving the following reasoning for the record, in case someone stumbles upon the same mixup.
In the examples folder, class is specified without the quotes.

<div class=${styles.container}>

And I thought that it acts like the webpack css-modules demo with JSX. Apparently it doesn't.

@KidkArolis
Copy link
Owner

KidkArolis commented May 24, 2019

Ah, I should fix that exampe indeed!
Yeah, doing html with strings like that is generally not advisable, but keeps the example really minimal. This wouldn't happen with jsx.

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