-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSidebar.js
More file actions
48 lines (44 loc) · 1.49 KB
/
Sidebar.js
File metadata and controls
48 lines (44 loc) · 1.49 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
import React, {useState} from "react";
import "./CssComponents/Sidebar.css";
import {SidebarData} from './SidebarData';
import {useHistory, Link} from 'react-router-dom';
import * as FaIcons from "react-icons/fa";
import * as AiIcons from "react-icons/ai";
import { IconContext } from 'react-icons';
function Sidebar() {
const [sidebar, setSidebar] = useState(false);
const showSideBar = () => setSidebar(!sidebar);
const history = useHistory();
return (
<IconContext.Provider value={{color: "#fff"}}>
<div className= "Sidebar">
<Link to='#' className='menu-bars'>
<FaIcons.FaBars onClick={showSideBar}/>
</Link>
</div>
<nav className={sidebar ? 'nav-menu active' : 'nav-menu'}>
<ul className='nav-menu-items'>
<li className='navbar-toggle' onClick={showSideBar}>
<Link to="#" className='menu-bars'>
<AiIcons.AiOutlineClose />
</Link>
</li>
{SidebarData.map((val, key) => {
return (
<li
key= {key}
className="row"
id={window.location.pathname === val.link ? "active" : ""}
onClick={ ()=> {history.push(val.link); window.location.pathname = val.link;}}>
{" "}
<div id="icon"> {val.icon} </div>
<div id="title"> {val.title} </div>
</li>
);
})}
</ul>
</nav>
</IconContext.Provider>
);
}
export default Sidebar;