Skip to content

Commit

Permalink
fix: 修复icon render svg问题
Browse files Browse the repository at this point in the history
  • Loading branch information
qkiroc committed Jul 19, 2023
1 parent fc1154a commit 8ebcce8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 15 additions & 1 deletion packages/amis-ui/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ export function Icon({
vendor,
cx: iconCx,
onClick = () => {},
onMouseEnter = () => {},
onMouseLeave = () => {},
style
}: {
icon: string;
Expand All @@ -280,7 +282,9 @@ export function Icon({
(icon.props as any).className
),
style,
onClick
onClick,
onMouseEnter,
onMouseLeave
});
}

Expand All @@ -306,6 +310,8 @@ export function Icon({
return (
<div
onClick={onClick}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
className={cx(iconContent, className, classNameProp)}
ref={refFn}
style={style}
Expand All @@ -319,6 +325,8 @@ export function Icon({
return (
<Component
onClick={onClick}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
className={cx(className, `icon-${icon}`, classNameProp)}
// @ts-ignore
icon={icon}
Expand All @@ -345,6 +353,8 @@ export function Icon({
return (
<svg
onClick={onClick}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
className={cx('icon', 'icon-object', className, classNameProp)}
style={style}
>
Expand All @@ -361,6 +371,8 @@ export function Icon({
return (
<img
onClick={onClick}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
className={cx(`${classPrefix}Icon`, className, classNameProp)}
src={icon}
style={style}
Expand All @@ -386,6 +398,8 @@ export function Icon({
return (
<i
onClick={onClick}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
className={cx(icon, className, classNameProp, iconPrefix)}
style={style}
/>
Expand Down
5 changes: 4 additions & 1 deletion packages/amis/src/renderers/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ export class Icon extends React.Component<IconProps, object> {
css,
env
} = this.props;
let icon = this.props.icon;

const icon = filter(this.props.icon, data);
if (typeof icon === 'string') {
icon = filter(this.props.icon, data);
}

return (
<>
Expand Down

0 comments on commit 8ebcce8

Please sign in to comment.