Skip to content

Instantly share code, notes, and snippets.

@qfox
Created February 6, 2018 16:10
Show Gist options
  • Save qfox/02bacc8c5d44b425f819228cdf0756d3 to your computer and use it in GitHub Desktop.
Save qfox/02bacc8c5d44b425f819228cdf0756d3 to your computer and use it in GitHub Desktop.
interface NestedWalker {
protected ctx: { path: string, cell: BemEntityName };
protected naming: BemNamingEntity;
public isLeaf(path): boolean;
public isDir(path): boolean; ← should we go deeper?
};
/*
/lib ← level, library
/lib/desktop.blocks
/lib/blocks
/lib/desktop.blocks/button
/lib/desktop.blocks/button/button.js
/lib/desktop.blocks/button/_size/ ← isPart: true, isLeaf: false
/lib/desktop.blocks/button/_size/button_size_l.js
@example1:
pattern: '${entity}/index@${layer}.${tech}',
scheme: 'flat'
/node_modules/@yandex-lego/button/index.js
/node_modules/@yandex-lego/popup/index.js
@example2:
pattern: '${layer}.blocks/${entity}.${tech}',
scheme: 'nested'
/desktop.blocks/button/_size/button_size_l.js
layer → desktop
entity → button/_size/button_size_l (nested)
TODO:
- унести логику про tech из схем наверх в сам walk
- в схему нестед добавить поддержу входа с depth > 1
- в walk разбирать pattern и по нему фильтровать
*/
walk(
['node_modules/@yandex-lego'],
{'node_modules/@yandex-lego': { pattern: '${entity}/index@${layer}.${tech}', scheme: 'flat' }}
)
walk(
['common.blocks', 'desktop.blocks'],
{'common.blocks': { layer: 'common', pattern: '${entity}.${tech}', scheme: 'nested' },
'desktop.blocks': { layer: 'desktop', pattern: '${entity}.${tech}', scheme: 'nested' }}
)
'${prefix}${entity}${postfix}'
walk(
['.'],
{'.': { pattern: '${layer}.blocks/${entity}.${tech}', scheme: 'nested' }}
)
walk(
[levels],
bemConfig
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment