import React from 'react'; import ReactModal from 'react-modal'; import {Link} from './link.js'; export const Modal = React.createClass({ propTypes: { type: React.PropTypes.oneOf(['alert', 'confirm', 'custom']), onConfirmed: React.PropTypes.func, onAborted: React.PropTypes.func, confirmButtonLabel: React.PropTypes.string, abortButtonLabel: React.PropTypes.string, confirmButtonDisabled: React.PropTypes.bool, abortButtonDisabled: React.PropTypes.bool, }, getDefaultProps: function() { return { type: 'alert', confirmButtonLabel: 'OK', abortButtonLabel: 'Cancel', confirmButtonDisabled: false, abortButtonDisabled: false, }; }, render: function() { return (
{this.props.children}
{this.props.type == 'custom' // custom modals define their own buttons ? null :
{this.props.type == 'confirm' ? : null}
}
); } }); export const ExpandableModal = React.createClass({ propTypes: { expandButtonLabel: React.PropTypes.string, extraContent: React.PropTypes.element, }, getDefaultProps: function() { return { confirmButtonLabel: 'OK', expandButtonLabel: 'Show More...', hideButtonLabel: 'Show Less', } }, getInitialState: function() { return { expanded: false, } }, toggleExpanded: function() { this.setState({ expanded: !this.state.expanded, }); }, render: function() { return ( {this.props.children} {this.state.expanded ? this.props.extraContent : null}
); } }); export default Modal;