Skip to content

Instantly share code, notes, and snippets.

@narqo
Last active August 29, 2015 14:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save narqo/82b300a3bb209628eb07 to your computer and use it in GitHub Desktop.
Save narqo/82b300a3bb209628eb07 to your computer and use it in GitHub Desktop.
How bem-core + ES6 may looks like
// @file common.blocks/button/button.js
import provide from 'ym';
import BemDom from 'i-bem__dom';
provide(BemDom.decl('button', {
onSetMod : {
'js' : {
'inited' : function() {
// ···
}
}
},
_onPointerClick() {
this.emit('click');
}
}, {
live() {
this.liveBindTo('pointerclick', this.prototype._onPointerClick);
}
}));
// @file common.blocks/functions/functions.js
import provide from 'ym';
var toStr = Object.prototype.toString;
provide({
isFunction : function(obj) {
return toStr.call(obj) === '[object Function]';
},
noop : function() {}
});
// @file common.blocks/jquery/jquery.js
import provide from 'ym';
import loader from 'loader_type_js';
import cfg from 'jquery__config';
function doProvide(preserveGlobal) {
provide(preserveGlobal? jQuery : jQuery.noConflict(true));
}
typeof jQuery !== 'undefined'?
doProvide(true) :
loader(cfg.url, doProvide);
// @file common.blocks/select/_mode/select_mode_check.js
import provide from 'ym';
import escape from 'strings__escape';
import Select from 'select';
provide(Select.declMod({ modName : 'type', modVal : 'check' }, {
/** @override */
_onButtonClick() {
// ···
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment