BEM Generator shorthand for block modifiers

This commit is contained in:
2021-03-10 02:58:14 +01:00
parent 05b23653c7
commit d6b4f0aff2
12 changed files with 33 additions and 20 deletions

View File

@@ -102,11 +102,13 @@ RV-Level(name, name_delimiter, allowed_parent_levels, selector_callback, squash_
if squash_if_parent_nested && is_any_parent_nested()
{block}
else
{selector_callback(name)}
selector_name = selector_callback(name)
if name == ''
selector_name = split(name_delimiter, selector_name)[0]
{selector_name}
{block}
RV-Block(name)
.{name}
{block}
@@ -114,6 +116,10 @@ RV-Block(name)
_bem_context._alias_map = {}
_bem_context._alias_stacks = {}
RV-Block--shorthand(name)
+RV-Block(name)
{block}
RV-Element(name=null)
+RV-Level(name, '__', ('RV-Block' 'RV-Block--modifier'), @(name){
if is_nested_in('RV-Block--modifier') {
@@ -131,7 +137,11 @@ RV-Element--modifier(name=null)
{block}
RV-Block--modifier(name=null)
+RV-Level(name, '--', ('RV-Block'), @(name){return '&--' + name}, true)
+RV-Level(name, '--', ('RV-Block' 'RV-Block--shorthand'), @(name){return '&--' + name}, true)
if is_nested_in('RV-Block--shorthand') && length(called-from) > 0
mixin_name = split('--', called-from[0])[0]
p(mixin_name)
convert(unquote(mixin_name)+'()')
{block}
RV-Squash()