This file contains hidden or 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
/* | |
You can use this function to dynamically render children in a Rect component, passing into parent's props. | |
It checks if the children call is a function or a React element and render it with parent's props | |
*/ | |
function renderChildren( children, props ) { | |
return toString.call(children) == '[object Function]' ? children(props) : React.Children.map(children, child => React.cloneElement(child, props)) | |
} |
This file contains hidden or 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
/** | |
* Extract only data attributes from an element (or a jQuery element) and return it as an object | |
* @param {Element} el JS raw element or jQuery element | |
* @param {String} dataTag data key from extract the rest. Could start with "data-" or not | |
* @param {Boolean} camelCase keys returned camelCased or not | |
* @return {Object} | |
* | |
* IMPORTANT: It use lodash/underscore as a dependency! | |
* IMPORTANT: Made in ES6 | |
* |
This file contains hidden or 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
import pluginify from 'pluginify'; | |
class Plugin { | |
constructor() { | |
/* ... */ | |
} | |
} | |
/* | |
Convert plugin class into a jQuery plugin |
This file contains hidden or 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
define([ | |
'jquery', | |
'domReady', | |
'path/to/facebook' | |
], | |
function( $, domReady, Facebook ) { | |
"use strict"; | |
var app = { |