fix(amis-editor): icon-button-group支持icon字体

This commit is contained in:
wibetter 2023-05-29 19:40:18 +08:00
parent 1ca4a73b93
commit b20926426e
2 changed files with 10 additions and 2 deletions

View File

@ -11,11 +11,16 @@
margin: 0 !important;
padding: 0 !important;
width: 20px;
min-height: 20px;
}
&.is-active {
svg {
fill: $Editor-theme-color;
color: $Editor-theme-color;
}
i {
color: $Editor-theme-color;
}
}
}

View File

@ -2,12 +2,13 @@
* @file icon按钮组
*/
import React from 'react';
import {FormItem, Button, Icon, FormControlProps} from 'amis';
import {FormItem, Button, Icon, hasIcon, FormControlProps} from 'amis';
import cx from 'classnames';
export interface ButtonGroupControlProps extends FormControlProps {
options?: Array<{
label: string;
iconFont?: string;
icon: string;
value: string;
iconClassName?: string;
@ -35,11 +36,13 @@ export default class ButtonGroupControl extends React.Component<ButtonGroupContr
tooltip={item.label}
active={value === item.value}
>
{item.icon ? (
{hasIcon(item.icon) ? (
<Icon
icon={item.icon}
className={cx('icon', item.iconClassName)}
/>
) : item.icon ? (
<i className={item.icon}></i>
) : (
item.label
)}