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> {
|
2023-02-15 13:26:27 -08:00
|
|
|
count: number
|
2022-11-03 09:13:45 -07:00
|
|
|
countMax?: number
|
2023-02-15 13:26:27 -08:00
|
|
|
icon?: string
|
|
|
|
src?: string
|
2022-03-30 08:37:30 -07:00
|
|
|
}
|
|
|
|
|
2022-11-03 09:13:45 -07:00
|
|
|
const IconWithCounter: React.FC<IIconWithCounter> = ({ icon, count, countMax, ...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 && (
|
2022-11-17 07:58:34 -08:00
|
|
|
<span className='absolute -top-2 -right-3'>
|
2022-11-03 09:13:45 -07:00
|
|
|
<Counter count={count} countMax={countMax} />
|
2022-11-17 01:52:56 -08:00
|
|
|
</span>
|
2022-04-28 14:29:15 -07:00
|
|
|
)}
|
2020-12-29 17:48:39 -08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default IconWithCounter;
|