Sidebar.jsx
2.45 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import React, { Component } from "react";
import { NavLink } from "react-router-dom";
import AdminNavbarLinks from "../Navbars/AdminNavbarLinks.jsx";
import logo from "assets/img/reactlogo.png";
class Sidebar extends Component {
constructor(props) {
super(props);
this.state = {
width: window.innerWidth
};
}
activeRoute(routeName) {
return this.props.location.pathname.indexOf(routeName) > -1 ? "active" : "";
}
updateDimensions() {
this.setState({ width: window.innerWidth });
}
componentDidMount() {
this.updateDimensions();
window.addEventListener("resize", this.updateDimensions.bind(this));
}
render() {
const sidebarBackground = {
backgroundColor: 'rgb(217,94,45)'
};
console.log(this.props.color);
return (
<div
id="sidebar"
className="sidebar"
>
{this.props.hasImage ? (
<div className="sidebar-background" style={sidebarBackground} />
) : (
null
)}
<div className="logo">
<a
href="https://www.creative-tim.com?ref=lbd-sidebar"
className="simple-text logo-mini"
>
<div className="logo-img">
<img src={logo} alt="logo_image" />
</div>
</a>
<a
href="https://www.creative-tim.com?ref=lbd-sidebar"
className="simple-text logo-normal"
>
Creative Tim
</a>
</div>
<div className="sidebar-wrapper">
<ul className="nav">
{this.state.width <= 991 ? <AdminNavbarLinks /> : null}
{this.props.routes.map((prop, key) => {
if (!prop.redirect)
return (
<li
className={
prop.upgrade
? "active active-pro"
: this.activeRoute(prop.layout + prop.path)
}
key={key}
>
<NavLink
to={prop.layout + prop.path}
className="nav-link"
activeClassName="active"
>
<i className={prop.icon} />
<p>{prop.name}</p>
</NavLink>
</li>
);
return null;
})}
</ul>
</div>
</div>
);
}
}
export default Sidebar;