mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 12:08:13 +08:00
fix: 修复Tag组件status模式下的图标问题 (#6642)
- 修复图标颜色不跟随自定义color变化的问题 - 修复自定义图标过小问题 - 支持新版svg图标 Co-authored-by: jinye <jinye@baidu.com>
This commit is contained in:
parent
dacca057e2
commit
6d7d95cb04
@ -124,7 +124,7 @@
|
||||
i {
|
||||
font-size: #{px2rem(8px)};
|
||||
}
|
||||
.icon {
|
||||
.#{$ns}Tag-default-icon {
|
||||
width: var(--Tag-status-size);
|
||||
height: var(--Tag-status-size);
|
||||
top: 0;
|
||||
|
@ -114,8 +114,7 @@ export class Tag extends React.Component<TagProps> {
|
||||
color,
|
||||
icon,
|
||||
style,
|
||||
label,
|
||||
closable
|
||||
label
|
||||
} = this.props;
|
||||
|
||||
const isPresetColor =
|
||||
@ -130,21 +129,29 @@ export class Tag extends React.Component<TagProps> {
|
||||
...style
|
||||
};
|
||||
|
||||
const prevIcon = displayMode === 'status' && (
|
||||
<span className={cx('Tag--prev')}>
|
||||
{typeof icon === 'string' ? (
|
||||
getIcon(icon) ? (
|
||||
<Icon icon={icon} className="icon" />
|
||||
) : (
|
||||
generateIcon(cx, icon, 'Icon')
|
||||
)
|
||||
) : React.isValidElement(icon) ? (
|
||||
icon
|
||||
) : (
|
||||
<Icon icon="dot" className="icon" />
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
let prevIcon;
|
||||
if (displayMode === 'status') {
|
||||
let iconItem;
|
||||
if (icon) {
|
||||
if (typeof icon === 'string' && getIcon(icon)) {
|
||||
iconItem = <Icon icon={icon} className="icon" />;
|
||||
} else {
|
||||
iconItem = generateIcon(cx, icon, 'Icon');
|
||||
}
|
||||
}
|
||||
if (!iconItem) {
|
||||
iconItem = (
|
||||
<Icon icon="dot" className={cx('icon', 'Tag-default-icon')} />
|
||||
);
|
||||
}
|
||||
|
||||
const prevIconStyle = customColor ? {style: {color: customColor}} : {};
|
||||
prevIcon = (
|
||||
<span className={cx('Tag--prev')} {...prevIconStyle}>
|
||||
{iconItem}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
|
Loading…
Reference in New Issue
Block a user