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,7 +43,16 @@ _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
|
||||||
* according to BEM.
|
* according to BEM.
|
||||||
@ -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
|
||||||
|
//by an earlier call of RV-Element
|
||||||
|
if not 'RV-Element' in called-from
|
||||||
|
// Saving accumulated modifiers and blocks
|
||||||
|
element = {}
|
||||||
|
element['block_list'] = _global_scope['_element_block_stack']
|
||||||
|
element['modifier_list'] = _global_scope['_element_modifier_stack']
|
||||||
|
|
||||||
//Detect if the selector will be generated
|
//Reseting
|
||||||
//by an earlier call of RV-Element
|
_global_scope['_element_block_stack'] = ()
|
||||||
if 'RV-Element' in called-from
|
_global_scope['_element_modifier_stack'] = {}
|
||||||
_create_element(name, block)
|
|
||||||
else
|
//Saving element
|
||||||
{block-selector}__{name}
|
_global_scope['_selector_blocks_to_generate'][name] = element
|
||||||
_create_element(name, block)
|
_global_scope['_last_element_name'] = name
|
||||||
else
|
|
||||||
warn('No block found. Creating One instead')
|
|
||||||
+RV-Block(name)
|
|
||||||
{block}
|
|
||||||
/*
|
/*
|
||||||
* 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'
|
||||||
else
|
counter += 1
|
||||||
callback = @(element, name, block_list){
|
|
||||||
&{_get_block_selector()}__{element}--{name}{
|
|
||||||
for current_block in block_list{
|
|
||||||
|
|
||||||
{current_block}
|
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
|
||||||
block_list = ()
|
|
||||||
push(block_list, @block{block})
|
//Is this modifier beeing included by another modifier
|
||||||
l = length(_additional-element-modifier-blocks)
|
if not 'RV-Element__Modifier' in called-from
|
||||||
for i in range(0, l)
|
//No
|
||||||
b = pop(_additional-element-modifier-blocks)
|
//Is this modifier beeing called in in- or postfix
|
||||||
push(block_list, b)
|
if not 'RV-Element' in called-from
|
||||||
|
//Yes
|
||||||
push(_element-modifier, {
|
last_element_name = _global_scope['_last_element_name']
|
||||||
callback: callback
|
|
||||||
name: name
|
//Accesing the last generated element and appending the modifier
|
||||||
block_list: block_list,
|
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
|
||||||
|
//No
|
||||||
|
_global_scope['_element_modifier_stack'][name] = _global_scope['_element_modifier_block_stack']
|
||||||
|
|
||||||
|
_global_scope['_element_modifier_block_stack'] = ()
|
||||||
|
else
|
||||||
|
p('wurstwasser')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user