graph: Create a Header dependencies list

node v10.16.3
version: 2.0.2
endpointsharetweet
const { BemGraph } = require('@bem/sdk.graph'); const BemCell = require('@bem/sdk.cell'); const graph = new BemGraph(); graph.vertex({ block: 'head' }) .dependsOn({ block: 'menu' }) .dependsOn({ block: 'logo' }) .dependsOn({ block: 'search' }) .dependsOn({ block: 'auth' }); graph.vertex({ block: 'search' }) .dependsOn({ block: 'input', mod: 'search-input' }) .dependsOn({ block: 'button', mod: 'search-button' }); graph.vertex({ block: 'menu' }) .dependsOn({ block: 'tab', elem: 'tab1' }) .dependsOn({ block: 'tab', elem: 'tab2' }) .dependsOn({ block: 'tab', elem: 'tab3' }) .dependsOn({ block: 'tab', elem: 'tab4' }); graph.vertex({ block: 'auth' }) .dependsOn({ block: 'input', elem: 'login' }) .dependsOn({ block: 'input', elem: 'password' }) .dependsOn({ block: 'button', mod: 'sign-in' }); // Register remaining vertices to naturalize the graph. graph.vertex({ block: 'input' }); graph.vertex({ block: 'button' }); graph.vertex({ block: 'tab' }); graph.naturalize(); graph.dependenciesOf({ block: 'head' }).map(c => BemCell.create(c).id).join('\n');
Loading…

no comments

    sign in to comment