Skip to content

Instantly share code, notes, and snippets.

@djfarrelly
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djfarrelly/3ad68eab25db8e5118bb to your computer and use it in GitHub Desktop.
Save djfarrelly/3ad68eab25db8e5118bb to your computer and use it in GitHub Desktop.
React modal for buffer
/* globals React */
/** @jsx React.DOM */
/**
* ReactModal
* Create your own React modal within a react component:
* render: function() {
* return (
* <ReactModal isOpen={this.props.isOpen}>
* <ReactModalHeader>
* A Modal title
* </ReactModalHeader>
* <p>Some modal content</p>
* <ReactModalActions>
* <Button onClick={this.close}>Cancel</Button>
* <Button onClick={this.submitForm}>Submit</Button>
* </ReactModalActions>
* </ReactModal>
* )
* }
*
*/
buffer.View.ReactModal = module.exports = React.createClass({
getInitialState: function() {
return {
open: this.props.isOpen === true
};
},
open: function() {
this.setState({ open: true });
},
close: function() {
this.setState({ open: false });
},
handleOverlayClick: function() {
this.close();
},
handleCloseClick: function() {
this.close();
},
render: function() {
return (
<div className="modal-container">
<div className="modal-mask" onClick="this.handleOverlayClick"></div>
<div className="modal clearfix">
<div className="modal-close" onClick={this.handleCloseClick}>
<i className="ss-delete"></i>
</div>
{this.props.children}
</div>
</div>
);
}
});
buffer.View.ReactModalActions = module.exports = React.createClass({
render: function() {
return (
<div className="modal-footer">
{this.props.children}
</div>
);
}
});
buffer.View.ReactModalHeader = module.exports = React.createClass({
render: function() {
return (
<h1 className="modal-header">
{this.props.children}
</h1>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment