Continued porting to react, approaching beta

This commit is contained in:
Colin McLeod
2016-01-21 22:06:05 -08:00
parent 653cb30dd9
commit 8227a4e361
86 changed files with 3810 additions and 2030 deletions

View File

@@ -1,15 +1,22 @@
import React from 'react';
import shallowEqual from '../utils/shallowEqual';
import { shallowEqual } from '../utils/UtilityFunctions';
/**
* @class Abstract TranslatedComponent
* Abstract Translated Component
*/
export default class TranslatedComponent extends React.Component {
static contextTypes = {
language: React.PropTypes.object.isRequired,
sizeRatio: React.PropTypes.number.isRequired
}
sizeRatio: React.PropTypes.number.isRequired,
openMenu: React.PropTypes.func.isRequired,
closeMenu: React.PropTypes.func.isRequired,
showModal: React.PropTypes.func.isRequired,
hideModal: React.PropTypes.func.isRequired,
tooltip: React.PropTypes.func.isRequired,
termtip: React.PropTypes.func.isRequired,
onWindowResize: React.PropTypes.func.isRequired
};
/**
* Created an instance of a Translated Component. This is an abstract class.
@@ -23,9 +30,9 @@ export default class TranslatedComponent extends React.Component {
/**
* Determine if the context change incldues a language or size change
* @param {object} nextContext The incoming / next context
* @return {boolean} true if the language has changed
* @return {boolean} true if the language has changed
*/
didContextChange(nextContext){
didContextChange(nextContext) {
return nextContext.language !== this.context.language || nextContext.sizeRatio != this.context.sizeRatio;
}
@@ -34,14 +41,12 @@ export default class TranslatedComponent extends React.Component {
* props, state, or context changes. This method performs a shallow comparison to
* determine change.
*
* @param {object} nextProps
* @param {objec} nextState
* @param {objec} nextContext
* @param {object} nextProps Next/Incoming Properties
* @param {objec} nextState Next/Incoming State
* @param {objec} nextContext Next/Incoming Context
* @return {boolean} True if props, state, or context has changed
*/
shouldComponentUpdate(nextProps, nextState, nextContext) {
return !shallowEqual(this.props, nextProps)
|| !shallowEqual(this.state, nextState)
|| this.didContextChange(nextContext);
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState) || this.didContextChange(nextContext);
}
}