blob: 33dbe01157bc3cd661803f52ec357d5e1d6a1339 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import classNames from "classnames";
import React from "react";
import "./Sidebar.css";
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;
|