import clsx from 'clsx'; import React from 'react'; import { NavLink, useLocation } from 'react-router-dom'; import IconWithCounter from 'pl-fe/components/icon-with-counter'; import { Icon } from 'pl-fe/components/ui'; import { useSettings } from 'pl-fe/hooks'; interface IThumbNavigationLink { count?: number; countMax?: number; src: string; activeSrc?: string; text: string | React.ReactElement; to: string; exact?: boolean; paths?: Array; } const ThumbNavigationLink: React.FC = ({ count, countMax, src, activeSrc, text, to, exact, paths }): JSX.Element => { const { pathname } = useLocation(); const { demetricator } = useSettings(); const isActive = (): boolean => { if (paths) { return paths.some(path => pathname.startsWith(path)); } else { return exact ? pathname === to : pathname.startsWith(to); } }; const active = isActive(); const icon = (active && activeSrc) || src; return ( {!demetricator && count !== undefined ? ( ) : ( )} ); }; export { ThumbNavigationLink as default };