Last active
August 29, 2015 14:17
-
-
Save joelmoss/d1e0be2692ede425ff93 to your computer and use it in GitHub Desktop.
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
import React from 'react' | |
import Modal from 'react-modal/lib/index' | |
Modal.setAppElement(document.getElementById('codio')) | |
Modal.injectCSS() | |
export default React.createClass({ | |
displayName: 'ModalConfirm', | |
propTypes: { | |
onClose: React.PropTypes.func | |
}, | |
getDefaultProps() { | |
return { | |
onClose: function (e) { | |
console.log('modal', e) | |
} | |
} | |
}, | |
getInitialState() { | |
return { modalIsOpen: false } | |
}, | |
openModal() { | |
this.setState({modalIsOpen: true}) | |
}, | |
closeModal() { | |
this.setState({modalIsOpen: false}) | |
}, | |
// Opportunity to validate something and keep the modal open even if it requested to be closed. | |
handleNo() { | |
this.setState({modalIsOpen: false}) | |
}, | |
render() { | |
return ( | |
<Modal className='modal-dialog' isOpen={this.state.modalIsOpen} onRequestClose={this.handleNo}> | |
{this.props.children} | |
<div className='modal-footer'> | |
<button type='button' className='btn btn-primary' onClick={this.handleYes}>Yes</button> | |
<button type='button' className='btn btn-default' onClick={this.handleNo}>No</button> | |
</div> | |
</Modal> | |
) | |
} | |
}) |
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
<ConfirmModal ref='logoutConfirmModal'> | |
<ModalHeader>Sign Out</ModalHeader> | |
<ModalBody> | |
<h3 className='centered'>Are you sure you wish to sign out?</h3> | |
</ModalBody> | |
</ConfirmModal> |
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
import React from 'react' | |
import Icon from '../icon' | |
export default React.createClass({ | |
displayName: 'ModalHeader', | |
propTypes: { | |
onClose: React.PropTypes.func | |
}, | |
getDefaultProps() { | |
return { | |
onClose: function (e) { | |
console.log('header', e) | |
} | |
} | |
}, | |
render() { | |
return ( | |
<div className="modal-header"> | |
<button type="button" className="close" onClick={this.props.onClose}> | |
<span aria-hidden="true">×</span> | |
</button> | |
<Icon name='signout' /> | |
<h3 className="modal-title">{this.props.children}</h3> | |
</div> | |
) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment