2017-11-17 14:38:54 +08:00
|
|
|
import * as React from 'react';
|
2016-10-08 15:09:56 +08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import omit from 'omit.js';
|
2016-06-22 13:18:43 +08:00
|
|
|
|
2016-08-19 17:11:06 +08:00
|
|
|
export interface IconProps {
|
|
|
|
type: string;
|
|
|
|
className?: string;
|
2016-08-22 17:26:14 +08:00
|
|
|
title?: string;
|
2016-10-19 17:51:33 +08:00
|
|
|
onClick?: React.MouseEventHandler<any>;
|
2016-10-08 15:09:56 +08:00
|
|
|
spin?: boolean;
|
2016-10-21 16:27:26 +08:00
|
|
|
style?: React.CSSProperties;
|
2016-08-19 17:11:06 +08:00
|
|
|
}
|
|
|
|
|
2017-04-06 11:51:48 +08:00
|
|
|
const Icon = (props: IconProps) => {
|
2016-10-08 15:09:56 +08:00
|
|
|
const { type, className = '', spin } = props;
|
|
|
|
const classString = classNames({
|
|
|
|
anticon: true,
|
|
|
|
'anticon-spin': !!spin || type === 'loading',
|
|
|
|
[`anticon-${type}`]: true,
|
2016-11-30 10:20:23 +08:00
|
|
|
}, className);
|
2016-10-08 15:09:56 +08:00
|
|
|
return <i {...omit(props, ['type', 'spin'])} className={classString} />;
|
2017-04-06 03:41:03 +08:00
|
|
|
};
|
2017-04-06 02:50:12 +08:00
|
|
|
|
2017-04-06 11:51:48 +08:00
|
|
|
export default Icon;
|