Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added mobile friendly nav bar #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-widgets": "^5.2.0",
Expand Down
69 changes: 68 additions & 1 deletion src/components/navbar/navbar.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.nav-bar {
width: 200px;
height: 100vh;
background-color: #6c87e9;
background-color: #6c87e9;
}

.workspace {
Expand All @@ -18,4 +18,71 @@ li {
list-style-type: none;
margin-top: 1em;
text-align: left;
}

.navbar {
background-color: #6c87e9;
height: 80px;
display: flex;
justify-content: start;
align-items: center;
}

.nav-menu-bars {
margin: 1rem;
font-size: 2rem;
}

.nav-menu {
background-color: #6c87e9;
width: 250px;
height: 100vh;
display: flex;
justify-content: center;
position: fixed;
top: 0;
left: -100%;
transition: 850ms;
}

.nav-menu.active {
left: 0;
transition: 350ms;
}

.nav-text {
display: flex;
justify-content: start;
align-items: center;
padding: 8px 0px 8px 16px;
list-style: none;
height: 60px;
}

.nav-text a {
text-decoration: none;
color: #f5f5f5;
font-size: 18px;
width: 95%;
height: 100%;
display: flex;
align-items: center;
padding: 0 16px;
border-radius: 4px;
}

.nav-text a:hover {
background-color: #1a83ff;
}

.nav-menu-items {
width: 100%;
}

.nav-menu-items .nav-menu-x {
display: flex;

align-content: start;
margin: 1rem -1rem;
font-size: 2rem;
}
50 changes: 32 additions & 18 deletions src/components/navbar/navbar.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
import './navbar.css';

import * as FaIcons from 'react-icons/fa';
import * as AiIcons from 'react-icons/ai';
import {NavLink} from 'react-router-dom';
import { useContext } from 'react';
import { useContext, useState } from 'react';
import AppContext from '../../AppContext';
import { IconContext } from 'react-icons';

function NavBar({ onLogout }) {
const { workspace } = useContext(AppContext)
const [sidebar, setSidebar] = useState(true);
const toggleSidebar = () => setSidebar(!sidebar);

return (
<div className="nav-bar">
<h1>EventBot</h1>
{workspace &&
<div>
<div className="workspace">
<h3>{workspace.team.name}</h3>
<button onClick={onLogout}>Log Out</button>
</div>
<ul>
<li><NavLink to='/'>Home</NavLink></li>
<li><NavLink to='/sendMessage'>Send Message</NavLink></li>
<li><NavLink to='/scheduleMessage'>Schedule Message</NavLink></li>
<li><NavLink to='/editMessage'>Edit Message</NavLink></li>
</ul>
</div>
}
</div>
<IconContext.Provider value={{ color: '#fff' }}>
{workspace &&
<div>
<div className='navbar'>
<NavLink to='#' className='nav-menu-bars'>
<FaIcons.FaBars onClick={toggleSidebar}/>
</NavLink>
</div>
<nav className={sidebar ? 'nav-menu active' : 'nav-menu'}>
<ul className='nav-menu-items'>
<div className='nav-menu-x' onClick={toggleSidebar}>
<AiIcons.AiOutlineClose/>
</div>
<div>
<h3>{workspace.team.name}</h3>
<button onClick={() => {onLogout(); toggleSidebar()}}>Log Out</button>
</div>
<li><NavLink to='/'>Home</NavLink></li>
<li><NavLink to='/sendMessage'>Send Message</NavLink></li>
<li><NavLink to='/scheduleMessage'>Schedule Message</NavLink></li>
<li><NavLink to='/editMessage'>Edit Message</NavLink></li>
</ul>
</nav>
</div>
}
</IconContext.Provider>
);
}

Expand Down