Skip to content

Instantly share code, notes, and snippets.

@davidgilbertson
Last active June 4, 2016 07:09
Show Gist options
  • Save davidgilbertson/1769faff75731a9a3ef310544a71d99c to your computer and use it in GitHub Desktop.
Save davidgilbertson/1769faff75731a9a3ef310544a71d99c to your computer and use it in GitHub Desktop.
import React from 'react';
const {Component, PropTypes} = React;
import SignInModalBody from './SignInModalBody.jsx';
import EditScreenModalBody from './EditScreenModalBody.jsx';
import FeedbackModalBody from './FeedbackModalBody.jsx';
import HelpPanelModalBody from './HelpPanelModalBody.jsx';
import styles from './styles.js';
class Modal extends Component {
render() {
let ModalBody;
switch (this.props.currentModal) {
case 'signIn' :
ModalBody = SignInModalBody;
break;
case 'editScreen' :
ModalBody = EditScreenModalBody;
break;
case 'feedback' :
ModalBody = FeedbackModalBody;
break;
case 'helpPanel' :
ModalBody = HelpPanelModalBody;
break;
default :
return null; // no known modal, don't render anything
}
return (
<div style={styles.back}>
<div style={styles.panel}>
<div style={styles.header}>
<h1 style={styles.title}>The Modal Title</h1>
<button style={styles.close}>Close</button>
</div>
<div style={styles.body}>
<ModalBody {...this.props}/>
</div>
<div style={styles.actions}>
<button>OK</button>
</div>
</div>
</div>
);
}
}
Modal.propTypes = {
currentModal: PropTypes.string.isRequired,
hideModal: PropTypes.func.isRequired,
};
export default Modal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment