feat: 引入iconfont组件

This commit is contained in:
lifan 2024-03-22 11:23:16 +08:00
parent 8daa0a5fbe
commit 7aa51db9b2
13 changed files with 4838 additions and 20 deletions

View File

@ -52,6 +52,7 @@
]
},
"dependencies": {
"@ant-design/icons": "^5.3.0",
"@zhst/slave": "workspace:^",
"antd": "^5.13.2"
},

View 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;

View File

@ -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>
);
};

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -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

View File

@ -0,0 +1,3 @@
.icon:hover {
color: #6accca !important;
}

View File

@ -1 +1 @@
export { default as Heart } from './heart';
export { default as IconFont } from './Iconfont';

View File

@ -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':