Extremely simple and small (~0.25Kb minified) ABEM class name generator. Developed for using with babel-plugin-transform-jsx-abem.
Note: This plugin doesn't apply any string transformation. camelCase should be applied earlier on.
npm install abem
const _abem = abem([options])
_abem(block[, element, modifiers, mixins])
arg | type |
---|---|
options | object (default: { separators: { element: '__', modifier: '-' } } ) |
block | string |
element | string | null |
modifiers | string | array | object | null |
mixins | string | array | object | null |
let _abem = abem()
_abem('o-animal', 'elephant')
// "o-animal__elephant"
_abem('o-animal', 'elephant', ['mod1', 'mod2'])
// "o-animal__elephant -mod1 -mod2"
_abem('o-animal', 'elephant', { mod1: true, mod2: false }, ['mix'])
// "o-animal__elephant -mod1 mix"
_abem('o-animal', null, null, { mix: true })
// "o-animal mix"
_abem = abem({ separators: { element: '___', modifier: '--' } })
_abem('o-animal', 'elephant', 'mod')
// "o-animal___elephant --mod"
You like this package?