Skip to content

Commit

Permalink
docs: description for create method
Browse files Browse the repository at this point in the history
  • Loading branch information
qfox committed Jan 26, 2017
1 parent 55f1cdb commit 907ae01
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Expand Up @@ -58,6 +58,7 @@ API
* [valueOf()](#valueof)
* [toJSON()](#tojson)
* [isBemCell(cell)](#isbemcellcell)
* [create(object)](#createobject)

### constructor(obj)

Expand Down Expand Up @@ -191,6 +192,39 @@ BemCell.isBemCell(cell); // true
BemCell.isBemCell({}); // false
```

### #create(object)

Creates BemCell instance by the any object representation.

Helper for laziness.

Parameter | Type | Description
-------------|----------|--------------------------
`object` | `object` | Representation of entity name.

Passed Object can have fields for BemEntityName and cell itself:

Object field | Type | Description
-------------|----------|------------------------------
`block` | `string` | The block name of entity.
`elem` | `string` | The element name of entity.
`mod` | `string`, `object` | The modifier of entity.<br><br> If specified value is `string` then it will be equivalent to `{ name: string, val: true }`.
`val` | `string` | The modifier value of entity.
`mod.name` | `string` | The modifier name of entity.
`mod.val` | `*` | The modifier value of entity.
`modName` | `string` | The modifier name of entity.
`modVal` | `*` | The modifier value of entity.
`tech` | `string` | Technology of cell.
`layer` | `string` | Layer of cell.

```js
const BemCell = require('@bem/cell');

BemCell.create({ block: 'my-button', mod: 'theme', val: 'red', tech: 'css', layer: 'common' });
BemCell.create({ block: 'my-button', modName: 'theme', modVal: 'red', tech: 'css', layer: 'common' });
// BemCell { entity: { block: 'my-button', mod: { name: 'theme', val: 'red' } }, tech: 'css', layer: 'common' }
```

Debuggability
-------------

Expand Down

0 comments on commit 907ae01

Please sign in to comment.