2022-01-10 22:17:52 +00:00
|
|
|
import React from 'react';
|
2022-01-10 22:25:06 +00:00
|
|
|
|
2022-06-30 14:51:36 +00:00
|
|
|
import Icon, { IIcon } from 'soapbox/components/icon';
|
2022-04-28 21:29:15 +00:00
|
|
|
import { Counter } from 'soapbox/components/ui';
|
2020-12-30 01:48:39 +00:00
|
|
|
|
2022-03-30 15:37:30 +00:00
|
|
|
interface IIconWithCounter extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
|
count: number,
|
2022-11-03 16:13:45 +00:00
|
|
|
countMax?: number
|
2022-03-30 15:37:30 +00:00
|
|
|
icon?: string;
|
|
|
|
src?: string;
|
|
|
|
}
|
|
|
|
|
2022-11-03 16:13:45 +00:00
|
|
|
const IconWithCounter: React.FC<IIconWithCounter> = ({ icon, count, countMax, ...rest }) => {
|
2020-12-30 01:48:39 +00:00
|
|
|
return (
|
2022-03-21 18:09:01 +00:00
|
|
|
<div className='relative'>
|
2022-06-30 14:51:36 +00:00
|
|
|
<Icon id={icon} {...rest as IIcon} />
|
2022-03-21 18:09:01 +00:00
|
|
|
|
2022-04-28 21:29:15 +00:00
|
|
|
{count > 0 && (
|
2022-11-17 15:58:34 +00:00
|
|
|
<span className='absolute -top-2 -right-3'>
|
2022-11-03 16:13:45 +00:00
|
|
|
<Counter count={count} countMax={countMax} />
|
2022-11-17 09:52:56 +00:00
|
|
|
</span>
|
2022-04-28 21:29:15 +00:00
|
|
|
)}
|
2020-12-30 01:48:39 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default IconWithCounter;
|