summaryrefslogtreecommitdiff
path: root/src/components/sidebars/Sidebar.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/sidebars/Sidebar.js')
-rw-r--r--src/components/sidebars/Sidebar.js40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/components/sidebars/Sidebar.js b/src/components/sidebars/Sidebar.js
index ce743b17..00e3607a 100644
--- a/src/components/sidebars/Sidebar.js
+++ b/src/components/sidebars/Sidebar.js
@@ -2,13 +2,37 @@ import classNames from "classnames";
import React from "react";
import "./Sidebar.css";
-const Sidebar = ({isRight, children}) => (
- <div
- className={classNames("sidebar p-3 h-100", {"sidebar-right": isRight})}
- onWheel={e => e.stopPropagation()}
- >
- {children}
- </div>
-);
+class Sidebar extends React.Component {
+ state = {
+ collapsed: false
+ };
+
+ render() {
+ const collapseButton = (
+ <div
+ className={classNames("sidebar-collapse-button", {"sidebar-collapse-button-right": this.props.isRight})}
+ onClick={() => this.setState({collapsed: !this.state.collapsed})}
+ >
+ {(this.state.collapsed && this.props.isRight) || (!this.state.collapsed && !this.props.isRight) ?
+ <span className="fa fa-angle-left" title={this.props.isRight ? "Expand" : "Collapse"}/> :
+ <span className="fa fa-angle-right" title={this.props.isRight ? "Collapse" : "Expand"}/>
+ }
+ </div>
+ );
+
+ if (this.state.collapsed) {
+ return collapseButton;
+ }
+ return (
+ <div
+ className={classNames("sidebar p-3 h-100", {"sidebar-right": this.props.isRight})}
+ onWheel={e => e.stopPropagation()}
+ >
+ {this.props.children}
+ {collapseButton}
+ </div>
+ );
+ }
+}
export default Sidebar;