Last active
August 29, 2015 14:13
-
-
Save djfarrelly/3ad68eab25db8e5118bb to your computer and use it in GitHub Desktop.
React modal for buffer
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
/* 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> | |
); | |
} | |
}); |
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
buffer.View.ReactModalActions = module.exports = React.createClass({ | |
render: function() { | |
return ( | |
<div className="modal-footer"> | |
{this.props.children} | |
</div> | |
); | |
} | |
}); |
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
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