bemify-js
Simple package to facilitate BEM CSS class naming
in JS with less verbosity.
Examples
bemify
takes a block string as its first argument which will prefix
all modifier and element classes supplied within the second argument.
Non-modifier/element classes remain unaffected.
bemify('block', '--modifier-a --modifier-b');
bemify('block', '__element --modifier-a --modifier-b');
bemify('block', [
'--modifier-a',
'--modifier-b',
]);
bemify('block', {
'--modifier-a': true,
'--modifier-b': false,
'--modifier-c': true,
'some-utility': true,
'some-other-utility': false,
});
const bem = bemify('block');
bem('--modifier-a --modifier-b');
bem('__element --modifier-a --modifier-b');
Check out the tests for complete examples.