From fac6fb4da570098cffc03f868621bcf6e1c4a307 Mon Sep 17 00:00:00 2001 From: reverend Date: Fri, 15 Jan 2021 01:28:34 +0100 Subject: [PATCH] ..,- --- components/00_Global/_mebgenerator.styl | 233 +++++++++--------------- 1 file changed, 91 insertions(+), 142 deletions(-) diff --git a/components/00_Global/_mebgenerator.styl b/components/00_Global/_mebgenerator.styl index 184693b..212b1b4 100644 --- a/components/00_Global/_mebgenerator.styl +++ b/components/00_Global/_mebgenerator.styl @@ -1,186 +1,135 @@ -_state = { +_block = { stack: {} + elements: {} + block_modifiers: {} - element_aliases: {} - element_modifier_aliases: {} - block_modifier_aliases: {} - - element_alias_stack: () () - element_modifier_alias_stack: () () - block_modifier_alias_stack: () () + element_stack: () () + element_modifier_stack: () () + block_modifier_stack: () () + + current_elements: () () + current_element_modifiers: () () + current_block_modifiers: () () } -reset_state() - _state.stack = {} +reset_block() + _block.stack = {} + _block.elements = {} + _block.block_modifiers = {} - _state.element_aliases = {} - _state.element_modifier_aliases = {} - _state.block_modifier_aliases ={} - - _state.element_alias_stack = () () - _state.element_modifier_alias_stack = () () - _state.block_modifier_alias_stack = () () + _block.element_stack = {} + _block.element_modifier_stack = {} + _block.block_modifier_stack = {} -push_level(level) - push(_state.stack, level) - -set_element_alias(name, alias) - _state.element_aliases[name] = alias - -get_element_alias(name) - if name in _state.element_aliases - return _state.element_aliases[name] - else - return name + _block.current_elements = () () + _block.current_element_modifiers = () () + _block.current_block_modifiers = () () -set_element_modifier_alias(name, alias) - _state.element_modifier_aliases[name] = alias - -get_element_modifier_alias(name) - if name in _state.element_modifier_aliases - return _state.element_modifier_aliases[name] - else - return name +_include = { + elements: {} + element_modifires: {} + block_modifiers: {} + + element_stack: {} + element_modifier_stack: {} + block_modifier_stack: {} + + + +} +reset_include() + _aliases.element_aliases = {} + _aliases.element_modifires_aliases = {} + _aliases.block_modifiers_aliases = {} + + _aliases.element_alias_stack = {} + _aliases.element_modifires_alias_stack = {} + _aliases.block_modifiers_alias_stack = {} -set_block_modifier_alias(name, alias) - _state.block_modifier_aliases[name] = alias - -get_block_modifier_alias(name) - if name in _state.block_modifier_aliases - return _state.block_modifier_aliases[name] - else - return name +_block_map = {} + +RV-Include(block_name, alias = null) + RV-Squash() {block} RV-Block(block_name) - - push(_block_name_stack, block_name) - - last_element_selector = null - last_element_name = null - last_bock_modifier_selector = null - last_bock_modifier_name = null - - selector_list = () () - - .{block_name} - - {block} + {block} - for level in _state.stack + push(_block.elements, _block.current_elements) + push(_block.block_modifiers, _block.current_block_modifiers) - if level.type == 'RV-Block__Modifier' - last_bock_modifier_name = block_name + '--' + level.name - last_bock_modifier_selector = '.' + block_name + '.' + last_bock_modifier_name - - push(selector_list, { - selector: last_bock_modifier_selector - block_list: level.block_list - }) - - else - if level.type == 'RV-Element' - name = get_element_alias(level.name) - last_element_name = block_name + '__' + name - element_selector = '.' + last_element_name - - if last_bock_modifier_selector != null - element_selector = last_bock_modifier_selector + ' ' + element_selector - - last_element_selector = element_selector - push(selector_list, { - selector: last_element_selector - block_list: level.block_list - }) - - else - if level.type == 'RV-Element__Modifier' - if last_element_selector != null && last_element_name != null - modifier_selector = '.' + last_element_name + '--' + level.name - - push(selector_list, { - selector: last_element_selector + modifier_selector - block_list: level.block_list - }) - - reset_state() - - .{block_name} - for item in selector_list - if item != () - & {item.selector} - for block in item.block_list - {block} + _block_map[block_name] = _block + + reset_block() RV-Element(element_name) + if 'RV-Include' in called-from + if 'RV-Element' in called-from + push(_include.element_stack, element_name) + else + for alias in _include.element_stack + _include.elements[alias] = element_name + _include.elements[element_name] = element_name + if 'RV-Element' in called-from - if lookup('block') != null - push(_state.element_alias_stack, { - name: element_name, - block: block - }) - else + push(_state.element_stack, block) + else + element = { + type: 'RV-Element' + name: element_name + blocks: (block) + modifiers: _block.current_element_modifiers + } + _block.current_element_modifiers = () () + for child in _block.element_stack + if child != () + push(element.blocks, child) + _block.element_stack = () () - for alias in _state.element_alias_stack - set_element_alias(alias.name, element_name) - push(element.block_list, alias.block) - _state.element_alias_stack = () () - - push_level(element) + if 'RV-Block__Modifier' in called-from + push(_block.current_elements, element) + else + _block.elements[elemante_name] = element RV-Element__Modifier(modifier_name) if 'RV-Element__Modifier' in called-from - if lookup('block') != null - push(_state.element_modifier_alias_stack, { - name: modifier_name, - block: block - }) + push(_state.element_modifier_stack, block) else modifier = { type: 'RV-Element__Modifier' name: modifier_name - block_list: () + blocks: (block) } - if lookup('block') != null - push(modifier.block_list, block) - - for alias in _state.element_modifier_alias_stack - if alias != () - set_element_modifier_alias(alias.name, modifier_name) - push(modifier.block_list, alias.block) - _state.element_modifier_alias_stack = () () + for child in _block.element_modifier_stack + if child != () + push(modifier.blocks, child) + _block.element_modifier_stack = () () - push_level(modifier) + push(_block.current_element_modifiers, modifier) RV-Block__Modifier(modifier_name) if 'RV-Block__Modifier' in called-from - if lookup('block') != null - push(_state.block_modifier_alias_stack, { - name: modifier_name, - block: block - }) + push(_block.block_modifier_stack, block) else modifier = { type: 'RV-Block__Modifier' name: modifier_name - block_list: () + blocks: (block) + elements: _block.current_elements } + _block.current_elements = () () - if lookup('block') != null - push(modifier.block_list, block) - - for alias in _state.block_modifier_alias_stack - if alias != () - set_block_modifier_alias(alias.name, modifier_name) - push(modifier.block_list, alias.block) - _state.block_modifier_alias_stack = () () + for child in _block.block_modifier_stack + if child != () + push(modifier.blocks, child) + _block.block_modifier_stack = () () - push_level(modifier) + _block.block_modifiers[modifier_name] = modifier