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.
35 lines
563 B
JavaScript
35 lines
563 B
JavaScript
import React from 'react'
|
|
import Toggle from './Toggle'
|
|
|
|
class Collapse extends React.Component {
|
|
constructor(props) {
|
|
super(props)
|
|
this.state = {
|
|
open: false
|
|
}
|
|
}
|
|
|
|
toggle = () => {
|
|
this.setState(state => ({
|
|
open: !state.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
|