From 08c4a5173a3d786a077b8fbfb15d2977d7308084 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sat, 25 Feb 2017 02:56:57 -0500 Subject: [PATCH] Add new ExpandableModal component --- js/component/modal.js | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/js/component/modal.js b/js/component/modal.js index ac1316eb1..7f99adffc 100644 --- a/js/component/modal.js +++ b/js/component/modal.js @@ -3,7 +3,7 @@ import ReactModal from 'react-modal'; import {Link} from './link.js'; -var Modal = React.createClass({ +export const Modal = React.createClass({ propTypes: { type: React.PropTypes.oneOf(['alert', 'confirm', 'custom']), onConfirmed: React.PropTypes.func, @@ -43,4 +43,43 @@ var Modal = React.createClass({ } }); +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;