Skip to content
This repository has been archived by the owner on Oct 16, 2018. It is now read-only.

awinogradov/easy-bem-naming

Repository files navigation

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