webapp
Форк от omaltsev/webapp
80 строк · 2.1 Кб
1import React, { useState, useEffect } from 'react';2import { Button } from './Button';3import { Link } from 'react-router-dom';4import './Navbar.css';5
6function Navbar() {7const [click, setClick] = useState(false);8const [button, setButton] = useState(true);9
10const handleClick = () => setClick(!click);11const closeMobileMenu = () => setClick(false);12
13const showButton = () => {14if (window.innerWidth <= 960) {15setButton(false);16} else {17setButton(true);18}19};20
21useEffect(() => {22showButton();23}, []);24
25window.addEventListener('resize', showButton);26
27return (28<>29<nav className='navbar'>30<div className='navbar-container'>31<Link to='/' className='navbar-logo' onClick={closeMobileMenu}>32TRVL33<i class='fab fa-typo3' />34</Link>35<div className='menu-icon' onClick={handleClick}>36<i className={click ? 'fas fa-times' : 'fas fa-bars'} />37</div>38<ul className={click ? 'nav-menu active' : 'nav-menu'}>39<li className='nav-item'>40<Link to='/' className='nav-links' onClick={closeMobileMenu}>41Home
42</Link>43</li>44<li className='nav-item'>45<Link46to='/services'47className='nav-links'48onClick={closeMobileMenu}49>50Services
51</Link>52</li>53<li className='nav-item'>54<Link55to='/products'56className='nav-links'57onClick={closeMobileMenu}58>59Products
60</Link>61</li>62
63<li>64<Link65to='/sign-up'66className='nav-links-mobile'67onClick={closeMobileMenu}68>69Sign Up
70</Link>71</li>72</ul>73{button && <Button buttonStyle='btn--outline'>SIGN UP</Button>}74</div>75</nav>76</>77);78}
79
80export default Navbar;81