2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-06-30 07:51:36 -07:00
|
|
|
import Icon, { IIcon } from 'soapbox/components/icon';
|
2022-04-28 14:29:15 -07:00
|
|
|
import { Counter } from 'soapbox/components/ui';
|
2020-12-29 17:48:39 -08:00
|
|
|
|
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'>
|
2022-06-30 07:51:36 -07:00
|
|
|
<Icon id={icon} {...rest as IIcon} />
|
2022-03-21 11:09:01 -07:00
|
|
|
|
2022-04-28 14:29:15 -07:00
|
|
|
{count > 0 && (
|
|
|
|
<i className='absolute -top-2 -right-2'>
|
|
|
|
<Counter count={count} />
|
|
|
|
</i>
|
|
|
|
)}
|
2020-12-29 17:48:39 -08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default IconWithCounter;
|