@maxwellmri/bem

A small helper function for managing BEM classes.

Stats

StarsIssuesVersionUpdatedCreatedSize
@maxwellmri/bem
200.3.44 years ago4 years agoMinified + gzip package size for @maxwellmri/bem in KB

Readme

bem

bem is a small helper function for managing BEM classes.

Install

npm install --save @maxwellmri/bem

Usage

bem can be used 3 ways.

  1. With an array

    const b = bem("Block");
    b(["&__component"]) // returns Block__component
    ub(["&__component", "&--modified"]) // returns Block__component Block--modifier
    
  2. With an string

    const b = bem("Block");
    b("&__component") // returns Block__component
    
  3. With an object (for conditional classes)

    const b = bem("Block");
    b({ "&__component": true, "&--disabled": false }) // returns Block__component
    b({ "&__component": true, "&--disabled": true }) // returns Block__component Block--disabled
    
  4. With multiple arguments

    const b = bem("Block");
    b(["&", "&--disabled"], "random") // returns Block Block--disabled random
    b(["&", "&--disabled"], { "fizz": true, "buzz": false }) // returns Block Block--disabled fizz
    

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.