Sidebar.jsx
2.14 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
import React, { Component } from "react";
import { NavLink } from "react-router-dom";
import AdminNavbarLinks from "../Navbars/AdminNavbarLinks.jsx";
// import logo from "../../assets/img/mate_logo.png";
import {mate_logo} from '../../assets/img'
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)'
};
return (
<div
id="sidebar"
className="sidebar"
>
<div className="logo" style={{display: 'flex',justifyContent: 'center', alignItems: 'center'}}>
<a
href="https://www.creative-tim.com?ref=lbd-sidebar"
>
<img src={mate_logo} alt="logo_image" style={{width: '135px'}}/>
</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;