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');
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user