A simple BEM helper using ReasonMl
reBEM Helper
npm install rebem-helper
or
yarn add rebem-helper
rebem-helper
to "bs-dependencies" section of bsconfig.jsonopen ReBemHelper;
/* Write my-block my-block--active */
let isActive = true;
let myBemClassNames = bem(~block="my-block", ~modifiers=[Boolean("active", isActive)], ());
open ReBemHelper
let isActive = true
let myBemClassNames =
bem ~block:"my-block"
~modifiers:[((Boolean ("active", isActive))[@explicit_arity ])] ()
open ReBemHelper;
/* Write class names: my-block my-block--small */
let mySizeBemClassNames = bem(~block="my-block", ~modifiers=[String("small")], ());
open ReBemHelper
let mySizeBemClassNames =
bem ~block:"my-block" ~modifiers:[((String ("small"))[@explicit_arity ])]
()
open ReBemHelper;
/* Write class names: my-block my-block--active my-block--small my-block--disable */
let mySizeBemClassNames = bem(
~block="my-block",
~modifiers=[
String("small"),
Boolean("active", isActive),
Switch("enable", "disable", false)
],
()
);
open ReBemHelper
let mySizeBemClassNames =
bem ~block:"my-block"
~modifiers:[((String ("small"))[@explicit_arity ]);
((Boolean ("active", isActive))[@explicit_arity ]);
((Switch ("enable", "disable", false))[@explicit_arity ])] ()
open ReBemHelper;
/* Write class names: my-block__element my-block__element--small some-other-class */
let mySizeBemClassNames = bem(~block="my-block", ~element="element", ~modifiers=[String("small")], ~others="some-other-class", ());
open ReBemHelper
let mySizeBemClassNames =
bem ~block:"my-block" ~element:"element"
~modifiers:[((String ("small"))[@explicit_arity ])]
~others:"some-other-class" ()
String(modifierName)
String(string)Boolean(modifierName, shouldShowModifierName)
Boolean(string, bool)Switch(activeModifierName, unactiveModifierName, isActiveModifierName)
Switch(string, string, bool)See more examples in examples folder:
Install and code.
yarn install
yarn start
Run tests
yarn test
Run tests (on watch)
yarn test:dev
Please feel free to write an issue/PR if you see/want somethings.