0.1.1 • Published 5 years ago

yu-bem v0.1.1

Weekly downloads
64
License
MIT
Repository
-
Last release
5 years ago

yu-bem

Create className with BEM structure in JS. Understand more about BEM from https://css-tricks.com/bem-101/

Getting started

npm install yu-bem
or 
yarn add yu-bem

Usage

Function bem consists of the follow arguments

argumentstype
blockstring
elementstring
modifierstring
customPrefixstring
import bem from 'yu-bem'

const btn = bem('btn'); // returns 'btn'
const btnIcon = bem('btn', 'icon'); // returns 'btn__icon'
const btnDisabled = bem('btn', null, 'disabled'); // returns 'btn--disabled'
const btnIconSuffix = bem('btn', 'icon', 'suffix'); // returns 'btn__icon--suffix'

To append a class prefix to the className, call the initPrefix function at the start

bem.initPrefix('mylib')
const btn = bem('btn'); // returns 'mylib-btn'

or provide the customPrefix which will override the init prefix

const btnIconSuffix = bem('btn', null, null, 'mylib2'); // returns 'mylib2-btn'
const btnIconSuffix = bem('btn', 'icon', null, 'mylib2'); // returns 'mylib2-btn__icon'
0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago