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.
carbon/components/Collapse.js

28 lines
522 B
JavaScript

import React from 'react'
import Toggle from './Toggle'
import Arrowdown from './svg/Arrowdown'
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} onChange={this.toggle} />
}
}
export default Collapse