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

fix: 修复底部客服按钮 收缩起来的样式bug
This commit is contained in:
zhanjunhao
2026-11-10 22:08:00 +08:00
parent c64713e24a
commit 7f6b59d3d9
6 changed files with 116 additions and 7 deletions
+24 -3
View File
@@ -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');
+18 -1
View File
@@ -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;
}