1.0.0 • Published 9 years ago

classname-manipulator v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

classname-manipulator

A simple javascript utility for building classNames. It's like classnames utility, however it allows you to use bem-naming notation and css-modules.

Usage

This utility was designed to be used with React components and helps you to build classNames for the components in an easier way. It uses certain properties: className, childName, theme.

Plain example:

'use strict';

var cm = require('classname-manipulator');

var props = {
  className: 'button',
  theme: {action: true}
};

cm(props); // 'button button--action'

Using react and css-modules:

'use strict';

import cm from 'classname-manipulator';
import styles from './Button.css';

class Button {
  render() {
    var classes = cm(this.props, styles);
    return (
      <Button className={classes}>
        {this.props.children}
      </Button>
    );
  }
}