tree-class

1.0.3 • Public • Published

tree-class

A simple JavaScript utility for conditionally treeing class names together.

Examples:

> treeClass('input');
'input'
> treeClass(0);
'0'
> treeClass({ input: true });
'input'
> treeClass({ input: Date.now() % 2 ? 'small' : 'large' });
'input input-large'
> treeClass(['input'{ form: { ctrl: 'large' } }]);
'input form form-ctrl form-ctrl-large'
> const style = { type'normal', size: 'small', color: 'green' }
> treeClass('date-picker'{ [style.type]: { [style.size]: style.color } } })
'date-picker date-picker-normal date-picker-normal-small date-picker-normal-small-green'

Package Sidebar

Install

npm i tree-class

Weekly Downloads

3

Version

1.0.3

License

MIT

Unpacked Size

3.67 kB

Total Files

4

Last publish

Collaborators

  • ngolin