css-modules-angular2 icon indicating copy to clipboard operation
css-modules-angular2 copied to clipboard

question - what if the css class name as a dash in its name

Open Memoyr opened this issue 7 years ago • 3 comments

import styles from "./button.css";

@Component({
  selector: 'buttone',
  template: `<button class="${styles.some-btn}">test</button>`,
})

is there a way to make the class .some-btn to be find, somehow the dash breaks the reference. thanks

Memoyr avatar Mar 08 '17 16:03 Memoyr

I got an alternative solution to make it work by using
import classNames from 'classnames/bind'; [(https://github.com/JedWatson/classnames)] to help multiple css import.

I'm evaluating if I should use [ngClass] for dynamic class name or cx() from classNames is OK.

Any thoughts about that ? Since I have a React background some Angular particularities are unknown to me.

Memoyr avatar Mar 08 '17 18:03 Memoyr

Hello,

Yes typically for dynamic classes ngClass would be the answer =).I am still evaluating CSS modules. I like the structure and the fact that it really is effective in removing unused CSS in a way that is a bit more difficult in other ways. That being said if you are just using css Angular's CSS mechanism is also capable of doing the same. if scopes CSS and can also find unused CSS if using a tool like codelyzer (https://twitter.com/mgechev/status/833961783521980416)

What I still havent been able to do is get CSS modules to work with AOT.

joaogarin avatar Mar 09 '17 09:03 joaogarin

@joaogarin did you ever get css modules to work with aot? And do you have an example in creating a share css module (node_module)?

playground avatar Sep 04 '17 02:09 playground