0.0.29 • Published 4 years ago

util.classnames v0.0.29

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

util.classnames

A class to manage CSS classes in a react component

build analysis code style: prettier testing NPM

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

import {ClassNames} from 'util.classnames';

const clsn = new ClassNames(['a', 'b', 'c']);

// clsn.classnames => 'a b c'

clsn.add('d');

// clsn.classnames => 'a b c d'

clsn.remove('a');

// clsn.classnames => 'b c d'

clsn.off('b');

// clsn.classnames => 'c d'

clsn.on('b');

// clsn.classnames => 'b c d'

clsn.toggle('b');

// clsn.classnames => 'c d'

clsn.toggle('b');

// clsn.classnames => 'b c d'

Initialize with a string

import {ClassNames} from 'util.classnames';

const clsn = new ClassNames('a');

// clsn.classnames => 'a'

Initialize with an object

import {ClassNames} from 'util.classnames';

const clsn = new ClassNames({a: true, b: true, c: false});

// clsn.classnames => 'a b c'

API

attributes

methods

0.0.29

4 years ago

0.0.28

5 years ago

0.0.27

5 years ago

0.0.26

5 years ago

0.0.25

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago