2020-08-29 10:19:15 +03:00
|
|
|
import {
|
2023-02-18 13:11:01 +03:00
|
|
|
faGlobe as domainsIcon,
|
|
|
|
faHome as overviewIcon,
|
2020-08-29 10:19:15 +03:00
|
|
|
faLink as createIcon,
|
2023-02-18 13:11:01 +03:00
|
|
|
faList as listIcon,
|
|
|
|
faTags as tagsIcon,
|
2020-08-29 10:19:15 +03:00
|
|
|
} from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
2023-02-18 13:11:01 +03:00
|
|
|
import classNames from 'classnames';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { FC } from 'react';
|
|
|
|
import type { NavLinkProps } from 'react-router-dom';
|
|
|
|
import { NavLink, useLocation } from 'react-router-dom';
|
2020-08-29 10:19:15 +03:00
|
|
|
import './AsideMenu.scss';
|
|
|
|
|
2020-08-29 11:53:02 +03:00
|
|
|
export interface AsideMenuProps {
|
2023-07-16 23:54:49 +03:00
|
|
|
routePrefix: string;
|
2020-08-29 10:19:15 +03:00
|
|
|
showOnMobile?: boolean;
|
|
|
|
}
|
|
|
|
|
2020-08-29 11:53:02 +03:00
|
|
|
interface AsideMenuItemProps extends NavLinkProps {
|
2020-08-29 10:19:15 +03:00
|
|
|
to: string;
|
2022-12-26 00:48:47 +03:00
|
|
|
className?: string;
|
2020-08-29 10:19:15 +03:00
|
|
|
}
|
|
|
|
|
2020-08-29 11:53:02 +03:00
|
|
|
const AsideMenuItem: FC<AsideMenuItemProps> = ({ children, to, className, ...rest }) => (
|
2020-08-29 10:19:15 +03:00
|
|
|
<NavLink
|
2022-02-06 22:07:18 +03:00
|
|
|
className={({ isActive }) => classNames('aside-menu__item', className, { 'aside-menu__item--selected': isActive })}
|
2020-08-29 10:19:15 +03:00
|
|
|
to={to}
|
|
|
|
{...rest}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</NavLink>
|
|
|
|
);
|
|
|
|
|
2023-07-16 23:54:49 +03:00
|
|
|
export const AsideMenu: FC<AsideMenuProps> = ({ routePrefix, showOnMobile = false }) => {
|
2022-02-06 23:17:10 +03:00
|
|
|
const { pathname } = useLocation();
|
2020-12-15 19:57:24 +03:00
|
|
|
const asideClass = classNames('aside-menu', {
|
2020-08-29 10:19:15 +03:00
|
|
|
'aside-menu--hidden': !showOnMobile,
|
|
|
|
});
|
2023-07-16 23:54:49 +03:00
|
|
|
const buildPath = (suffix: string) => `${routePrefix}${suffix}`;
|
2020-08-29 10:19:15 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<aside className={asideClass}>
|
|
|
|
<nav className="nav flex-column aside-menu__nav">
|
2020-12-06 20:32:24 +03:00
|
|
|
<AsideMenuItem to={buildPath('/overview')}>
|
2021-09-24 20:10:03 +03:00
|
|
|
<FontAwesomeIcon fixedWidth icon={overviewIcon} />
|
2020-12-06 20:32:24 +03:00
|
|
|
<span className="aside-menu__item-text">Overview</span>
|
|
|
|
</AsideMenuItem>
|
2022-02-06 23:17:10 +03:00
|
|
|
<AsideMenuItem
|
|
|
|
to={buildPath('/list-short-urls/1')}
|
|
|
|
className={classNames({ 'aside-menu__item--selected': pathname.match('/list-short-urls') !== null })}
|
|
|
|
>
|
2021-09-24 20:10:03 +03:00
|
|
|
<FontAwesomeIcon fixedWidth icon={listIcon} />
|
2020-08-29 10:19:15 +03:00
|
|
|
<span className="aside-menu__item-text">List short URLs</span>
|
|
|
|
</AsideMenuItem>
|
|
|
|
<AsideMenuItem to={buildPath('/create-short-url')}>
|
2021-09-24 20:10:03 +03:00
|
|
|
<FontAwesomeIcon fixedWidth icon={createIcon} flip="horizontal" />
|
2020-08-29 10:19:15 +03:00
|
|
|
<span className="aside-menu__item-text">Create short URL</span>
|
|
|
|
</AsideMenuItem>
|
|
|
|
<AsideMenuItem to={buildPath('/manage-tags')}>
|
2021-09-24 20:10:03 +03:00
|
|
|
<FontAwesomeIcon fixedWidth icon={tagsIcon} />
|
2020-08-29 10:19:15 +03:00
|
|
|
<span className="aside-menu__item-text">Manage tags</span>
|
|
|
|
</AsideMenuItem>
|
2022-12-23 22:42:47 +03:00
|
|
|
<AsideMenuItem to={buildPath('/manage-domains')}>
|
|
|
|
<FontAwesomeIcon fixedWidth icon={domainsIcon} />
|
|
|
|
<span className="aside-menu__item-text">Manage domains</span>
|
|
|
|
</AsideMenuItem>
|
2020-08-29 10:19:15 +03:00
|
|
|
</nav>
|
|
|
|
</aside>
|
|
|
|
);
|
|
|
|
};
|