You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
salary-management-oneself/src/lib/CustomIcon/index.tsx

61 lines
1.2 KiB
TypeScript

3 years ago
/**
* Icon Icon
*
*
*/
import * as React from 'react';
import { createFromIconfontCN } from '@ant-design/icons';
import { Util } from '@/utils';
export declare type IconType = React.ReactNode | string;
const Icon = createFromIconfontCN({
scriptUrl: [
// @ts-ignore
`${Util.getPublicPath()}css/iconfont/iconfont.js`,
],
});
/**
*
* @param icon
*/
export const buildIcon: (
type: string,
icon: IconType,
style?: React.CSSProperties,
className?: string,
) => React.ReactNode | null = function (
type,
icon,
style = {},
className = '',
) {
let comp;
switch (type) {
case 'IMAGE':
comp =
typeof icon === 'string' ? (
<img
src={icon}
className={className}
style={{ width: 16, height: 16, ...style }}
/>
) : (
icon
);
break;
default:
comp =
typeof icon === 'string' ? (
<Icon type={icon} style={style} className={className} />
) : (
icon
);
}
return comp;
};
export default Icon;