bigbuffet-rw/app/soapbox/components/ui/icon/icon.tsx

29 lines
639 B
TypeScript
Raw Normal View History

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