R: Modal Example

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>
<script src="https://npmcdn.com/classnames/index.js"></script>
<link rel="stylesheet" href="https://localhost:8443/styles/base.min.css">
<div class="js-app"></div>

CSS

* {
  -webkit-font-smoothing: antialiased;
}

body {
    padding: 5%;
}

Babel + JSX

console.clear();

/**
 * App Component
 * Holds actions, controls modal display using the state modalVisible.
 */
var AppComponent = React.createClass({
	getInitialState() {
    	return {
        	modalVisible: false
        }
    },
	
	_onModalYesClicked() {
    	console.log('onYesClicked::contact the server');
        
        this.toggleModal();
    },
    
    _onModalNoClicked() {
    	console.log('onNoClicked:contact the server');

		this.toggleModal();
    },
    
    toggleModal({title = null, description = null} = {}) {
    	this.setState({
        	modalVisible: !this.state.modalVisible,
            title: title,
            description: description
        });
    },
    
    onCancelClicked() {
    	console.log('onCancelClicked');
            
        this.toggleModal({
        	title: 'Cancel',
        	description: 'Would you like to commit to cancelling?'
        });
    },
    
    onHoldClicked() {
    	console.log('onHoldClicked');
        
		this.toggleModal({
        	title: 'Hold',
        	description: 'Are you sure you would like to hold the order?'
        });
    },
    
    render() {
    	var modal = undefined;
        
        if(this.state.modalVisible) {
        	modal = <ModalComponent 
            	title={this.state.title}
                description={this.state.description}
            	onModalYesClicked={this._onModalYesClicked} 
                onModalNoClicked={this._onModalNoClicked}  />
        }
    
        return (
        	<div>
                <button className="btn btn--negative" onClick={this.onCancelClicked}>Cancel</button>
                <button className="btn" onClick={this.onHoldClicked}>Hold</button>
                
                {modal}
            </div>
    	)
    }
});

/**
 * Modal Component
 * Uses props to tell parent component the action to take on action click.
 */
var ModalComponent = React.createClass({
	render() {
    	return (
        	<div className="modal modal--is-open">
              <div...