feat: 引入iconfont组件
This commit is contained in:
parent
8daa0a5fbe
commit
7aa51db9b2
@ -52,6 +52,7 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^5.3.0",
|
||||
"@zhst/slave": "workspace:^",
|
||||
"antd": "^5.13.2"
|
||||
},
|
||||
|
50
packages/icon/src/Iconfont.tsx
Normal file
50
packages/icon/src/Iconfont.tsx
Normal file
@ -0,0 +1,50 @@
|
||||
import { createFromIconfontCN } from '@ant-design/icons';
|
||||
import React from 'react';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
interface IconFontProps {
|
||||
styles?: React.CSSProperties;
|
||||
icon?: string;
|
||||
size?: number;
|
||||
color?: string;
|
||||
title?: string;
|
||||
className?: string;
|
||||
onIconClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
||||
children?: ReactNode;
|
||||
active?: boolean;
|
||||
disable?: boolean;
|
||||
}
|
||||
const Icon = createFromIconfontCN({
|
||||
scriptUrl: require('./font_1739270_pqkfa2ldec/iconfont.js'),
|
||||
});
|
||||
const IconFont: React.FC<IconFontProps> = (props) => {
|
||||
const {
|
||||
title = '',
|
||||
styles = {},
|
||||
icon,
|
||||
size = 14,
|
||||
onIconClick,
|
||||
children,
|
||||
active = false,
|
||||
color = '',
|
||||
} = props || {};
|
||||
return (
|
||||
<Icon
|
||||
title={title}
|
||||
onClick={(e) => {
|
||||
onIconClick && onIconClick(e);
|
||||
}}
|
||||
style={{
|
||||
...styles,
|
||||
cursor: 'pointer',
|
||||
fontSize: size,
|
||||
color,
|
||||
...(active ? { color: '#09f' } : {}),
|
||||
}}
|
||||
type={icon}
|
||||
>
|
||||
{children}
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
export default IconFont;
|
@ -1,11 +1,11 @@
|
||||
import React from 'react';
|
||||
import { Heart } from '@zhst/icon';
|
||||
import { IconFont } from '@zhst/icon';
|
||||
|
||||
const demo = () => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Heart size={20} />
|
||||
<IconFont icon="icon-daoru1" />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
1743
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.css
Normal file
1743
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.css
Normal file
File diff suppressed because it is too large
Load Diff
1
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.js
Normal file
1
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.js
Normal file
File diff suppressed because one or more lines are too long
3033
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.json
Normal file
3033
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.ttf
Normal file
BIN
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.ttf
Normal file
Binary file not shown.
BIN
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.woff
Normal file
BIN
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.woff
Normal file
Binary file not shown.
BIN
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.woff2
Normal file
BIN
packages/icon/src/font_1739270_pqkfa2ldec/iconfont.woff2
Normal file
Binary file not shown.
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Created by jiangzhixiong on 2024/03/22
|
||||
*/
|
||||
|
||||
import React, { FC } from 'react'
|
||||
|
||||
interface Iheart {
|
||||
size?: string | number
|
||||
}
|
||||
|
||||
const Heart: FC<Iheart> = (props) => {
|
||||
return (
|
||||
<svg style={{ width: `${props.size}px`, height: '100%' }} t="1711074821835" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="13154" width="200" height="200"><path d="M322.56 164.266667c-113.152 0-205.226667 92.16-205.226667 206.506666 0 138.666667 64 249.813333 144.64 332.373334 80.938667 82.944 176.64 134.912 233.898667 154.453333l0.341333 0.128c2.730667 0.981333 8.490667 2.005333 15.786667 2.005333 7.296 0 13.056-1.024 15.786667-2.005333l0.341333-0.128c57.258667-19.541333 152.96-71.509333 233.941333-154.453333 80.554667-82.56 144.597333-193.706667 144.597334-332.373334 0-114.346667-92.074667-206.506667-205.226667-206.506666a203.946667 203.946667 0 0 0-163.754667 82.645333 32 32 0 0 1-51.370666 0A203.349333 203.349333 0 0 0 322.56 164.266667zM53.333333 370.773333c0-149.333333 120.405333-270.506667 269.226667-270.506666 74.112 0 141.013333 30.122667 189.44 78.72a267.349333 267.349333 0 0 1 189.44-78.72c148.821333 0 269.226667 121.173333 269.226667 270.506666 0 160-74.24 286.293333-162.816 377.088-88.149333 90.282667-192.426667 147.541333-258.901334 170.24a114.986667 114.986667 0 0 1-36.949333 5.632c-11.818667 0-25.216-1.493333-36.949333-5.589333-66.432-22.741333-170.752-80-258.901334-170.282667C127.530667 657.066667 53.333333 530.773333 53.333333 370.773333z" p-id="13155"></path></svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default Heart
|
3
packages/icon/src/index.less
Normal file
3
packages/icon/src/index.less
Normal file
@ -0,0 +1,3 @@
|
||||
.icon:hover {
|
||||
color: #6accca !important;
|
||||
}
|
@ -1 +1 @@
|
||||
export { default as Heart } from './heart';
|
||||
export { default as IconFont } from './Iconfont';
|
||||
|
@ -167,6 +167,10 @@ importers:
|
||||
specifier: ^6.21.1
|
||||
version: 6.21.3(react-dom@18.2.0)(react@18.2.0)
|
||||
|
||||
packages/icon: {}
|
||||
|
||||
packages/map: {}
|
||||
|
||||
packages/material:
|
||||
dependencies:
|
||||
'@ant-design/icons':
|
||||
|
Loading…
Reference in New Issue
Block a user