This commit is contained in:
reverend 2021-01-09 21:14:21 +01:00
parent d6c3cea86c
commit e37315f90f
5 changed files with 43 additions and 88 deletions

View File

@ -30,25 +30,8 @@ RV-Block(name)
* according to BEM. * according to BEM.
*/ */
RV-Block__Modifier(name) RV-Block__Modifier(name)
// Determining if we are inside a block or after a block attach('RV-Block', unquote('--' + name), block)
call_stack = _call_stack_till_first_block()
if 'RV-Block' in call_stack
// We are called inside a block
push(_block_modifier_block_stack, @block{block})
//Detect if the selector will be generated
//by an earlier call of RV-Element
if not 'RV-Block__Modifier' in call_stack
block_list = _pop_stack(_block_modifier_block_stack)
_block_modifier_building_lane[name] = {
block_list: block_list
}
else
// We are not called inside a block
// Is there a block to attach to
if _last_block_name != null
.{_last_block_name}--{name}
{block}
/* /*
* Generates an CSS class for an element * Generates an CSS class for an element
@ -57,6 +40,7 @@ RV-Block__Modifier(name)
*/ */
RV-Element(name) RV-Element(name)
attach('RV-Block', unquote('__' + name), block) attach('RV-Block', unquote('__' + name), block)
tow(name, block)
@ -70,36 +54,5 @@ RV-Element(name)
* from RV-Element * from RV-Element
*/ */
RV-Element__Modifier(name) RV-Element__Modifier(name)
counter = 0 attach('RV-Element', '--' + name, block)
for fn in called-from
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
//No
_global_scope['_element_modifier_stack'][name] = _global_scope['_element_modifier_block_stack']
_global_scope['_element_modifier_block_stack'] = ()
else
p('wurstwasser')

View File

@ -1,6 +1,7 @@
_lanes = {} _lanes = {}
_stacks = {} _stacks = {}
_last_name = {} _last_name = {}
_being_towed = {}
_reset_last_name(block_type=null) _reset_last_name(block_type=null)
if block_type == null if block_type == null
@ -103,14 +104,14 @@ _pop_lane(block_type=null)
return {} return {}
attach(parent_type, suffix, block) attach(parent_type, suffix, block)
_being_towed[_current_block_type()] = true
call_stack = _call_stack_till_first(parent_type) call_stack = _call_stack_till_first(parent_type)
if parent_type in call_stack if parent_type in call_stack
// We are called inside a block // We are called inside a block
_push_onto_stack(block) _push_onto_stack(block)
//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
_current_block = _current_block_type() if not _current_block_type() in (call_stack)
if not _curent_block in (call_stack)
block_list = _pop_stack() block_list = _pop_stack()
_put_into_lane(suffix, block_list, parent_type) _put_into_lane(suffix, block_list, parent_type)
else else
@ -118,21 +119,28 @@ attach(parent_type, suffix, block)
// Is there a block to attach to // Is there a block to attach to
_last_parent_name = _get_last_name(parent_type) _last_parent_name = _get_last_name(parent_type)
if _last_parent_name != null if _last_parent_name != null
& .{_last_parent_name}{suffix} &.{_last_parent_name}{suffix}
--attach 'blubb'
{block} {block}
tow(name, block, block_type=null) tow(name, block, block_type=null)
if block_type == null if block_type == null // Determining if we are inside a block or after a block
block_type = called-from[0] block_type = called-from[0]
.{name} if not block_type in _being_towed
prefix = '.'+name
{prefix}
{block} {block}
else
prefix = ''
{prefix}
if block_type in _lanes if block_type in _lanes
for suffix, block_list in _pop_lane(block_type) for suffix, block_list in _pop_lane(block_type)
& .{name}{suffix} p('name' name 'suffix' suffix)
for b in block_list & {name}{suffix}
{b} for current_block in block_list
{current_block}
_set_last_name(name, block_type) _set_last_name(name, block_type)

View File

@ -133,6 +133,9 @@ RV-Fan()
color black color black
--blubb wasser --blubb wasser
+RV-Element__Modifier('Wurst')
--wurst 'wurst'
+RV-Element('Affter') +RV-Element('Affter')
--hasi 'lein' --hasi 'lein'

View File

@ -318,32 +318,23 @@
bottom: 0; bottom: 0;
right: 0; right: 0;
} }
.Fan { .Fächer {
--base-height: 280px; --wurst: yeet;
--base-width: 320px;
display: flex;
} }
.Fan.Fan--fullWidth { .Fächer BLubb--Wurst {
flex-flow: row wrap; --wurst: 'wurst';
} }
.Fan.Fan--vertical { .Fächer Fächer__BLubb {
flex-direction: column; color: #000;
width: max-content; --blubb: wasser;
} }
.Fan.Fan--horizontal { .Fächer__Affter {
flex-direction: row; --attach: 'blubb';
--hasi: 'lein';
} }
.Fan.Fan--auto { .Fächer--Mafter {
flex-flow: row wrap; --attach: 'blubb';
} --blubb: 'bernd';
.wurst .Fächer {
display: flex;
}
.wurst .Fächer .wurst .Fächer__Base--wurst {
--wurst: wasser;
}
.wurst .wurst__Base--wurst {
--wurst: wasser;
} }
.RV-FlexGrid__Container { .RV-FlexGrid__Container {
display: grid; display: grid;