Bachelorthesis_Code/frontend/src/components/Navbar.js
cami 29142a9977 Refactoring because of local scripts and tabs
In this commit I want to refactor some things.
- I don't want to use external connections so I moved all that shit to localhost
- I do not need so many spaces as it is bad for formatting
2021-05-27 03:07:54 +02:00

83 lines
2.2 KiB
JavaScript

import React, { useState, useEffect } from "react";
import { Button } from "./Button";
import { Link } from "react-router-dom";
import "./Navbar.css";
import "@fortawesome/fontawesome-free/css/all.css";
function Navbar() {
const [click, setClick] = useState(false);
const [button, setButton] = useState(true);
const handleClick = () => setClick(!click);
const closeMobileMenu = () => setClick(false);
const showButton = () => {
if (window.innerWidth <= 960) {
setButton(false);
} else {
setButton(true);
}
};
/* Shows the button after resizing the screen */
useEffect(() => {
showButton();
}, []);
window.addEventListener("resize", showButton);
return (
<>
<nav className="navbar">
<div className="navbar-container">
<Link to="/" className="navbar-logo" onClick={closeMobileMenu}>
TRVL
<i class="fab fa-typo3" />
</Link>
<div className="menu-icon" onClick={handleClick}>
<i className={click ? "fas fa-times" : "fas fa-bars"} />
</div>
<ul className={click ? "nav-menu active" : "nav-menu"}>
<li className="nav-item">
<Link to="/" className="nav-links" onClick={closeMobileMenu}>
Home
</Link>
</li>
<li className="nav-item">
<Link
to="/services"
className="nav-links"
onClick={closeMobileMenu}
>
Services
</Link>
</li>
<li className="nav-item">
<Link
to="/products"
className="nav-links"
onClick={closeMobileMenu}
>
Products
</Link>
</li>
<li>
<Link
to="/sign-up"
className="nav-links-mobile"
onClick={closeMobileMenu}
>
Sign Up
</Link>
</li>
</ul>
{button && <Button buttonStyle="btn--outline">SIGN UP</Button>}
</div>
</nav>
</>
);
}
export default Navbar;