58 lines
1.3 KiB
Stylus
58 lines
1.3 KiB
Stylus
/*
|
|
* This is set of mixins to help generating
|
|
* CSS classes according to the Block__Element--Modifier pattern.
|
|
* It also helps nesting those classes in any fashion imaganible
|
|
* and still produces clean BEM CSS
|
|
*/
|
|
|
|
_css-prefix = 'RV'
|
|
|
|
// Cache for Blocks
|
|
_last_block_name = null
|
|
|
|
_element_building_lane = {}
|
|
_element_block_stack = ()
|
|
|
|
_block_modifier_building_lane = {}
|
|
_block_modifier_block_stack = ()
|
|
|
|
|
|
/*
|
|
* Generates a CSS class for an
|
|
* Block according to BEM
|
|
*/
|
|
RV-Block(name)
|
|
tow(name, block)
|
|
|
|
|
|
/*
|
|
* Generates a CSS class for an block modifier
|
|
* according to BEM.
|
|
*/
|
|
RV-Block__Modifier(name)
|
|
attach('RV-Block', unquote('--' + name), block)
|
|
|
|
|
|
/*
|
|
* Generates an CSS class for an element
|
|
* according to BEM. Also minds the element modifiers
|
|
* For more see RV-Element___Modifier
|
|
*/
|
|
RV-Element(name)
|
|
attach('RV-Block', unquote('__' + name), block)
|
|
tow(name, block)
|
|
|
|
|
|
|
|
/* p(_block_building_lane)
|
|
* Generates a CSS class for an element modifier
|
|
* according to BEM. These are ment to be part of the
|
|
* content block of an element and since child-mixins
|
|
* are called first there is no way of knowing what the
|
|
* current element is named. To solve this, we store
|
|
* a callback for the modifier and add the element name
|
|
* from RV-Element
|
|
*/
|
|
RV-Element__Modifier(name)
|
|
attach('RV-Element', '--' + name, block)
|
|
|