1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
This commit is contained in:
diminator 2015-07-07 15:56:35 +02:00
parent 4a2ad0ea9d
commit d5ce1ecde2
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,38 @@
'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() {
let isVisible = (this.state.expanded) ? '' : 'invisible';
return (
<span>
<span onClick={this.handleToggle}>
{this.props.button}
</span>
<div ref='panel' className={isVisible}>
{this.props.panel}
</div>
</span>
);
}
});
export default CollapsibleButton;

View File

@ -191,7 +191,7 @@ let MediaContainer = React.createClass({
} }
}); });
const CollapsibleButton = React.createClass({ let CollapsibleButton = React.createClass({
propTypes: { propTypes: {
button: React.PropTypes.object, button: React.PropTypes.object,