mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 06:09:34 +08:00
37 lines
999 B
TypeScript
Executable File
37 lines
999 B
TypeScript
Executable File
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
import omit from 'omit.js';
|
|
import { antDesignIcons } from '@ant-design/icons';
|
|
import AntdIcon from '@ant-design/icons-react';
|
|
import CustomIcon, { create } from './CustomIcon';
|
|
|
|
AntdIcon.library.add(...antDesignIcons);
|
|
|
|
export interface IconProps {
|
|
type: string;
|
|
className?: string;
|
|
title?: string;
|
|
onClick?: React.MouseEventHandler<any>;
|
|
spin?: boolean;
|
|
style?: React.CSSProperties;
|
|
}
|
|
|
|
const Icon: React.SFC<IconProps> = (props: IconProps) => {
|
|
const { type, className = '', spin } = props;
|
|
const classString = classNames({
|
|
anticon: true,
|
|
'anticon-spin': !!spin || type === 'loading',
|
|
}, className);
|
|
return <AntdIcon {...omit(props, ['spin'])} className={classString}/>;
|
|
};
|
|
|
|
export type IconType = React.SFC<IconProps> & {
|
|
CustomIcon: typeof CustomIcon;
|
|
create: typeof create;
|
|
};
|
|
|
|
(Icon as IconType).CustomIcon = CustomIcon;
|
|
(Icon as IconType).create = create;
|
|
|
|
export default Icon as IconType;
|