2022-03-21 18:09:01 +00:00
|
|
|
import React from 'react';
|
2022-04-07 18:47:06 +00:00
|
|
|
|
2022-04-28 21:29:15 +00:00
|
|
|
import Counter from '../counter/counter';
|
|
|
|
|
2022-04-07 18:47:06 +00:00
|
|
|
import SvgIcon from './svg-icon';
|
2022-03-21 18:09:01 +00:00
|
|
|
|
2022-04-28 21:29:15 +00:00
|
|
|
|
2022-04-12 13:50:39 +00:00
|
|
|
interface IIcon extends Pick<React.SVGAttributes<SVGAElement>, 'strokeWidth'> {
|
2022-03-21 18:09:01 +00:00
|
|
|
className?: string,
|
|
|
|
count?: number,
|
|
|
|
alt?: string,
|
|
|
|
src: string,
|
2022-04-07 18:47:06 +00:00
|
|
|
size?: number,
|
2022-03-21 18:09:01 +00:00
|
|
|
}
|
|
|
|
|
2022-04-07 18:47:06 +00:00
|
|
|
const Icon = ({ src, alt, count, size, ...filteredProps }: IIcon): JSX.Element => (
|
2022-04-05 14:42:19 +00:00
|
|
|
<div className='relative' data-testid='icon'>
|
2022-04-04 19:05:15 +00:00
|
|
|
{count ? (
|
2022-04-28 21:29:15 +00:00
|
|
|
<span className='absolute -top-2 -right-3'>
|
|
|
|
<Counter count={count} />
|
2022-04-04 19:05:15 +00:00
|
|
|
</span>
|
|
|
|
) : null}
|
2022-03-21 18:09:01 +00:00
|
|
|
|
2022-04-07 18:47:06 +00:00
|
|
|
<SvgIcon src={src} size={size} alt={alt} {...filteredProps} />
|
2022-04-04 19:05:15 +00:00
|
|
|
</div>
|
|
|
|
);
|
2022-03-21 18:09:01 +00:00
|
|
|
|
|
|
|
export default Icon;
|