import React from 'react'; import ls from './Section.less'; import Fa from './Fa'; export const TabContext = React.createContext(0); export class Section extends React.PureComponent { constructor({defaultClosed}) { super(); this.state = { closed: defaultClosed } } render() { let {label, closable, children} = this.props; let closed = this.isClosed(); return { tabs =>
{label}
{!closed && children}
}
; } isClosed() { let {closable} = this.props; if (!closable) return false; return closable && this.state.closed; } tweakClose = () => { this.setState({closed: !this.isClosed()}); } }