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";
3 years ago
export declare type IconType = React.ReactNode | string;
const hrmSalaryUrl = "/spa/hrmSalary/hrmSalaryCalculateDetail/";
3 years ago
const Icon = createFromIconfontCN({
scriptUrl: [
// @ts-ignore
`${process.env.NODE_ENV === "development" ? Util.getPublicPath() : hrmSalaryUrl}css/iconfont/iconfont.js`
]
3 years ago
});
/**
*
* @param icon
*/
export const buildIcon: (
type: string,
icon: IconType,
style?: React.CSSProperties,
className?: string
3 years ago
) => 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;
};
3 years ago
export default Icon;