Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

@bem/sdk.decl Usage examples: Select all checkboxes

node v10.24.1
version: 1.0.0
endpointsharetweet
const bemDecl = require('@bem/sdk.decl'); const bemCell = require('@bem/sdk.cell'); // Set state modifier for the entity function select(entity) { const selectedState = { entity: { mod: { name: 'state', val: 'checked'}} }; return bemDecl.assign(selectedState, entity); }; // Set state modifier for the array of entities function selectAll(entities) { return entities.map(e => select(e)); }; // Define BEM cells that represents checkbox entities. const checkboxes = [ bemCell.create({ block: 'checkbox', elem: '1', mod: { name: 'state', val: 'unchecked'}}), bemCell.create({ block: 'checkbox', elem: '2', mod: { name: 'state', val: 'checked'}}), bemCell.create({ block: 'checkbox', elem: '3', mod: { name: 'state'}}), bemCell.create({ block: 'checkbox', elem: '4'}), ]; // Select all checkboxes. selectAll(checkboxes).map(e => e.valueOf());
Loading…

no comments

    sign in to comment