-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,450 additions
and
1,267 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
'use strict'; | ||
|
||
var ApplicationStore = require('../store/application'); | ||
var instanciatedApplicationStore; | ||
|
||
/** | ||
* Built the store in order to the . | ||
* @return {ApplicationStore} - An instanciated application store. | ||
*/ | ||
module.exports = function builtInStore() { | ||
if (!instanciatedApplicationStore) { | ||
instanciatedApplicationStore = new ApplicationStore(); | ||
} | ||
return instanciatedApplicationStore; | ||
}; | ||
module.exports = new ApplicationStore(); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,36 @@ | ||
'use strict'; | ||
/*global document*/ | ||
//dependencies | ||
'use strict'; | ||
|
||
var React = require('react'); | ||
var keys = require('lodash/object/keys'); | ||
/** | ||
* Map containing all the mounted components. | ||
* @type {Object} | ||
*/ | ||
var mountedComponents = require('./mounted-components'); | ||
|
||
var clearComponent = require('./clear'); | ||
|
||
/** | ||
* Render a react component in a DOM selector. | ||
* @param {object} component - A react component. | ||
* @param {string} selector - A selector on a DOM node. | ||
* @param {object} options - Options for the component rendering. | ||
*/ | ||
* Render a react component in a DOM selector. | ||
* @param {object} component - A react component. | ||
* @param {string} selector - A selector on a DOM node. | ||
* @param {object} options - Options for the component rendering. | ||
*/ | ||
module.exports = function renderComponent(component, selector, options) { | ||
options = options || {}; | ||
// Clear a potential previously mounted component | ||
clearComponent(selector); | ||
var targetDOMContainer = document.querySelector(selector); | ||
if (!targetDOMContainer) { | ||
throw new Error('You are trying to render a component in a DOM element which is not existing, your selector is ' + selector); | ||
} | ||
// Render the component | ||
var mountedComponent = React.render(React.createElement(component, options.props, options.data), targetDOMContainer); | ||
//Save the fact that a component is mounted. | ||
mountedComponents[selector] = mountedComponent; | ||
console.info('Mounted components : ', keys(mountedComponents)); | ||
return mountedComponent; | ||
options = options || {}; | ||
// Clear a potential previously mounted component | ||
clearComponent(selector); | ||
var targetDOMContainer = document.querySelector(selector); | ||
if (!targetDOMContainer) { | ||
throw new Error('You are trying to render a component in a DOM element which is not existing, your selector is ' + selector); | ||
} | ||
// Render the component | ||
var mountedComponent = React.render(React.createElement(component, options.props, options.data), targetDOMContainer); | ||
//Save the fact that a component is mounted. | ||
mountedComponents[selector] = mountedComponent; | ||
console.info('Mounted components : ', keys(mountedComponents)); | ||
return mountedComponent; | ||
}; | ||
/* | ||
Exemple | ||
var render = Focus.application.render; | ||
var MyComponent = require('./my-component'); | ||
render(MyComponent, 'div.component-container', {props: {id: '12'}}); | ||
*/ | ||
Exemple | ||
var render = Focus.application.render; | ||
var MyComponent = require('./my-component'); | ||
render(MyComponent, 'div.component-container', {props: {id: '12'}}); | ||
*/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,29 @@ | ||
"use strict"; | ||
'use strict'; | ||
|
||
var React = require('react'); | ||
var assign = require('object-assign'); | ||
//var isObject = require('lodash/lang/isObject'); | ||
//var isFunction = require('lodash/lang/isFunction'); | ||
|
||
/** | ||
* Create a component with a mixin except id the component is mixin only. | ||
* @param {object} mixin - The component mixin. | ||
* @param {Boolean} isMixinOnly - define if the component is a mixin only. | ||
* @return {object} - {component} the built react component. | ||
*/ | ||
* Create a component with a mixin except id the component is mixin only. | ||
* @param {object} mixin - The component mixin. | ||
* @param {Boolean} isMixinOnly - define if the component is a mixin only. | ||
* @return {object} - {component} the built react component. | ||
*/ | ||
function createComponent(mixin, isMixinOnly) { | ||
if (isMixinOnly) { | ||
return undefined; //Error('Your class publish a mixin only...'); | ||
} | ||
return { component: React.createClass(mixin) }; | ||
if (isMixinOnly) { | ||
return null; | ||
} | ||
return { component: React.createClass(mixin) }; | ||
} | ||
|
||
/** | ||
* Build a module with a mixin and a React component. | ||
* @param {object} componentMixin - Mixin of the component. | ||
* @param {boolean} isMixinOnly - Bolean to set . | ||
* @return {object} {mixin: 'the component mixin', component: 'the react instanciated component'} | ||
*/ | ||
module.exports = function (componentMixin, isMixinOnly) { | ||
|
||
return assign({ | ||
mixin: componentMixin | ||
/*extend: function extendMixin(properties){ | ||
if(isFunction(componentMixin)){ | ||
throw new Error('You cannot extend a mixin function'); | ||
} | ||
if(!isObject(properties)){ | ||
throw new Error('properties should be an object'); | ||
} | ||
return assign({}, componentMixin, properties); | ||
},*/ | ||
}, createComponent(componentMixin, isMixinOnly)); | ||
* Build a module with a mixin and a React component. | ||
* @param {object} componentMixin - Mixin of the component. | ||
* @param {boolean} isMixinOnly - Bolean to set . | ||
* @return {object} {mixin: 'the component mixin', component: 'the react instanciated component'} | ||
*/ | ||
module.exports = function builder(componentMixin, isMixinOnly) { | ||
return assign({ mixin: componentMixin }, createComponent(componentMixin, isMixinOnly)); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
|
||
module.exports = { | ||
builder: require('./builder'), | ||
types: require('./types') | ||
|
Oops, something went wrong.