2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2020-12-29 17:48:39 -08:00
|
|
|
import Icon from 'soapbox/components/icon';
|
|
|
|
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
|
|
|
|
2022-03-30 08:37:30 -07:00
|
|
|
interface IIconWithCounter extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
|
count: number,
|
|
|
|
icon?: string;
|
|
|
|
src?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const IconWithCounter: React.FC<IIconWithCounter> = ({ icon, count, ...rest }) => {
|
2020-12-29 17:48:39 -08:00
|
|
|
return (
|
2022-03-21 11:09:01 -07:00
|
|
|
<div className='relative'>
|
2021-09-12 17:45:17 -07:00
|
|
|
<Icon id={icon} {...rest} />
|
2022-03-21 11:09:01 -07:00
|
|
|
|
|
|
|
{count > 0 && <i className='absolute -top-2 -right-2 block px-1.5 py-0.5 bg-accent-500 text-xs text-white rounded-full ring-2 ring-white'>
|
2020-12-29 17:48:39 -08:00
|
|
|
{shortNumberFormat(count)}
|
|
|
|
</i>}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default IconWithCounter;
|