From 30055e438b46e5ba990ed7920eec7305498a9fde Mon Sep 17 00:00:00 2001 From: sarding <37691952+sarding@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:04:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20icon=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A0=B7=E5=BC=8F=20(#6379)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sarding --- packages/amis/src/renderers/Icon.tsx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/amis/src/renderers/Icon.tsx b/packages/amis/src/renderers/Icon.tsx index 39d8d0a9c..fc340e753 100644 --- a/packages/amis/src/renderers/Icon.tsx +++ b/packages/amis/src/renderers/Icon.tsx @@ -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 { } 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 { return; } + icon = filter(icon, data); + let CustomIcon = getIcon(icon); if (CustomIcon) { return (