npm.io
1.0.0 • Published 11 years ago

classnameify

Licence
MIT
Version
1.0.0
Deps
2
Vulns
0
Weekly
0
Stars
2

classnameify

Build status NPM version js-xo-style

Generate classname selectors for CSS components, works splendid together with e.g. React

Why?

Generating classnames according to the contents of CSS declarations solves the biggest problem with large scale CSS, i.e. the fact that it cascades. See unistyle for how to use this in a scalable way.

Installation

Install classnameify using npm:

npm install --save classnameify

Usage

Module usage
var classnameify = require('classnameify');

classnameify({
  myComponent: {
    color: '#FFF',
    fontSize: '10px'
  }
});
/*
 {
  '._e80a8a8': {
    color: '#FFF',
    fontSize: '10px'
  }
 }
*/
Usage together with e.g. React

Have a look at unistyle for how this fits together with React.

API

classnameify(val)
Name Type Description
val `Object Array`

Returns: Object.

License

MIT Joakim Carlstein

Keywords