This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jBlocks.define('counter', { | |
events: { | |
'click .js-inc': 'inc', | |
'click .js-dec': 'dec' | |
}, | |
methods: { | |
oninit: function() { | |
this._currentValue = Number(this.params.initialValue); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="js-counter" data-component="сounter" data-props='{ "initialValue": 2 }'> | |
<button class="js-inc">+</button> | |
<button class="js-dec">-</button> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// somewhere in my program, when DOM is ready... | |
var counter = jBlocks.get(document.querySelector('.js-counter')); | |
// use event to react on what happens during lifecycle | |
counter.on('changed', function() { | |
console.log('hello, world!'); | |
}); | |
// ... when user clicks on inc button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* <div class="block"> | |
* <div class="block__foo"> | |
* <div class="block__bar block__bar_green"> | |
* <div class="another-block__bar"></div> | |
* </div> | |
* <div class="block block_cool"></div> | |
* </div> | |
* </div> | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
span { | |
display: inline-block; | |
width: 10px; | |
height: 10px; | |
background: red; | |
} | |
.flex { | |
display: flex; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wrapper { | |
background: red; | |
} | |
.wrapper:after { | |
content: ''; | |
display: table; | |
} | |
.inner { | |
margin: 20px 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyArray() { | |
this._index = 0; | |
} | |
MyArray.prototype.push = function(v) { | |
this[this._index++] = v; | |
} | |
var arr = new MyArray(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wrapper { | |
display: flex; | |
justify-content: space-between; | |
} | |
.input { | |
width: 100%; | |
outline: 1px solid red; | |
display: inline-block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wrapper { | |
display: flex; | |
justify-content: space-between; | |
} | |
.input { | |
width: 100%; | |
outline: 1px solid red; | |
display: inline-block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wrapper:after { | |
content: ''; | |
display: block; | |
clear: both; | |
} | |
.input { | |
overflow: hidden; | |
outline: 1px solid red; | |
} |