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

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