mirror of https://github.com/sgoudham/carbon.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
512 B
JavaScript
30 lines
512 B
JavaScript
import React from 'react'
|
|
import Toggle from './Toggle'
|
|
|
|
import { toggle } from '../lib/util'
|
|
|
|
class Collapse extends React.PureComponent {
|
|
state = {
|
|
open: false
|
|
}
|
|
|
|
toggle = () => this.setState(toggle('open'))
|
|
|
|
render() {
|
|
if (this.state.open) {
|
|
return this.props.children
|
|
}
|
|
return (
|
|
<Toggle
|
|
enabled={false}
|
|
center={true}
|
|
label={this.props.label}
|
|
className="collapse"
|
|
onChange={this.toggle}
|
|
/>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default Collapse
|