import clsx from 'clsx'; import type { ComponentType, DOMAttributes, FunctionComponent, ReactElement, } from 'react'; import React from 'react'; import { Tooltip } from '../Rcui/Tooltip'; import styles from './styles.scss'; type NavigationButtonIconProps = { currentPath?: string; }; export type NavigationButtonIcon = | ReactElement | ComponentType; export interface NavigationButtonProps { icon: NavigationButtonIcon; activeIcon: NavigationButtonIcon; active?: boolean; label: string; noticeCounts?: number; width: number | string; height: number | string; onClick: DOMAttributes['onClick']; keepStyle: boolean; activeClassName: string; inActiveClassName: string; className?: string; id?: string; tooltipForceHide?: boolean; dataSign?: string; } export const NavigationButton: FunctionComponent = ({ active, activeIcon, icon, label, noticeCounts, onClick, width, height, keepStyle, className, activeClassName, inActiveClassName, id, tooltipForceHide, dataSign, }) => { let notice = null; if (noticeCounts && noticeCounts > 0) { if (noticeCounts > 99) { notice = (
99+
); } else { notice = (
{noticeCounts}
); } } return (
{active ? activeIcon : icon}
{notice}
); }; NavigationButton.defaultProps = { active: false, keepStyle: false, }; export default NavigationButton;