Playground

This commit is contained in:
reverend 2021-03-16 14:27:34 +01:00
parent 8275d2960d
commit 3b03410b3c
2 changed files with 108 additions and 5 deletions

View File

@ -87,7 +87,6 @@ is_any_parent_nested()
RV-Level(name_delimiter, allowed_parent_levels=null, selector_callback, squash_if_parent_nested=false)
name = auto_name(name_delimiter)
p(called-from)
not_in_parent = true
for parent_level in allowed_parent_levels
not_in_parent = not_in_parent && not_nested_in(parent_level)
@ -114,9 +113,6 @@ RV-Level(name_delimiter, allowed_parent_levels=null, selector_callback, squash_i
// RV-Fan--horizontal RV-Fan--horizontal __ Base -- wurst
// RV-BreakPoint__Item--outside RV-Fan--horizontal__Base RV-Fan--horizontal
RV-Block(name)
.{name}
{block}
@ -162,4 +158,84 @@ RV-Block--modifier()
{block}
RV-Squash()
{block}
{block}
filter(list, value)
filtered = ()
for element in list
if element != value
push(filtered, element)
return filtered
_level_types = {
'': 'block'
'__': 'element'
'--': 'modifier'
}
get_first_level_name(mixin_name)
shortest_split = null
for delimiter, level_type in _level_types
if length(delimiter) > 0
current_split = split(delimiter, mixin_name)[0]
if shortest_split == null || length(current_split) <= length(shortest_split)
shortest_split = current_split
return shortest_split
string_contains(smaller, greater)
if smaller == null || greater == null
return false
if length(smaller) > length(greater)
return false
p('%s'%smaller length('%s'%smaller))
for i in range(0, length(smaller))
if smaller[i] != greater[i]
return false
return true
is_contigious(call_stack)
for i in range(0, length(call_stack) - 1)
p(call_stack[i+1] call_stack[i])
p(string_contains(call_stack[i+1], call_stack[i]))
if !call_stack[i+1] in call_stack[i]
return false
return true
determine_level_type(mixin_name)
candidate = null
candidate_level = null
candidate_delimiter = null
// This is why humanity is doomed
mixin_name = split('äöü', mixin_name)[0]
for delimiter, level in _level_types
if length(delimiter) <= 0
splited_level = mixin_name
else
splited_level = split(delimiter, mixin_name)[-1]
if candidate == null || length(candidate) > length(splited_level)
candidate = splited_level
candidate_level = level
candidate_delimiter = delimiter
return unquote(candidate) candidate_level unquote(candidate_delimiter)
generate_selector(mixin_name)
block_name = get_first_level_name(mixin_name)
level_info = determine_level_type(mixin_name)
return '&%s%s' % (level_info[2] level_info[0])
RV-BEM()
call_stack = filter(called-from, 'RV-BEM')
p(cs call_stack)
if is_contigious(call_stack)
{generate_selector(called-from[0])}
{block}
p('###')

View File

@ -150,4 +150,31 @@ RV-Fan(base-height, base-width)
RV-Fan--auto(--base-height, --base-width)
RV-Fan--vertical(--base-height, --base-width)
RV-Fan--horizontal(--base-height, --base-width)
RV-Fan--horizontal__Surface()
+RV-BEM()
--peter bernd
RV-Fan--horizontal__Base--wurst()
+RV-BEM()
--fan wurst
RV-Fan--horizontal__Base()
+RV-BEM()
RV-Fan--horizontal__Base--wurst()
RV-Fan--horizontal__Surface()
--wurst wasser
RV-Fan--horizontal()
+RV-BEM()
RV-Fan--horizontal__Base()
--kaka pipi
RV-Fan()
+RV-BEM()
RV-Fan--horizontal()
--blubb bernd
RV-Fan()