Skip to content

Commit

Permalink
Merge e3f1375 into 9e4e115
Browse files Browse the repository at this point in the history
  • Loading branch information
qfox committed Dec 11, 2016
2 parents 9e4e115 + e3f1375 commit 6da7e46
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const cell = new BemCell({
cell.entity; // ➜ BemEntityName { block: 'button', elem: 'text' }
cell.tech; // css
cell.layer; // common
cell.id; // common/button__text.css
```

License
Expand Down
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,23 @@ module.exports = class BemCell {
* @returns {string} layer of cell.
*/
get layer() { return this._layer; }

/**
* Returns the identifier of this cell.
*
* @example
* const BemCell = require('@bem/cell');
* const BemEntityName = require('@bem/entity-name');
*
* const cell = new BemCell({
* entity: new BemEntityName({ block: 'button', elem: 'text' }),
* tech: 'css',
* layer: 'desktop'
* });
*
* cell.id; // ➜ "desktop/button__text.css"
*
* @returns {string} identifier of cell.
*/
get id() { return `${this._layer}/${this._entity}.${this._tech}`; }
};
10 changes: 10 additions & 0 deletions test/fields.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ test('should provide `layer` field', t => {

t.is(cell.layer, 'desktop');
});

test('should provide `id` field', t => {
const cell = new BemCell({
entity: new BemEntityName({ block: 'block' }),
layer: 'desktop',
tech: 'css'
});

t.is(cell.id, 'desktop/block.css');
});

0 comments on commit 6da7e46

Please sign in to comment.