import React, { ReactNode, ReactElement } from 'react'; import Icon, { IconName } from '../Icon'; import { BadgeWrapper, CountIconBadge, CountNumberBadge } from './StyledBadge'; import { MAX_NUMBER, getPaddingState, isNumber } from './utils'; export interface CountProps { /* * The count badge's content. */ children: ReactNode; /** * If it is number, just input the number value. If icon, just input name of icon (corresponding to Icon component in hero-design). */ content: number | IconName; /** * Visual intent color to apply to count badge. */ intent?: 'success' | 'primary' | 'warning' | 'danger' | 'error'; } const Count = ({ children, content, intent = 'danger', }: CountProps): ReactElement => { return ( {children} {isNumber(content) ? ( {content > MAX_NUMBER ? `${MAX_NUMBER}+` : content} ) : ( )} ); }; export default Count;