feat: icon支持自定义样式 (#6379)

Co-authored-by: sarding <hongfuquan@baidu.com>
This commit is contained in:
sarding 2023-03-17 10:04:24 +08:00 committed by GitHub
parent 351571c4c4
commit 30055e438b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,8 @@ import {
filter,
IconCheckedSchema,
autobind,
createObject
createObject,
insertCustomStyle
} from 'amis-core';
import {BaseSchema, SchemaTpl} from '../Schema';
import {BadgeObject, withBadge} from 'amis-ui';
@ -76,10 +77,27 @@ export class Icon extends React.Component<IconProps, object> {
}
render() {
const {vendor, classnames: cx, className, style, data} = this.props;
const {
vendor,
classnames: cx,
className,
style,
data,
css,
id
} = this.props;
let icon = this.props.icon;
icon = filter(icon, data);
insertCustomStyle(
css,
[
{
key: 'className',
value: className
}
],
id
);
if (typeof icon !== 'string') {
if (
@ -108,6 +126,8 @@ export class Icon extends React.Component<IconProps, object> {
return;
}
icon = filter(icon, data);
let CustomIcon = getIcon(icon);
if (CustomIcon) {
return (