'use strict'; import React from 'react'; import Panel from 'react-bootstrap/lib/Panel'; const CollapsibleParagraph = React.createClass({ propTypes: { title: React.PropTypes.string, children: React.PropTypes.oneOfType([ React.PropTypes.object, React.PropTypes.array ]), iconName: React.PropTypes.string, show: React.PropTypes.bool, defaultExpanded: React.PropTypes.bool }, getDefaultProps() { return { show: true }; }, getInitialState() { return { expanded: this.props.defaultExpanded }; }, handleToggle(e){ e.preventDefault(); this.setState({expanded: !this.state.expanded}); }, render() { let text = this.state.expanded ? '-' : '+'; if(this.props.show) { return (
{text} {this.props.title}
{this.props.children}
); } else { return null; } } }); export default CollapsibleParagraph;