2.1.0 • Published 7 years ago

easy-bem-naming v2.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Easy BEM

Easy and much friendly API for @bem/naming package.

NPM Status Travis Status Dependency Status

Usage

npm i -S easy-bem-naming

const b = require('easy-bem-naming')();

b('block') == 'block';
b('block').e('elem') == 'block__elem';

b('block').m({ m: 'v', disabled: true }) == 'block block_m_v block_disabled';
b('block').e('elem').m({ m: 'v', disabled: true }) == 'block__elem block__elem_m_v block__elem_disabled';

// any order of methods
b('block').m({ m: 'v' }).e('elem').m({ disabled: true }) == 'block__elem block__elem_m_v block__elem_disabled';

// simple mixes
b('block').mix('mixed-block', b('mixed').e('elem')) == 'block mixed-block mixed__elem';

// nested mixes
b('block').mix('mixed-block', b('mixed').e('elem').mix(b('nested-mix'))) == 'block mixed-block mixed__elem nested-mix';

// different namings
const rb = require('easy-bem-naming')('react');
const hb = require('easy-bem-naming')('two-dashes');

rb('Block').e('Elem') == 'Block-Elem';
hb('block').m({ m: 'v', disabled: true }) == 'block block--m_v block--disabled';

License MIT