kadirahq / mantra

Mantra - An Application Architecture for Meteor
https://kadirahq.github.io/mantra/
976 stars 50 forks source link

CSS Convention - Scoping vs BEM vs OOCSS vs SMACSS #156

Open merlinstardust opened 8 years ago

merlinstardust commented 8 years ago

Does Mantra have a preferred CSS convention?

adamdawkins commented 8 years ago

Not sure this feels like something Mantra should have an opinion on. With so many CSS Frameworks also used in UI development, it could be a bit hard to enforce.

+, for most intents and purposes, BEM, SMACSS and OOCSS are very much variants of the same school of CSS thought.

arunoda commented 8 years ago

Since the React community is going forward with CSS in JS, that's a kind of way we can go. We started with few projects with that and we are loving that.

Specially Radium allows us to do much better inline styling.

And I also like CSS frameworks which abstract the CPU via some React components. These are two such good projects:

arunoda commented 8 years ago

I also agree with @adamdawkins that there are so many ways to deal with CSS and we can't enforce one such way.

natecox commented 8 years ago

I feel much the same way about this as I do about enforcing strict linting styles: people feel too strongly about the way CSS is structured, and it has little bearing on the functionality of the app, so I don't think we should try to impose a standard here. It's basically an invitation for evangelism and arguments.

merlinstardust commented 8 years ago

There's definitely a lot of CSS methodologies out there just like there are lots of style recommendations for JavaScript. But it seems that Mantra is going to recommend an eslint config so I think recommending a CSS methodology is within the scope of the spec.

I do think that CSS in JS does seem to be the way forward after seeing this slide deck.

arunoda commented 8 years ago

I wrote an article on this too: https://voice.kadira.io/state-of-react-and-css-501d179443d3#.jwxj8y2ee

fermuch commented 8 years ago

The best tool I found so far is JSS. Pure js, and compiles to CSS.

You create a javascript file which exports an object, and that object has all the style definitions (check out the playground). When you need those styles, you can simply import them (since they're JS files), and use jss.createStyleSheet to compile the object to CSS.

It works well with mantra, since it doesn't need external compilers, and everything is self-contained. You can even write the definitions inside the component itself, and you don't have global style definitions, so everything is self contained in the component.

v-anyukov commented 8 years ago

@fermuch Hi! Did you try this https://github.com/jsstyles/react-jss? Cant make it work properly with mantra =(

fermuch commented 8 years ago

@v-anyukov take a look at this link.