bigbuffet-rw/app/soapbox/components/icon_with_counter.tsx

25 lines
665 B
TypeScript
Raw Normal View History

import React from 'react';
import Icon from 'soapbox/components/icon';
import { shortNumberFormat } from 'soapbox/utils/numbers';
interface IIconWithCounter extends React.HTMLAttributes<HTMLDivElement> {
count: number,
icon?: string;
src?: string;
}
const IconWithCounter: React.FC<IIconWithCounter> = ({ icon, count, ...rest }) => {
return (
2022-03-21 11:09:01 -07:00
<div className='relative'>
<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'>
{shortNumberFormat(count)}
</i>}
</div>
);
};
export default IconWithCounter;