ant-design/components/icon/index.tsx

23 lines
594 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;
}
export default (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} />;
2016-06-22 13:18:43 +08:00
};