fix: 修复图标选择组件无法渲染iconfont (#6974)

Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
This commit is contained in:
qkiroc 2023-05-23 20:47:52 +08:00 committed by GitHub
parent 7f90d4ee26
commit ad3bfa8692
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -66,6 +66,9 @@
height: 100%;
}
}
&-iconfont {
margin-right: var(--sizes-size-4);
}
}
&-wrapper {

View File

@ -278,6 +278,9 @@ export function Icon({
const Component = getIcon(icon);
const isURLIcon = typeof icon === 'string' && icon?.indexOf('.') !== -1;
const isIconfont =
typeof icon === 'string' &&
(~icon?.indexOf('iconfont') || ~icon?.indexOf('fa'));
return Component ? (
<>
@ -293,6 +296,8 @@ export function Icon({
</>
) : isURLIcon ? (
<img className={cx(`${classPrefix}Icon`, className)} src={icon} />
) : isIconfont ? (
<i className={cx(icon, className)} />
) : (
<span className="text-danger"> icon {icon}</span>
);

View File

@ -147,7 +147,13 @@ export default class IconSelectControl extends React.PureComponent<
dangerouslySetInnerHTML={{__html: SvgStr[0].replace(/\\"/g, '"')}}
></div>
) : (
<Icon icon={valueTemp} className="icon" />
<Icon
icon={valueTemp}
className={cx(
`${ns}IconSelectControl-input-area-iconfont`,
'icon'
)}
/>
)
) : null}
<span className={cx(`${ns}IconSelectControl-input-icon-id`)}>