1.0.3 • Published 6 years ago

tree-class v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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'