feat: 还原统一icon之后的尺寸 但复用ant design icon

fix: 修复底部客服按钮 收缩起来的样式bug
This commit is contained in:
zhanjunhao
2026-11-10 22:08:00 +08:00
parent 32be8094dc
commit 3297cca457
6 changed files with 116 additions and 7 deletions
+45 -2
View File
@@ -55,7 +55,8 @@ test('common action glyphs render Ant Design icons with their existing accessibl
);
assert.match(html, /app-action-icon/);
assert.match(html, /anticon/);
assert.match(html, /font-size:18px/);
assert.match(html, /--action-icon-width:18px/);
assert.match(html, /--action-icon-height:18px/);
assert.ok(html.includes(`aria-label="${name}"`));
assert.doesNotMatch(html, /lucide/);
}
@@ -76,6 +77,8 @@ test('action icons preserve refs, class names, explicit style, symbolic size and
assert.equal(node.type, ant.CopyOutlined);
assert.equal(node.ref, ref);
assert.equal(node.props.style.fontSize, 22);
assert.equal(node.props.style['--action-icon-width'], '20px');
assert.equal(node.props.style['--action-icon-height'], '20px');
assert.equal(node.props.style.color, 'currentColor');
assert.match(node.props.className, /custom/);
assert.equal(node.props.strokeWidth, undefined);
@@ -105,7 +108,7 @@ test('legacy icon names retain size presets and now resolve to Ant Design', asyn
const html = renderToStaticMarkup(
React.createElement(legacy.IconSearch, { size: 'small' }),
);
assert.match(html, /font-size:14px/);
assert.match(html, /--action-icon-width:14px/);
assert.match(html, /anticon-search/);
assert.doesNotMatch(html, /lucide/);
assert.match(
@@ -113,3 +116,43 @@ test('legacy icon names retain size presets and now resolve to Ant Design', asyn
/lucide/,
);
});
test('action icons preserve SVG dimensions independently of font size and retain width overrides', () => {
assert.equal(
icons.Search.render({}, null).props.style['--action-icon-width'],
'24px',
);
const node = icons.Copy.render(
{
size: 16,
width: 20,
height: '1.5em',
style: { fontSize: 48, width: 12 },
},
null,
);
assert.equal(node.props.style['--action-icon-width'], '20px');
assert.equal(node.props.style['--action-icon-height'], '1.5em');
assert.equal(node.props.style.fontSize, 48);
assert.equal(node.props.style.width, 12);
assert.equal(node.props.width, undefined);
assert.equal(node.props.height, undefined);
assert.equal(
icons.Plus.render({ size: 0 }, null).props.style['--action-icon-width'],
'0px',
);
});
test('Ant chevrons keep the compact original glyph proportions without changing their layout box', () => {
for (const name of [
'ChevronDown',
'ChevronUp',
'ChevronLeft',
'ChevronRight',
]) {
const node = icons[name].render({ size: 16 }, null);
assert.equal(node.props.style['--action-icon-width'], '16px');
assert.equal(node.props.style['--action-icon-height'], '16px');
assert.equal(node.props.style['--action-icon-scale'], 0.65);
}
});