forked from alibaba/lowcode-engine-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-icon.tsx
More file actions
38 lines (30 loc) · 916 Bytes
/
custom-icon.tsx
File metadata and controls
38 lines (30 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Icon } from '@alifd/next';
import * as React from 'react';
import { useEffect } from 'react';
const ICON_URL = '//at.alicdn.com/t/a/font_2761185_ccl8ob63gmj.js';
let CustomIcon: any;
document.addEventListener('DOMContentLoaded', function () {
// console.log('3 seconds passed');
CustomIcon = Icon.createFromIconfontCN({
scriptUrl: ICON_URL,
});
});
interface IconProps {
type: string;
size?: number | 'small' | 'xxs' | 'xs' | 'medium' | 'large' | 'xl' | 'xxl' | 'xxxl' | 'inherit';
className?: string;
style?: any;
}
export default (props: IconProps) => {
const { type, size, className = '', style = {} } = props;
useEffect(() => {
if(!CustomIcon){
CustomIcon = Icon.createFromIconfontCN({
scriptUrl: ICON_URL,
});
}
}, []);
return (
<>{CustomIcon && <CustomIcon type={type} size={size} className={className} style={style} />}</>
);
};