mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 18:09:22 +08:00
2e284aa017
* update warning * rm warning * replace with dev warning * fix test * fix site * Update webpack.config.js Co-authored-by: 偏右 <afc163@gmail.com> * Update webpack.config.js * fix sytax * adjust * move into function Co-authored-by: 偏右 <afc163@gmail.com>
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
/* eslint-disable camelcase */
|
|
import React from 'react';
|
|
import AntdIcon, { createFromIconfontCN } from '@ant-design/icons';
|
|
|
|
import { withThemeSuffix, removeTypeTheme, getThemeFromTypeName } from './utils';
|
|
import warning from '../../../../components/_util/devWarning';
|
|
|
|
const IconFont = createFromIconfontCN({
|
|
scriptUrl: '//at.alicdn.com/t/font_1329669_t1u72b9zk8s.js',
|
|
});
|
|
|
|
const OldIcon = props => {
|
|
const { type, theme } = props;
|
|
let computedType = type;
|
|
if (theme) {
|
|
const themeInName = getThemeFromTypeName(type);
|
|
warning(
|
|
!themeInName || theme === themeInName,
|
|
'Icon',
|
|
`The icon name '${type}' already specify a theme '${themeInName}',` +
|
|
` the 'theme' prop '${theme}' will be ignored.`,
|
|
);
|
|
}
|
|
computedType = withThemeSuffix(removeTypeTheme(computedType), theme || 'outlined');
|
|
return <IconFont {...props} type={`icon-${computedType}`} />;
|
|
};
|
|
|
|
const Icon = props => {
|
|
if (typeof props.type === 'string') {
|
|
return <OldIcon {...props} />;
|
|
}
|
|
return <AntdIcon {...props} />;
|
|
};
|
|
|
|
Icon.createFromIconfontCN = createFromIconfontCN;
|
|
|
|
export default Icon;
|