# create-classname

> Create className based on an object's conditions

Latest version **1.0.15** (published 2017-09-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install create-classname
pnpm add create-classname
yarn add create-classname
bun add create-classname
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.15 |
| Published | 2017-09-21 |
| First published | 2017-09-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Hiléo Andercsson |
| Maintainers | hileomsi |
| Keywords | React, Props, ClassName |

## Links

- npm: https://www.npmjs.com/package/create-classname
- Repository: https://github.com/hileomsi/create-classname
- Homepage: https://github.com/hileomsi/create-classname#readme
- Issues: https://github.com/hileomsi/create-classname/issues
- npm.io page: https://npm.io/package/create-classname

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.15 (latest) — 2017-09-21
- 1.0.14 — 2017-09-21
- 1.0.13 — 2017-09-21
- 1.0.12 — 2017-09-20
- 1.0.11 — 2017-09-20
- 1.0.10 — 2017-09-20
- 1.0.9 — 2017-09-16
- 1.0.8 — 2017-09-16
- 1.0.7 — 2017-09-15
- 1.0.6 — 2017-09-15
- 1.0.5 — 2017-09-15
- 1.0.4 — 2017-09-15
- 1.0.3 — 2017-09-15
- 1.0.2 — 2017-09-15
- 1.0.1 — 2017-09-14
- … 1 more at https://npm.io/package/create-classname/versions

## README

# createClassName 
🎈 - Create className based on an object's conditions. 

[![NPM version](https://badge.fury.io/js/create-classname.png)](http://badge.fury.io/js/create-classname)

[![Npm Downloads](https://nodei.co/npm/create-classname.png?downloads=true&stars=true)](https://nodei.co/npm/create-classname.png?downloads=true&stars=true)

### Installation

Install the dependencies.

```sh
$ npm i --save create-classname
ou
$ yarn add create-classname
```

### Definition

```js
    createClassName(defaultClassName, data | props, mapping);
```

- defaultClassName: *string*
- data | props: *object*
- mapping: *array*
    -  verifier: *string* | *function*
    -  className: *string* | *function*

### Example

```js
//App.jsx
	ReactDOM.render(
		<MyButton 
			active
			color='blue'
			icon={<Icon name="facebook"/>}
			outline
			raised={false}
		>
			Click Me!
		</MyButton>,
		document.getElementById('root')
	);
```

```js
//MyButton.jsx
import { createClassName } from 'create-classname';

export default class MyButton extends Component {
	constructor(props) {
		super();
		
		const mapping = [
			{ verifier: 'active', className: 'active' },
			{ verifier: 'color' , className: (p) => `color-${p.color}` },
			{ verifier: (p) =>  p.icon && p.outline, className: 'button-icon-outline' },
			{ verifier: (p) => p.raised, className: 'button-raised' },
			{ verifier: 'round', className: 'button-round' }
		];
		
		const className = createClassName('button', props, mapping);
		//className => "button active color-blue button-icon-outline"

		this.state = { className: className };
	}
	
	render() {
		return (<button className={this.state.className}></button>)
	}
}
```

License
----
ISC

---
_Source: https://npm.io/package/create-classname · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
