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

[class=^col-] could be mismatch and won't be exported by css-loader #11

Closed
houkanshan opened this issue Feb 2, 2018 · 8 comments
Closed

Comments

@houkanshan
Copy link

Hi, I believe using [class=^col-] will lead to some problems:

  1. If col- is not at the start of a class name, like class=" col-md-6" or class="first-xs col-md-6", then it will mismatch the selector.
  2. When using css-loader, [class=^col-] won't be exported, because css-loader's CSS Module only works with class name selector. A typical user is react-flexbox-grid. I just posted a related issue there.

I'm thinking that maybe we could keep [class=^col-] and add all the explicit class names back?

Thank you!

@knulli
Copy link

knulli commented Feb 4, 2018

I have the same issue. Right now [class=^col-] does not consider Joomla classes like class="custom col-md-3 col-xs-12".

This means I have to hard code the columns instead of controlling them from inside the CMS or override the selector in my template.css.

@jacargentina
Copy link

@evgenyrodionov Any chance to fix this? Having problems as user of react-flexbox-grid

@imevro
Copy link
Owner

imevro commented Feb 21, 2018

Will dig on this week

@jacargentina
Copy link

@evgenyrodionov maybe on "this" week ? Please....

@imevro
Copy link
Owner

imevro commented Feb 27, 2018

File issue in css-loader because it’s absolutely valid css code

@imevro imevro closed this as completed Feb 27, 2018
@jacargentina
Copy link

@houkanshan are you sure this is a "css-loader" bug ? If so, please fill the issue there? Anyway @evgenyrodionov adding the classes would hurt anybody 😉

@houkanshan
Copy link
Author

Hi, @evgenyrodionov , thanks for responding.

Since currently codesandbox.io doesn't support config webpack.config.js, I have to explain by text here.

Yeh, it's valid css code. And what css-loader + style-loader (with CSS Modules enabled) export will be like this:

<style>
...

[class^="col-"] {
  box-sizing: border-box;
  flex: 0 0 auto;
  flex-basis: 100%;
  padding-right: var(--half-gutter-width, 8px);
  padding-left: var(--half-gutter-width, 8px);
  max-width: 100%;
}

...

._1fN_pog_-VsREObhSvH0-I { /* .col-xs-1 */
  flex-basis: 8.33333333%;
  max-width: 8.33333333%;
}

...
</style>

A screenshot of my project:

So when we use them in our project, like a react project, the code will be like this:

import style from 'flexboxgrid2/flexboxgrid2.css'

<div className={style['col-xs-1']}>I'm a Col guy</div>

And the generated html will be:

<div class="_1fN_pog_-VsREObhSvH0-I">I'm a Col guy</div>

Then the [class^="col-"] thing is lost.

And I thinks it's not css-loader's fault because CSS Modules is all about class name.

@imevro
Copy link
Owner

imevro commented Feb 28, 2018

Got it, thanks

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

4 participants