fix: 修复Tag组件status模式下的图标问题 (#6642)

- 修复图标颜色不跟随自定义color变化的问题
- 修复自定义图标过小问题
- 支持新版svg图标

Co-authored-by: jinye <jinye@baidu.com>
This commit is contained in:
lmaomaoz 2023-04-18 19:46:35 +08:00 committed by GitHub
parent dacca057e2
commit 6d7d95cb04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 18 deletions

View File

@ -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;

View File

@ -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