ant-design/components/icon/index.tsx

25 lines
614 B
TypeScript
Raw Normal View History

2016-06-28 22:22:42 +08:00
import * as React from 'react';
import classNames from 'classnames';
import omit from 'omit.js';
2016-06-22 13:18:43 +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>;
spin?: boolean;
2016-10-21 16:27:26 +08:00
style?: React.CSSProperties;
}
2017-04-06 11:51:48 +08:00
const Icon = (props: IconProps) => {
const { type, className = '', spin } = props;
const classString = classNames({
anticon: true,
'anticon-spin': !!spin || type === 'loading',
[`anticon-${type}`]: true,
}, className);
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;