import PropTypes from 'prop-types' import classNames from 'classnames' import React from 'react' import './Sidebar.css' class Sidebar extends React.Component { static propTypes = { isRight: PropTypes.bool.isRequired, collapsible: PropTypes.bool, } static defaultProps = { collapsible: true, } state = { collapsed: false, } render() { const collapseButton = (
this.setState({ collapsed: !this.state.collapsed })} > {(this.state.collapsed && this.props.isRight) || (!this.state.collapsed && !this.props.isRight) ? ( ) : ( )}
) if (this.state.collapsed) { return collapseButton } return (
e.stopPropagation()} > {this.props.children} {this.props.collapsible && collapseButton}
) } } export default Sidebar