2019-03-19 20:58:21 +08:00
|
|
|
import React, { memo } from 'react';
|
2017-06-04 10:40:14 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2016-05-20 21:37:19 +08:00
|
|
|
import cx from 'classnames';
|
2023-02-21 21:29:51 +08:00
|
|
|
import { omit } from 'radash';
|
2022-07-04 23:27:46 +08:00
|
|
|
import Styled from './styles';
|
2016-05-20 21:37:19 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
iconName: PropTypes.string.isRequired,
|
|
|
|
prependIconName: PropTypes.string,
|
2022-07-04 23:27:46 +08:00
|
|
|
rotate: PropTypes.bool,
|
2023-09-11 21:12:37 +08:00
|
|
|
className: PropTypes.string,
|
2023-10-04 22:43:10 +08:00
|
|
|
color: PropTypes.string,
|
2016-05-20 21:37:19 +08:00
|
|
|
};
|
|
|
|
|
2019-03-19 20:58:21 +08:00
|
|
|
const Icon = ({
|
2024-06-11 21:05:08 +08:00
|
|
|
className = '',
|
|
|
|
prependIconName = 'icon-bbb-',
|
2019-03-19 20:58:21 +08:00
|
|
|
iconName,
|
2024-06-11 21:05:08 +08:00
|
|
|
rotate = false,
|
|
|
|
color = undefined,
|
2019-03-19 20:58:21 +08:00
|
|
|
...props
|
|
|
|
}) => (
|
2022-07-04 23:27:46 +08:00
|
|
|
<Styled.Icon
|
2023-10-04 22:43:10 +08:00
|
|
|
color={color}
|
2017-10-11 06:08:51 +08:00
|
|
|
className={cx(className, [prependIconName, iconName].join(''))}
|
2019-03-19 20:58:21 +08:00
|
|
|
// ToastContainer from react-toastify passes a useless closeToast prop here
|
2023-02-21 21:29:51 +08:00
|
|
|
{...omit(props, ['closeToast', 'animations', 'loading'])}
|
2022-07-04 23:27:46 +08:00
|
|
|
$rotate={rotate}
|
2017-10-11 06:08:51 +08:00
|
|
|
/>
|
2019-03-19 20:58:21 +08:00
|
|
|
);
|
2017-10-23 20:25:05 +08:00
|
|
|
|
2019-03-19 20:58:21 +08:00
|
|
|
export default memo(Icon);
|
2016-05-20 21:37:19 +08:00
|
|
|
|
|
|
|
Icon.propTypes = propTypes;
|