ye
This commit is contained in:
@@ -17,6 +17,15 @@ _global_scope = {
|
||||
_element_modifier_stack: {}
|
||||
}
|
||||
|
||||
_block_building_lane = ()
|
||||
_element_building_lange = ()
|
||||
|
||||
_work_lane(lane, callback)
|
||||
l = length(lane)
|
||||
for _ in (0..l)
|
||||
piece = pop(lane)
|
||||
callback(piece)
|
||||
|
||||
/*
|
||||
* Gets the selector of the parent class
|
||||
*/
|
||||
@@ -41,8 +50,13 @@ _get_element_selector()
|
||||
* Block according to BEM
|
||||
*/
|
||||
RV-Block(name)
|
||||
.{_css-prefix}-{name}
|
||||
.{name}
|
||||
push(_block_building_lane, {
|
||||
elements: {}
|
||||
block_modifiers: {}
|
||||
})
|
||||
{block}
|
||||
|
||||
for name, element in _global_scope['_selector_blocks_to_generate']
|
||||
& &__{name}
|
||||
for current_block in element.block_list
|
||||
@@ -70,25 +84,30 @@ RV-Block__Modifier(name)
|
||||
* For more see RV-Element___Modifier
|
||||
*/
|
||||
RV-Element(name)
|
||||
element_block_stack = _global_scope['_element_block_stack']
|
||||
append(element_block_stack, block)
|
||||
_global_scope['_element_block_stack'] = element_block_stack
|
||||
// Is there a block to build
|
||||
block_index = (index(called-from, 'RV-Block'))
|
||||
p(called-from block_index slice(called-from, 0, block_index))
|
||||
|
||||
//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']
|
||||
if length(_block_building_lane) >= 1
|
||||
push(_block_building_lane, block)
|
||||
|
||||
//Reseting
|
||||
_global_scope['_element_block_stack'] = ()
|
||||
_global_scope['_element_modifier_stack'] = {}
|
||||
current_block = _block_building_lane[-1]
|
||||
|
||||
//Saving element
|
||||
_global_scope['_selector_blocks_to_generate'][name] = element
|
||||
_global_scope['_last_element_name'] = name
|
||||
//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']
|
||||
|
||||
//Reseting
|
||||
_global_scope['_element_block_stack'] = ()
|
||||
_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
|
||||
|
@@ -66,7 +66,10 @@ RV-Fan--fullWidth(base-height, base-width)
|
||||
+RV-Element('Surface')
|
||||
flex-grow 1
|
||||
|
||||
|
||||
RV-Fan__Base--wurst()
|
||||
+RV-Element__Modifier('wurst')
|
||||
--wurst wasser
|
||||
|
||||
/* ###############
|
||||
* Element Mixins
|
||||
* ############### */
|
||||
@@ -83,22 +86,13 @@ RV-Fan__Surface--fixedHeight(height)
|
||||
|
||||
RV-Fan__Surface--fixedWidth(width)
|
||||
+RV-Element__Modifier('fixedWidth')
|
||||
|
||||
max-width width
|
||||
|
||||
RV-Fan__Surface()
|
||||
+RV-Element('Surface')
|
||||
RV-ContentCrop()
|
||||
|
||||
RV-Fan__Surface--fixedWidth(width)
|
||||
RV-Fan__Surface--fixedHeight(height)
|
||||
|
||||
RV-Fan__Surface-Pack(width, height)
|
||||
RV-Fan__Surface()
|
||||
|
||||
+RV-Element('Surface')
|
||||
RV-Fan__Surface--fixedWidth(width)
|
||||
RV-Fan__Surface--fixedHeight(height)
|
||||
@block{
|
||||
RV-ContentCrop()
|
||||
}
|
||||
|
||||
/* ############
|
||||
* Block Mixin
|
||||
@@ -106,57 +100,35 @@ RV-Fan__Surface-Pack(width, height)
|
||||
RV-Fan()
|
||||
display flex
|
||||
|
||||
RV-Fan__()
|
||||
RV-Fan()
|
||||
RV-Fan__Base()
|
||||
RV-Fan__Surface()
|
||||
|
||||
RV-Fan--(base-height, base-width)
|
||||
RV-Fan()
|
||||
|
||||
RV-Fan--fullWidth(base-height, base-width)
|
||||
RV-Fan--vertical(base-height, base-width)
|
||||
RV-Fan--horizontal(base-height, base-width)
|
||||
RV-Fan--auto(base-height, base-width)
|
||||
|
||||
RV-Fan__Surface()
|
||||
|
||||
RV-Fan__Surface--()
|
||||
|
||||
RV-Fan__Base()
|
||||
|
||||
RV-Fan__Base--()
|
||||
|
||||
RV-Fan__--()
|
||||
|
||||
RV-Fan-Pack(base-height, base-width)
|
||||
RV-Fan()
|
||||
|
||||
RV-Fan__Surface-Pack(base-height, base-width)
|
||||
RV-Fan__Base(base-height, base-width)
|
||||
|
||||
|
||||
|
||||
/* #########
|
||||
* CSS-Class
|
||||
* ######### */
|
||||
.RV-Fan
|
||||
|
||||
+RV-Block('Fan')
|
||||
RV-CSSParameter({
|
||||
base-height: 280px,
|
||||
base-width: 320px
|
||||
})
|
||||
|
||||
RV-Fan-Pack(base-height, base-width)
|
||||
/*
|
||||
.tollecomponent
|
||||
RV-Fan()
|
||||
+RV-Element('Square')
|
||||
|
||||
RV-Fan__Surface()
|
||||
RV-Fan__Surface--fixedWidth(base-width)
|
||||
RV-Fan__Surface--fixedHeight(base-height)
|
||||
|
||||
RV-Fan__Base(base-height, base-width)
|
||||
|
||||
RV-Fan--fullWidth(base-height, base-width)
|
||||
RV-Fan--vertical(base-height, base-width)
|
||||
RV-Fan--horizontal(base-height, base-width)
|
||||
RV-Fan--auto(base-height, base-width)
|
||||
|
||||
|
||||
+RV-Block('wurst')
|
||||
+RV-Block('Fächer')
|
||||
RV-Fan()
|
||||
RV-Fan__Base(50px, 50px)
|
||||
|
||||
+RV-Element__Modifier('color')
|
||||
RV-Fan__Base--blue()
|
||||
+/
|
||||
|
||||
|
||||
|
||||
|
||||
RV-Fan__Base--wurst()
|
||||
|
||||
RV-Fan__Surface(50px, 50px)
|
||||
|
@@ -1,75 +1,11 @@
|
||||
_selector_maps = {}
|
||||
_catched = {}
|
||||
@css-class-prefix: RV
|
||||
|
||||
throw(id, callback)
|
||||
if id in _selector_maps
|
||||
hook = _selector_maps[id]
|
||||
else
|
||||
hook = {}
|
||||
|
||||
hook[selector()] = callback
|
||||
_selector_maps[id] = hook
|
||||
|
||||
catch(id, params)
|
||||
if selector() in _catched
|
||||
_catches = _catched[selector()]
|
||||
else
|
||||
_catches = {}
|
||||
|
||||
_catches[id] = params
|
||||
_catched[selector()] = _catches
|
||||
|
||||
_generate_hooks()
|
||||
for catched_selector, config in _catched
|
||||
for id, parameter in config
|
||||
if id in _selector_maps
|
||||
hook = _selector_maps[id]
|
||||
for thrown_selector, callback in hook
|
||||
{thrown_selector}{catched_selector}
|
||||
callback(parameter)
|
||||
|
||||
|
||||
red()
|
||||
color red
|
||||
catch('button', green)
|
||||
catch('field', red)
|
||||
|
||||
field()
|
||||
display inline
|
||||
padding 10px
|
||||
border-bottom 2px solid blue
|
||||
throw('field', @(){
|
||||
border-bottom 2px solid red
|
||||
color blue
|
||||
})
|
||||
|
||||
button()
|
||||
padding 5px
|
||||
background-color orange
|
||||
border 1px solid black
|
||||
display inline
|
||||
throw('button', @(c){color c})
|
||||
|
||||
.bluebutton
|
||||
red()
|
||||
button()
|
||||
|
||||
.button
|
||||
button()
|
||||
|
||||
.wred
|
||||
red()
|
||||
|
||||
.field
|
||||
field()
|
||||
|
||||
.wurst
|
||||
.field
|
||||
field()
|
||||
red()
|
||||
|
||||
.debug
|
||||
--one _selector_maps
|
||||
--two _catched
|
||||
|
||||
_generate_hooks()
|
||||
RV-Utils__Block(name, callback)
|
||||
@name; name
|
||||
@a-@name()
|
||||
callback()
|
||||
|
||||
RV-Utils__Block(Test, @(){
|
||||
color blue
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user