feat: 还原统一icon之后的尺寸 但复用ant design icon
fix: 修复底部客服按钮 收缩起来的样式bug
This commit is contained in:
@@ -145,3 +145,19 @@
|
||||
| 浏览器 | 浅深色 × 桌面/移动端,136 项对齐检查、真实组件交互和富文本加粗通过 |
|
||||
| 源码契约 | 151 个文件的 API 与操作处理属性对照通过,图标 JSX 别名单独归一化 |
|
||||
| 差异检查 | `git diff --check` 通过 |
|
||||
|
||||
## 11. 操作图标尺寸回归修复(2026-11-10)
|
||||
|
||||
用户反馈客服浮钮的小箭头变大后,重新对照第 10 节改造前快照,并检查当前 Ant Design 6 环境。发现旧适配只用 `fontSize` 控制 Ant 图标,未完整保留 Lucide SVG 的宽高契约:无 `size` 时由原来的 24px 变成继承文字字号,`w-*` / `h-*`、局部 CSS 尺寸只改变外层 span,内部 SVG 仍是 1em;部分旧 `style.fontSize` 又意外改变了实际图标尺寸。另有侧栏的直接 SVG 旋转选择器未覆盖 Ant span。客服按钮本身的 46px / 20px、主图标 22px 和箭头占位 16px 没有变化,视觉差异来自 Ant 箭头更大的实心轮廓。
|
||||
|
||||
- `ActionIcons.js` 保留 Ant 图形,独立传递宽高变量;默认尺寸恢复为原 Lucide 的 24px,旧兼容入口仍默认为 16px。支持数字尺寸、预设、显式 width / height、行内样式及 CSS 工具类覆盖,字体大小不再意外改变 SVG 占位。
|
||||
- `action-icons.css` 的默认宽高放在 Tailwind components 层,内部 SVG 填满外层尺寸;四向折线箭头按实测缩小到 0.65,保留原占位和点击范围。右上箭头保留 45 度方向并约束旋转后的图形,避免超出原尺寸。
|
||||
- `center-layout.css` 的展开旋转同时匹配 SVG 和 Ant 图标 span。页面业务、客服分配/释放逻辑、主题状态和依赖版本不变;新增尺寸契约回归用例。
|
||||
|
||||
尺寸清单覆盖 220 个源码文件中的 731 个静态及条件分支用例。Playwright 使用 `channel: 'chrome'`、`headless: true`,桌面 1920×1000 / 移动 393×851、浅色 / 深色共 2,924 次新旧占位宽高对照通过,另检查搜索按钮、模型复制按钮、顶栏及侧栏旋转。实际客服组件的接口由本地 mock 提供,展开态、收起态、面板打开/关闭、图标居中及关闭后焦点归还均通过。此处验证源码提取尺寸和真实组件,不代表真实账号的全站业务或逐页像素验收,也不要求两套图形的路径完全相同。
|
||||
|
||||
本轮未启动有头窗口,未调用 bringToFront、窗口置顶、激活或操作系统鼠标键盘;未执行生产构建或生产环境测试。重任务串行、单测并发 1,Node 堆上限 2,944MB,持续采样 CPU、可用物理内存和提交空间。回归脚本、截图、新旧尺寸和资源记录仅保存在忽略目录 `report/ui-unification/icon-size-review/`。
|
||||
|
||||
最终验证:重新应用修复后,全量串行单测 670/670 通过,失败、跳过、取消均为 0;全仓 ESLint 零错误、零警告,Prettier、`check:ui` 和 `git diff --check` 均通过。浏览器尺寸对照与客服交互在重新应用后再次运行通过,运行错误为 0。
|
||||
|
||||
客服收起态追加回归:此前使用 reduced motion 的静态 hover 检查不足以验证用户反馈的抖动。当前明确禁止收起容器及两个按钮在默认、hover、active、focus 状态发生 transform、translate、scale、transition 或 animation;内部按钮的白色焦点描边改到整个容器,避免中缝横线。真实 Chrome 无头模式使用 `reducedMotion: 'no-preference'`,DPR 1 / 1.25 / 1.5 × 桌面 / 移动 × 浅色 / 深色,共 12 组、84 个交互状态,采样 1,735 帧,容器和按钮位移均为 0;中缝 8,456 次像素检查无白线。接口由本地 mock 提供,展开、打开、关闭与焦点归还通过;未启动有头窗口,不作无干扰后台有头运行承诺,未执行生产构建或生产环境测试。证据为同一忽略目录中的 `motion-regression.json` 及截图。
|
||||
|
||||
@@ -134,11 +134,18 @@ import {
|
||||
ZoomOutOutlined,
|
||||
} from '@ant-design/icons';
|
||||
|
||||
const iconLength = (value) =>
|
||||
typeof value === 'number' || /^\d+(?:\.\d+)?$/.test(value)
|
||||
? `${value}px`
|
||||
: value;
|
||||
|
||||
// Keep existing icon props and DOM refs while rendering the Ant Design glyph.
|
||||
const createActionIcon = (Icon, displayName, options = {}) => {
|
||||
const Component = forwardRef(function ActionIcon(
|
||||
{
|
||||
size,
|
||||
width,
|
||||
height,
|
||||
color,
|
||||
className = '',
|
||||
style,
|
||||
@@ -149,8 +156,10 @@ const createActionIcon = (Icon, displayName, options = {}) => {
|
||||
},
|
||||
ref,
|
||||
) {
|
||||
const fontSize =
|
||||
{ small: 14, default: 16, large: 20, 'extra-large': 24 }[size] ?? size;
|
||||
const dimension =
|
||||
{ small: 14, default: 16, large: 20, 'extra-large': 24 }[size] ??
|
||||
size ??
|
||||
24;
|
||||
const Glyph =
|
||||
fill && fill !== 'none' && options.filled ? options.filled : Icon;
|
||||
return React.createElement(Glyph, {
|
||||
@@ -158,7 +167,14 @@ const createActionIcon = (Icon, displayName, options = {}) => {
|
||||
ref,
|
||||
rotate: props.rotate ?? options.rotate,
|
||||
className: ['app-action-icon', className].filter(Boolean).join(' '),
|
||||
style: { fontSize, color, ...style },
|
||||
// SVG dimensions used to be independent of the inherited font size.
|
||||
style: {
|
||||
'--action-icon-width': iconLength(width ?? dimension),
|
||||
'--action-icon-height': iconLength(height ?? dimension),
|
||||
'--action-icon-scale': options.scale,
|
||||
color,
|
||||
...style,
|
||||
},
|
||||
});
|
||||
});
|
||||
Component.displayName = displayName;
|
||||
@@ -208,18 +224,22 @@ export const Check = /* @__PURE__ */ createActionIcon(CheckOutlined, 'Check');
|
||||
export const ChevronDown = /* @__PURE__ */ createActionIcon(
|
||||
DownOutlined,
|
||||
'ChevronDown',
|
||||
{ scale: 0.65 },
|
||||
);
|
||||
export const ChevronUp = /* @__PURE__ */ createActionIcon(
|
||||
UpOutlined,
|
||||
'ChevronUp',
|
||||
{ scale: 0.65 },
|
||||
);
|
||||
export const ChevronLeft = /* @__PURE__ */ createActionIcon(
|
||||
LeftOutlined,
|
||||
'ChevronLeft',
|
||||
{ scale: 0.65 },
|
||||
);
|
||||
export const ChevronRight = /* @__PURE__ */ createActionIcon(
|
||||
RightOutlined,
|
||||
'ChevronRight',
|
||||
{ scale: 0.65 },
|
||||
);
|
||||
export const ArrowRight = /* @__PURE__ */ createActionIcon(
|
||||
ArrowRightOutlined,
|
||||
@@ -242,6 +262,7 @@ export const ArrowUpRight = /* @__PURE__ */ createActionIcon(
|
||||
'ArrowUpRight',
|
||||
{
|
||||
rotate: 45,
|
||||
scale: Math.SQRT1_2,
|
||||
},
|
||||
);
|
||||
export const Eye = /* @__PURE__ */ createActionIcon(EyeOutlined, 'Eye');
|
||||
|
||||
@@ -109,6 +109,20 @@
|
||||
border-radius: 10px 0 0 10px;
|
||||
background: var(--cs-primary);
|
||||
}
|
||||
.cs-float-tab:is(:hover, :focus-within) {
|
||||
background: var(--cs-primary-hover);
|
||||
}
|
||||
/* The collapsed tab is one stationary surface, including during interaction. */
|
||||
.cs-float-tab,
|
||||
.cs-float-tab:is(:hover, :active, :focus-within),
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn,
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn:is(:hover, :active, :focus-visible) {
|
||||
transform: none;
|
||||
translate: none;
|
||||
scale: none;
|
||||
transition: none;
|
||||
animation: none;
|
||||
}
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -126,9 +140,12 @@
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn:not(:disabled):hover,
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn:not(:disabled):active {
|
||||
color: var(--cs-on-primary);
|
||||
background: var(--cs-primary-hover);
|
||||
background: transparent;
|
||||
}
|
||||
.cs-float-tab .cs-float-tab-action.ant-btn:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
.cs-float-tab:has(.cs-float-tab-action:focus-visible) {
|
||||
outline: 2px solid var(--cs-on-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/* Native action buttons share Ant Button's content alignment. Page layout,
|
||||
* responsive visibility and explicit spacing utilities keep their precedence. */
|
||||
@layer tailwind-components {
|
||||
.app-action-icon {
|
||||
width: var(--action-icon-width);
|
||||
height: var(--action-icon-height);
|
||||
}
|
||||
|
||||
.app-action-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -9,6 +14,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
.app-action-icon > svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
scale: var(--action-icon-scale, 1);
|
||||
}
|
||||
|
||||
.ant-btn > .ant-btn-icon,
|
||||
.ant-btn .app-action-icon {
|
||||
display: inline-flex;
|
||||
|
||||
@@ -94,7 +94,7 @@ html.dark .ui-center-sidebar {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ui-org-group-toggle[aria-expanded='true'] > svg {
|
||||
.ui-org-group-toggle[aria-expanded='true'] > :is(svg, .app-action-icon) {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user