Files
webtorrent-desktop/src/renderer/components/ShowMore.js
Feross Aboukhadijeh 82853aa017 more progress
2016-08-23 04:21:58 -07:00

56 lines
1.0 KiB
JavaScript

const React = require('react')
const FlatButton = require('material-ui/FlatButton').default
class ShowMore extends React.Component {
static get propTypes () {
return {
defaultExpanded: React.PropTypes.bool,
hideLabel: React.PropTypes.string,
showLabel: React.PropTypes.string
}
}
static get defaultProps () {
return {
hideLabel: 'Hide more...',
showLabel: 'Show more...'
}
}
constructor (props) {
super(props)
this.state = {
expanded: !!this.props.defaultExpanded
}
this.handleClick = this.handleClick.bind(this)
}
handleClick () {
this.setState({
expanded: !this.state.expanded
})
}
render () {
const label = this.state.expanded
? this.props.hideLabel
: this.props.showLabel
return (
<div
style={this.props.style}
>
{this.state.expanded ? this.props.children : null}
<FlatButton
onClick={this.handleClick}
label={label}
/>
</div>
)
}
}
module.exports = ShowMore