2020-12-12 13:29:15 +03:00
|
|
|
import { faChevronDown as arrowIcon, faCogs as cogsIcon } from '@fortawesome/free-solid-svg-icons';
|
2020-08-29 10:19:15 +03:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
2020-11-14 00:44:26 +03:00
|
|
|
import { FC, useEffect } from 'react';
|
2022-02-06 22:07:18 +03:00
|
|
|
import { Link, useLocation } from 'react-router-dom';
|
2020-08-29 10:19:15 +03:00
|
|
|
import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import { useToggle } from '../utils/helpers/hooks';
|
2020-12-20 10:56:46 +03:00
|
|
|
import { ShlinkLogo } from './img/ShlinkLogo';
|
2020-08-29 10:19:15 +03:00
|
|
|
import './MainHeader.scss';
|
|
|
|
|
2022-02-06 22:07:18 +03:00
|
|
|
const MainHeader = (ServersDropdown: FC) => () => {
|
2020-08-29 10:19:15 +03:00
|
|
|
const [ isOpen, toggleOpen, , close ] = useToggle();
|
2022-02-06 22:07:18 +03:00
|
|
|
const location = useLocation();
|
2020-08-29 10:19:15 +03:00
|
|
|
const { pathname } = location;
|
|
|
|
|
|
|
|
useEffect(close, [ location ]);
|
|
|
|
|
|
|
|
const settingsPath = '/settings';
|
|
|
|
const toggleClass = classNames('main-header__toggle-icon', { 'main-header__toggle-icon--opened': isOpen });
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Navbar color="primary" dark fixed="top" className="main-header" expand="md">
|
|
|
|
<NavbarBrand tag={Link} to="/">
|
2020-12-20 10:56:46 +03:00
|
|
|
<ShlinkLogo className="main-header__brand-logo" color="white" /> Shlink
|
2020-08-29 10:19:15 +03:00
|
|
|
</NavbarBrand>
|
|
|
|
|
|
|
|
<NavbarToggler onClick={toggleOpen}>
|
|
|
|
<FontAwesomeIcon icon={arrowIcon} className={toggleClass} />
|
|
|
|
</NavbarToggler>
|
|
|
|
|
|
|
|
<Collapse navbar isOpen={isOpen}>
|
|
|
|
<Nav navbar className="ml-auto">
|
|
|
|
<NavItem>
|
2021-09-19 12:17:56 +03:00
|
|
|
<NavLink tag={Link} to={settingsPath} active={pathname === settingsPath}>
|
2020-08-29 10:19:15 +03:00
|
|
|
<FontAwesomeIcon icon={cogsIcon} /> Settings
|
|
|
|
</NavLink>
|
|
|
|
</NavItem>
|
|
|
|
<ServersDropdown />
|
|
|
|
</Nav>
|
|
|
|
</Collapse>
|
|
|
|
</Navbar>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default MainHeader;
|