2015-07-07 15:56:35 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
let CollapsibleButton = React.createClass({
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
panel: React.PropTypes.object,
|
|
|
|
button: React.PropTypes.object,
|
|
|
|
children: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.object,
|
|
|
|
React.PropTypes.array
|
|
|
|
])
|
|
|
|
},
|
|
|
|
|
|
|
|
getInitialState() {
|
|
|
|
return {expanded: false};
|
|
|
|
},
|
|
|
|
handleToggle(e){
|
|
|
|
e.preventDefault();
|
|
|
|
this.setState({expanded: !this.state.expanded});
|
|
|
|
},
|
|
|
|
render() {
|
2015-11-10 10:32:08 +01:00
|
|
|
let isHidden = (this.state.expanded) ? '' : 'hidden';
|
2015-07-07 15:56:35 +02:00
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
<span onClick={this.handleToggle}>
|
|
|
|
{this.props.button}
|
|
|
|
</span>
|
2015-11-10 10:32:08 +01:00
|
|
|
<div ref='panel' className={isHidden}>
|
2015-07-07 15:56:35 +02:00
|
|
|
{this.props.panel}
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default CollapsibleButton;
|