feat: 还原统一icon之后的尺寸 但复用ant design icon
fix: 修复底部客服按钮 收缩起来的样式bug
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user