Skip to content

Utility for generating BEM class names using JS objects

License

Notifications You must be signed in to change notification settings

pgoforth/bem-broom

Repository files navigation

bem-broom

Utility for generating and parsing BEM class names using JS objects

Build Status Coverage Status


Usage Example

import {bem, unbem} from 'bem-broom'

const bemObject = {
    prefix: 'abc-'
    block: 'navigation',
    element: 'link',
    modifiers: {
        block: {
            location: 'header'
        },
        element: {
            active: true
        }
    }
};

const classNames = bem(bemObject);
/*
    [
        'abc-navigation',
        'abc-navigation--location_header',
        'abc-navigation__link',
        'abc-link',
        'abc-link--active',
    ]
*/

const parsedBem = unbem('xyz-block__element--modifier_value', {prefix: 'xyz-'});
/*
    {
        block: 'block',
        element: 'element',
        modifiers: {
            element: {
                modifier: 'value'
            }
        }
    }
*/

About

Utility for generating BEM class names using JS objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published