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

evaluate BEM naming convention #32

Open
gasolin opened this issue Apr 11, 2014 · 1 comment
Open

evaluate BEM naming convention #32

gasolin opened this issue Apr 11, 2014 · 1 comment

Comments

@gasolin
Copy link
Contributor

gasolin commented Apr 11, 2014

I noticed that the css selectors does not changed a lot in https://github.com/mozilla-b2g/Gaia-UI-Building-Blocks/tree/v2/style/headers

I'd like to hear @rnowm your opinion of adopting some syntax naming rules such as BEM
http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/

With this naming rule, we could easier recognize what this selector does, use more flatten css selector to applying styles, avoid cascade selector error which csslint reports.

With BEM naming style, the bb-header might looks like

.bb-header /* the block */
.bb-header__subheader /* the block with element */
.bb-header__menu
.bb-header__menu--action  /* the block with element and modifier */

For class inheritance, LESS can also come to help

.bb-header menu {
  height: 100%;
  padding: 0;
  margin: 0;
}
.bb-header__menu
@import bb-header
@gasolin
Copy link
Contributor Author

gasolin commented Apr 11, 2014

Another kind of naming rule with same concept
http://benfrain.com/modular-css-bem-oocss-naming/ for reference

 .namespace-ComponentName_ModifierName-variant-label
name-space : all lowercase/train-case (optional).
ComponentName : upper camel case (non-optional)
_ModifierName : upper camel case preceded by an underscore (optional)
-variant-label : all lowercase/train-case (optional)

or

.moduleName {}
.moduleName__element {}
.moduleName__element–is–modified {}

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

1 participant