as i discovered, this is pretty much worthless, good night ladies and germs
This commit is contained in:
parent
4991dd276b
commit
cb6f67676e
@ -6,8 +6,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
_css-prefix = 'RV'
|
_css-prefix = 'RV'
|
||||||
_element-modifier = ()
|
_global_scope = {
|
||||||
_additional-element-modifier-blocks = ()
|
_selector_blocks_to_generate: {}
|
||||||
|
_element-modifier: ()
|
||||||
|
_additional-element-modifier-blocks: ()
|
||||||
|
_last_element_name: null
|
||||||
|
_blocks_to_generate: ()
|
||||||
|
_element_modifier_block_stack: ()
|
||||||
|
_element_block_stack: ()
|
||||||
|
_element_modifier_stack: {}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets the selector of the parent class
|
* Gets the selector of the parent class
|
||||||
@ -15,17 +23,19 @@ _additional-element-modifier-blocks = ()
|
|||||||
_get_parent_selector()
|
_get_parent_selector()
|
||||||
return split(' ', selector())[-1]
|
return split(' ', selector())[-1]
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets the selector of the current block
|
* Gets the selector of the current block
|
||||||
*/
|
*/
|
||||||
_get_block_selector()
|
_get_block_selector()
|
||||||
return unquote(split('__', _get_parent_selector())[0])
|
return unquote(split('__', _get_parent_selector())[0])
|
||||||
|
|
||||||
|
|
||||||
_get_element_selector()
|
_get_element_selector()
|
||||||
p(_get_parent_selector())
|
|
||||||
element--modifier = split('__', _get_parent_selector())[1]
|
element--modifier = split('__', _get_parent_selector())[1]
|
||||||
return unquote(split('--', element--modifier)[0])
|
return unquote(split('--', element--modifier)[0])
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generates a CSS class for an
|
* Generates a CSS class for an
|
||||||
* Block according to BEM
|
* Block according to BEM
|
||||||
@ -33,6 +43,15 @@ _get_element_selector()
|
|||||||
RV-Block(name)
|
RV-Block(name)
|
||||||
.{_css-prefix}-{name}
|
.{_css-prefix}-{name}
|
||||||
{block}
|
{block}
|
||||||
|
for name, element in _global_scope['_selector_blocks_to_generate']
|
||||||
|
& &__{name}
|
||||||
|
for current_block in element.block_list
|
||||||
|
{current_block}
|
||||||
|
for modifier_name, modifier_block_list in element.modifier_list
|
||||||
|
&--{modifier_name}
|
||||||
|
for current_block in modifier_block_list
|
||||||
|
{current_block}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generates a CSS class for an block modifier
|
* Generates a CSS class for an block modifier
|
||||||
@ -45,44 +64,32 @@ RV-Block__Modifier(name)
|
|||||||
&{_get_block_selector()}--{name}
|
&{_get_block_selector()}--{name}
|
||||||
{block}
|
{block}
|
||||||
|
|
||||||
_create_element(name, block)
|
|
||||||
{block}
|
|
||||||
// Checking for modifiers
|
|
||||||
l = length(_element-modifier) - 1
|
|
||||||
for i in range(0, l)
|
|
||||||
modifier = pop(_element-modifier)
|
|
||||||
callback = modifier['callback']
|
|
||||||
// Calling the modifiers block,
|
|
||||||
// passing the name of the element
|
|
||||||
callback(
|
|
||||||
element: name,
|
|
||||||
name: modifier['name'],
|
|
||||||
block_list: modifier['block_list']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generates an CSS class for an element
|
* Generates an CSS class for an element
|
||||||
* according to BEM. Also minds the element modifiers
|
* according to BEM. Also minds the element modifiers
|
||||||
* For more see RV-Element___Modifier
|
* For more see RV-Element___Modifier
|
||||||
*/
|
*/
|
||||||
RV-Element(name)
|
RV-Element(name)
|
||||||
block-selector = _get_block_selector()
|
element_block_stack = _global_scope['_element_block_stack']
|
||||||
// Are we in a block?
|
append(element_block_stack, block)
|
||||||
if block-selector != '&'
|
_global_scope['_element_block_stack'] = element_block_stack
|
||||||
//Create Selector and output the CSS for the element
|
|
||||||
|
|
||||||
//Detect if the selector will be generated
|
//Detect if the selector will be generated
|
||||||
//by an earlier call of RV-Element
|
//by an earlier call of RV-Element
|
||||||
if 'RV-Element' in called-from
|
if not 'RV-Element' in called-from
|
||||||
_create_element(name, block)
|
// Saving accumulated modifiers and blocks
|
||||||
else
|
element = {}
|
||||||
{block-selector}__{name}
|
element['block_list'] = _global_scope['_element_block_stack']
|
||||||
_create_element(name, block)
|
element['modifier_list'] = _global_scope['_element_modifier_stack']
|
||||||
else
|
|
||||||
warn('No block found. Creating One instead')
|
//Reseting
|
||||||
+RV-Block(name)
|
_global_scope['_element_block_stack'] = ()
|
||||||
{block}
|
_global_scope['_element_modifier_stack'] = {}
|
||||||
|
|
||||||
|
//Saving element
|
||||||
|
_global_scope['_selector_blocks_to_generate'][name] = element
|
||||||
|
_global_scope['_last_element_name'] = name
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generates a CSS class for an element modifier
|
* Generates a CSS class for an element modifier
|
||||||
* according to BEM. These are ment to be part of the
|
* according to BEM. These are ment to be part of the
|
||||||
@ -93,27 +100,36 @@ RV-Element(name)
|
|||||||
* from RV-Element
|
* from RV-Element
|
||||||
*/
|
*/
|
||||||
RV-Element__Modifier(name)
|
RV-Element__Modifier(name)
|
||||||
if 'RV-Element__Modifier' in called-from
|
counter = 0
|
||||||
//What the actual fuch this language is to utterly buggy
|
for fn in called-from
|
||||||
push(_additional-element-modifier-blocks, @block{block})
|
if fn is 'RV-Element'
|
||||||
|
counter += 1
|
||||||
|
|
||||||
|
if counter <= 1
|
||||||
|
element_modifier_block_stack = _global_scope['_element_modifier_block_stack']
|
||||||
|
append(element_modifier_block_stack, block)
|
||||||
|
_global_scope['_element_modifier_block_stack'] = element_modifier_block_stack
|
||||||
|
|
||||||
|
//Is this modifier beeing included by another modifier
|
||||||
|
if not 'RV-Element__Modifier' in called-from
|
||||||
|
//No
|
||||||
|
//Is this modifier beeing called in in- or postfix
|
||||||
|
if not 'RV-Element' in called-from
|
||||||
|
//Yes
|
||||||
|
last_element_name = _global_scope['_last_element_name']
|
||||||
|
|
||||||
|
//Accesing the last generated element and appending the modifier
|
||||||
|
element = _global_scope['_selector_blocks_to_generate'][last_element_name]
|
||||||
|
modifier_list = element['modifier_list']
|
||||||
|
modifier_list[name] = _global_scope['_element_modifier_block_stack']
|
||||||
|
element['modifier_list'] = modifier_list
|
||||||
|
|
||||||
|
_global_scope['_selector_blocks_to_generate'][last_element_name] = element
|
||||||
else
|
else
|
||||||
callback = @(element, name, block_list){
|
//No
|
||||||
&{_get_block_selector()}__{element}--{name}{
|
_global_scope['_element_modifier_stack'][name] = _global_scope['_element_modifier_block_stack']
|
||||||
for current_block in block_list{
|
|
||||||
|
|
||||||
{current_block}
|
_global_scope['_element_modifier_block_stack'] = ()
|
||||||
}
|
else
|
||||||
}
|
p('wurstwasser')
|
||||||
}
|
|
||||||
block_list = ()
|
|
||||||
push(block_list, @block{block})
|
|
||||||
l = length(_additional-element-modifier-blocks)
|
|
||||||
for i in range(0, l)
|
|
||||||
b = pop(_additional-element-modifier-blocks)
|
|
||||||
push(block_list, b)
|
|
||||||
|
|
||||||
push(_element-modifier, {
|
|
||||||
callback: callback
|
|
||||||
name: name
|
|
||||||
block_list: block_list,
|
|
||||||
})
|
|
||||||
|
Loading…
Reference in New Issue
Block a user