util.classnames
A class to manage CSS classes in a react component
Installation
This module uses yarn to manage dependencies and run scripts for development.
To install as an application dependency:
$ yarn add --dev util.classnames
To build the app and run all tests:
$ yarn run all
Overview
Provides an ES6 class for managing CSS class names strings used in a react component. Strings are added to an instance and later retrieved using the classnames
property. This property represents an concatenation of all active strings within the instance. The values within the class can be turned on and off to create different combinations. These strings can be used in the className
property of a component.
Usage
Initialize with an array of strings
; const clsn = 'a' 'b' 'c'; // clsn.classnames => 'a b c' clsn; // clsn.classnames => 'a b c d' clsn; // clsn.classnames => 'b c d' clsn; // clsn.classnames => 'c d' clsn; // clsn.classnames => 'b c d' clsn; // clsn.classnames => 'c d' clsn; // clsn.classnames => 'b c d'
Initialize with a string
; const clsn = 'a'; // clsn.classnames => 'a'
Initialize with an object
; const clsn = a: true b: true c: false; // clsn.classnames => 'a b c'