Add error state

This commit is contained in:
John Furrow
2016-02-03 21:36:52 -08:00
parent f9982e5fa1
commit 6db47c5823
18 changed files with 302 additions and 210 deletions

View File

@@ -1,3 +1,4 @@
import _ from 'lodash';
import CSSTransitionGroup from 'react-addons-css-transition-group';
import React from 'react';
@@ -8,6 +9,7 @@ import UIActions from '../../actions/UIActions';
import UIStore from '../../stores/UIStore';
const METHODS_TO_BIND = [
'handleKeyPress',
'handleOverlayClick',
'onModalChange'
];
@@ -23,13 +25,17 @@ export default class Modals extends React.Component {
METHODS_TO_BIND.forEach((method) => {
this[method] = this[method].bind(this);
});
this.handleKeyPress = _.throttle(this.handleKeyPress, 1000);
}
componentDidMount() {
window.addEventListener('keydown', this.handleKeyPress);
UIStore.listen(EventTypes.UI_MODAL_CHANGE, this.onModalChange);
}
componentWillUnmount() {
window.removeEventListener('keydown', this.handleKeyPress);
UIStore.unlisten(EventTypes.UI_MODAL_CHANGE, this.onModalChange);
}
@@ -37,6 +43,12 @@ export default class Modals extends React.Component {
UIActions.dismissModal();
}
handleKeyPress(event) {
if (this.state.activeModal != null && event.keyCode === 27) {
this.dismissModal();
}
}
handleModalClick(event) {
event.stopPropagation();
}