2022-09-23 14:31:16 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2023-11-15 11:46:17 +08:00
|
|
|
import { Keyframes, unit } from '@ant-design/cssinjs';
|
2024-04-08 14:04:08 +08:00
|
|
|
|
2022-09-23 14:31:16 +08:00
|
|
|
import { resetComponent } from '../../style';
|
2023-03-20 10:28:20 +08:00
|
|
|
import { initFadeMotion } from '../../style/motion/fade';
|
2022-11-28 23:08:07 +08:00
|
|
|
import { initMotion } from '../../style/motion/motion';
|
2023-11-15 11:46:17 +08:00
|
|
|
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
|
2023-11-29 17:23:45 +08:00
|
|
|
import { genStyleHooks, mergeToken } from '../../theme/internal';
|
2023-03-20 10:28:20 +08:00
|
|
|
import getOffset from '../util';
|
2022-09-23 14:31:16 +08:00
|
|
|
|
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
|
|
|
export interface ComponentToken {
|
2023-11-15 11:46:17 +08:00
|
|
|
/**
|
|
|
|
* Offset of the badge dot in a circular button
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
dotOffsetInCircle: number;
|
|
|
|
/**
|
|
|
|
* Offset of the badge dot in a square button
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
dotOffsetInSquare: number;
|
2022-09-23 14:31:16 +08:00
|
|
|
}
|
|
|
|
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 组件的 Token
|
|
|
|
* @descEN Token for FloatButton component
|
|
|
|
*/
|
2022-09-23 14:31:16 +08:00
|
|
|
type FloatButtonToken = FullToken<'FloatButton'> & {
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 颜色
|
|
|
|
* @descEN Color of FloatButton
|
|
|
|
*/
|
2022-09-23 14:31:16 +08:00
|
|
|
floatButtonColor: string;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 背景颜色
|
|
|
|
* @descEN Background color of FloatButton
|
|
|
|
*/
|
2022-09-23 14:31:16 +08:00
|
|
|
floatButtonBackgroundColor: string;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 悬停背景颜色
|
|
|
|
* @descEN Hover background color of FloatButton
|
|
|
|
*/
|
2022-09-23 14:31:16 +08:00
|
|
|
floatButtonHoverBackgroundColor: string;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 字体大小
|
|
|
|
* @descEN Font size of FloatButton
|
|
|
|
*/
|
2022-09-23 14:31:16 +08:00
|
|
|
floatButtonFontSize: number;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 尺寸
|
|
|
|
* @descEN Size of FloatButton
|
|
|
|
*/
|
2022-09-23 14:31:16 +08:00
|
|
|
floatButtonSize: number;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 图标尺寸
|
|
|
|
* @descEN Icon size of FloatButton
|
|
|
|
*/
|
2023-11-15 11:46:17 +08:00
|
|
|
floatButtonIconSize: number | string;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 主体尺寸
|
|
|
|
* @descEN Body size of FloatButton
|
|
|
|
*/
|
2023-11-15 11:46:17 +08:00
|
|
|
floatButtonBodySize: number | string;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 主体内间距
|
|
|
|
* @descEN Body padding of FloatButton
|
|
|
|
*/
|
2023-03-20 10:28:20 +08:00
|
|
|
floatButtonBodyPadding: number;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 徽标偏移量
|
|
|
|
* @descEN Offset of badge
|
|
|
|
*/
|
2023-11-15 11:46:17 +08:00
|
|
|
badgeOffset: number | string;
|
2022-09-23 14:31:16 +08:00
|
|
|
|
|
|
|
// Position
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 底部内边距
|
|
|
|
* @descEN Bottom inset of FloatButton
|
|
|
|
*/
|
2022-09-23 14:31:16 +08:00
|
|
|
floatButtonInsetBlockEnd: number;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc FloatButton 右侧内边距
|
|
|
|
* @descEN Right inset of FloatButton
|
|
|
|
*/
|
2022-09-23 14:31:16 +08:00
|
|
|
floatButtonInsetInlineEnd: number;
|
|
|
|
};
|
|
|
|
|
2022-11-28 23:08:07 +08:00
|
|
|
const initFloatButtonGroupMotion = (token: FloatButtonToken) => {
|
|
|
|
const { componentCls, floatButtonSize, motionDurationSlow, motionEaseInOutCirc } = token;
|
2022-09-23 14:31:16 +08:00
|
|
|
const groupPrefixCls = `${componentCls}-group`;
|
|
|
|
const moveDownIn = new Keyframes('antFloatButtonMoveDownIn', {
|
|
|
|
'0%': {
|
2023-11-15 11:46:17 +08:00
|
|
|
transform: `translate3d(0, ${unit(floatButtonSize)}, 0)`,
|
2022-09-23 14:31:16 +08:00
|
|
|
transformOrigin: '0 0',
|
|
|
|
opacity: 0,
|
|
|
|
},
|
|
|
|
'100%': {
|
|
|
|
transform: 'translate3d(0, 0, 0)',
|
|
|
|
transformOrigin: '0 0',
|
|
|
|
opacity: 1,
|
|
|
|
},
|
|
|
|
});
|
2023-03-20 10:28:20 +08:00
|
|
|
|
2022-09-23 14:31:16 +08:00
|
|
|
const moveDownOut = new Keyframes('antFloatButtonMoveDownOut', {
|
|
|
|
'0%': {
|
|
|
|
transform: 'translate3d(0, 0, 0)',
|
|
|
|
transformOrigin: '0 0',
|
|
|
|
opacity: 1,
|
|
|
|
},
|
|
|
|
'100%': {
|
2023-11-15 11:46:17 +08:00
|
|
|
transform: `translate3d(0, ${unit(floatButtonSize)}, 0)`,
|
2022-09-23 14:31:16 +08:00
|
|
|
transformOrigin: '0 0',
|
|
|
|
opacity: 0,
|
|
|
|
},
|
|
|
|
});
|
2022-11-28 23:08:07 +08:00
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
[`${groupPrefixCls}-wrap`]: {
|
|
|
|
...initMotion(`${groupPrefixCls}-wrap`, moveDownIn, moveDownOut, motionDurationSlow, true),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
[`${groupPrefixCls}-wrap`]: {
|
|
|
|
[`
|
|
|
|
&${groupPrefixCls}-wrap-enter,
|
|
|
|
&${groupPrefixCls}-wrap-appear
|
|
|
|
`]: {
|
|
|
|
opacity: 0,
|
|
|
|
animationTimingFunction: motionEaseInOutCirc,
|
|
|
|
},
|
|
|
|
[`&${groupPrefixCls}-wrap-leave`]: {
|
|
|
|
animationTimingFunction: motionEaseInOutCirc,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Group ==============================
|
|
|
|
const floatButtonGroupStyle: GenerateStyle<FloatButtonToken, CSSObject> = (token) => {
|
2023-03-20 10:28:20 +08:00
|
|
|
const {
|
|
|
|
antCls,
|
|
|
|
componentCls,
|
|
|
|
floatButtonSize,
|
|
|
|
margin,
|
|
|
|
borderRadiusLG,
|
|
|
|
borderRadiusSM,
|
|
|
|
badgeOffset,
|
|
|
|
floatButtonBodyPadding,
|
2024-08-09 22:22:45 +08:00
|
|
|
zIndexPopupBase,
|
2023-11-15 11:46:17 +08:00
|
|
|
calc,
|
2023-03-20 10:28:20 +08:00
|
|
|
} = token;
|
2022-11-28 23:08:07 +08:00
|
|
|
const groupPrefixCls = `${componentCls}-group`;
|
2022-09-23 14:31:16 +08:00
|
|
|
return {
|
|
|
|
[groupPrefixCls]: {
|
|
|
|
...resetComponent(token),
|
2024-08-09 22:22:45 +08:00
|
|
|
zIndex: zIndexPopupBase,
|
2022-09-23 14:31:16 +08:00
|
|
|
display: 'block',
|
|
|
|
border: 'none',
|
|
|
|
position: 'fixed',
|
|
|
|
width: floatButtonSize,
|
|
|
|
height: 'auto',
|
|
|
|
boxShadow: 'none',
|
|
|
|
minHeight: floatButtonSize,
|
|
|
|
insetInlineEnd: token.floatButtonInsetInlineEnd,
|
|
|
|
insetBlockEnd: token.floatButtonInsetBlockEnd,
|
2022-12-06 15:17:34 +08:00
|
|
|
borderRadius: borderRadiusLG,
|
2022-10-24 23:15:39 +08:00
|
|
|
|
2022-09-23 14:31:16 +08:00
|
|
|
[`${groupPrefixCls}-wrap`]: {
|
|
|
|
zIndex: -1,
|
|
|
|
display: 'block',
|
|
|
|
position: 'relative',
|
|
|
|
marginBottom: margin,
|
|
|
|
},
|
2023-01-20 10:31:27 +08:00
|
|
|
[`&${groupPrefixCls}-rtl`]: {
|
2022-09-23 14:31:16 +08:00
|
|
|
direction: 'rtl',
|
|
|
|
},
|
|
|
|
[componentCls]: {
|
|
|
|
position: 'static',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${groupPrefixCls}-circle`]: {
|
|
|
|
[`${componentCls}-circle:not(:last-child)`]: {
|
|
|
|
marginBottom: token.margin,
|
|
|
|
[`${componentCls}-body`]: {
|
|
|
|
width: floatButtonSize,
|
|
|
|
height: floatButtonSize,
|
2023-03-20 10:28:20 +08:00
|
|
|
borderRadius: '50%',
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${groupPrefixCls}-square`]: {
|
|
|
|
[`${componentCls}-square`]: {
|
|
|
|
padding: 0,
|
2024-08-14 09:17:56 +08:00
|
|
|
borderRadius: 0,
|
|
|
|
[`&${groupPrefixCls}-trigger`]: {
|
|
|
|
borderRadius: borderRadiusLG,
|
|
|
|
},
|
2022-09-23 14:31:16 +08:00
|
|
|
'&:first-child': {
|
2022-12-06 15:17:34 +08:00
|
|
|
borderStartStartRadius: borderRadiusLG,
|
|
|
|
borderStartEndRadius: borderRadiusLG,
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
'&:last-child': {
|
2022-12-06 15:17:34 +08:00
|
|
|
borderEndStartRadius: borderRadiusLG,
|
|
|
|
borderEndEndRadius: borderRadiusLG,
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
'&:not(:last-child)': {
|
2023-11-15 11:46:17 +08:00
|
|
|
borderBottom: `${unit(token.lineWidth)} ${token.lineType} ${token.colorSplit}`,
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
2023-03-20 10:28:20 +08:00
|
|
|
[`${antCls}-badge`]: {
|
|
|
|
[`${antCls}-badge-count`]: {
|
2023-11-15 11:46:17 +08:00
|
|
|
top: calc(calc(floatButtonBodyPadding).add(badgeOffset)).mul(-1).equal(),
|
|
|
|
insetInlineEnd: calc(calc(floatButtonBodyPadding).add(badgeOffset)).mul(-1).equal(),
|
2023-03-20 10:28:20 +08:00
|
|
|
},
|
|
|
|
},
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
[`${groupPrefixCls}-wrap`]: {
|
|
|
|
display: 'block',
|
2022-12-06 15:17:34 +08:00
|
|
|
borderRadius: borderRadiusLG,
|
2022-09-23 14:31:16 +08:00
|
|
|
boxShadow: token.boxShadowSecondary,
|
|
|
|
[`${componentCls}-square`]: {
|
|
|
|
boxShadow: 'none',
|
|
|
|
marginTop: 0,
|
|
|
|
borderRadius: 0,
|
2023-03-20 10:28:20 +08:00
|
|
|
padding: floatButtonBodyPadding,
|
2022-09-23 14:31:16 +08:00
|
|
|
'&:first-child': {
|
2022-12-06 15:17:34 +08:00
|
|
|
borderStartStartRadius: borderRadiusLG,
|
|
|
|
borderStartEndRadius: borderRadiusLG,
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
'&:last-child': {
|
2022-12-06 15:17:34 +08:00
|
|
|
borderEndStartRadius: borderRadiusLG,
|
|
|
|
borderEndEndRadius: borderRadiusLG,
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
'&:not(:last-child)': {
|
2023-11-15 11:46:17 +08:00
|
|
|
borderBottom: `${unit(token.lineWidth)} ${token.lineType} ${token.colorSplit}`,
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
[`${componentCls}-body`]: {
|
2023-03-20 10:28:20 +08:00
|
|
|
width: token.floatButtonBodySize,
|
|
|
|
height: token.floatButtonBodySize,
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${groupPrefixCls}-circle-shadow`]: {
|
|
|
|
boxShadow: 'none',
|
|
|
|
},
|
|
|
|
[`${groupPrefixCls}-square-shadow`]: {
|
|
|
|
boxShadow: token.boxShadowSecondary,
|
|
|
|
[`${componentCls}-square`]: {
|
|
|
|
boxShadow: 'none',
|
2023-03-20 10:28:20 +08:00
|
|
|
padding: floatButtonBodyPadding,
|
2022-09-23 14:31:16 +08:00
|
|
|
[`${componentCls}-body`]: {
|
2023-03-20 10:28:20 +08:00
|
|
|
width: token.floatButtonBodySize,
|
|
|
|
height: token.floatButtonBodySize,
|
|
|
|
borderRadius: borderRadiusSM,
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Shared ==============================
|
2022-11-17 23:31:41 +08:00
|
|
|
const sharedFloatButtonStyle: GenerateStyle<FloatButtonToken, CSSObject> = (token) => {
|
2023-03-20 10:28:20 +08:00
|
|
|
const {
|
|
|
|
antCls,
|
|
|
|
componentCls,
|
|
|
|
floatButtonBodyPadding,
|
|
|
|
floatButtonIconSize,
|
|
|
|
floatButtonSize,
|
|
|
|
borderRadiusLG,
|
|
|
|
badgeOffset,
|
|
|
|
dotOffsetInSquare,
|
|
|
|
dotOffsetInCircle,
|
2024-08-09 22:22:45 +08:00
|
|
|
zIndexPopupBase,
|
2023-11-15 11:46:17 +08:00
|
|
|
calc,
|
2023-03-20 10:28:20 +08:00
|
|
|
} = token;
|
2022-09-23 14:31:16 +08:00
|
|
|
return {
|
|
|
|
[componentCls]: {
|
|
|
|
...resetComponent(token),
|
|
|
|
border: 'none',
|
|
|
|
position: 'fixed',
|
|
|
|
cursor: 'pointer',
|
2024-08-09 22:22:45 +08:00
|
|
|
zIndex: zIndexPopupBase,
|
2023-09-08 13:56:05 +08:00
|
|
|
// Do not remove the 'display: block' here.
|
|
|
|
// Deleting it will cause marginBottom to become ineffective.
|
|
|
|
// Ref: https://github.com/ant-design/ant-design/issues/44700
|
|
|
|
display: 'block',
|
2022-09-23 14:31:16 +08:00
|
|
|
width: floatButtonSize,
|
|
|
|
height: floatButtonSize,
|
|
|
|
insetInlineEnd: token.floatButtonInsetInlineEnd,
|
|
|
|
insetBlockEnd: token.floatButtonInsetBlockEnd,
|
|
|
|
boxShadow: token.boxShadowSecondary,
|
2022-10-24 23:15:39 +08:00
|
|
|
// Pure Panel
|
|
|
|
'&-pure': {
|
|
|
|
position: 'relative',
|
|
|
|
inset: 'auto',
|
|
|
|
},
|
2022-09-23 14:31:16 +08:00
|
|
|
'&:empty': {
|
|
|
|
display: 'none',
|
|
|
|
},
|
2023-03-20 10:28:20 +08:00
|
|
|
[`${antCls}-badge`]: {
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
[`${antCls}-badge-count`]: {
|
|
|
|
transform: 'translate(0, 0)',
|
|
|
|
transformOrigin: 'center',
|
2023-11-15 11:46:17 +08:00
|
|
|
top: calc(badgeOffset).mul(-1).equal(),
|
|
|
|
insetInlineEnd: calc(badgeOffset).mul(-1).equal(),
|
2023-03-20 10:28:20 +08:00
|
|
|
},
|
|
|
|
},
|
2022-09-23 14:31:16 +08:00
|
|
|
[`${componentCls}-body`]: {
|
2022-12-06 15:17:34 +08:00
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
2022-09-23 14:31:16 +08:00
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
2022-11-17 23:31:41 +08:00
|
|
|
transition: `all ${token.motionDurationMid}`,
|
2022-09-23 14:31:16 +08:00
|
|
|
[`${componentCls}-content`]: {
|
|
|
|
overflow: 'hidden',
|
|
|
|
textAlign: 'center',
|
|
|
|
minHeight: floatButtonSize,
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
2023-11-15 11:46:17 +08:00
|
|
|
padding: `${unit(calc(floatButtonBodyPadding).div(2).equal())} ${unit(
|
|
|
|
floatButtonBodyPadding,
|
|
|
|
)}`,
|
2022-09-23 14:31:16 +08:00
|
|
|
[`${componentCls}-icon`]: {
|
|
|
|
textAlign: 'center',
|
|
|
|
margin: 'auto',
|
|
|
|
width: floatButtonIconSize,
|
|
|
|
fontSize: floatButtonIconSize,
|
|
|
|
lineHeight: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-03-20 10:28:20 +08:00
|
|
|
|
2023-03-01 19:00:17 +08:00
|
|
|
[`${componentCls}-rtl`]: {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
2022-09-23 14:31:16 +08:00
|
|
|
[`${componentCls}-circle`]: {
|
|
|
|
height: floatButtonSize,
|
|
|
|
borderRadius: '50%',
|
2023-03-20 10:28:20 +08:00
|
|
|
[`${antCls}-badge`]: {
|
|
|
|
[`${antCls}-badge-dot`]: {
|
|
|
|
top: dotOffsetInCircle,
|
|
|
|
insetInlineEnd: dotOffsetInCircle,
|
|
|
|
},
|
|
|
|
},
|
2022-09-23 14:31:16 +08:00
|
|
|
[`${componentCls}-body`]: {
|
|
|
|
borderRadius: '50%',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${componentCls}-square`]: {
|
|
|
|
height: 'auto',
|
|
|
|
minHeight: floatButtonSize,
|
2022-12-06 15:17:34 +08:00
|
|
|
borderRadius: borderRadiusLG,
|
2023-03-20 10:28:20 +08:00
|
|
|
[`${antCls}-badge`]: {
|
|
|
|
[`${antCls}-badge-dot`]: {
|
|
|
|
top: dotOffsetInSquare,
|
|
|
|
insetInlineEnd: dotOffsetInSquare,
|
|
|
|
},
|
|
|
|
},
|
2022-09-23 14:31:16 +08:00
|
|
|
[`${componentCls}-body`]: {
|
|
|
|
height: 'auto',
|
2023-03-20 10:28:20 +08:00
|
|
|
borderRadius: borderRadiusLG,
|
2022-09-23 14:31:16 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${componentCls}-default`]: {
|
2022-11-22 17:00:28 +08:00
|
|
|
backgroundColor: token.floatButtonBackgroundColor,
|
2022-11-17 23:31:41 +08:00
|
|
|
transition: `background-color ${token.motionDurationMid}`,
|
2022-09-23 14:31:16 +08:00
|
|
|
[`${componentCls}-body`]: {
|
2022-11-22 17:00:28 +08:00
|
|
|
backgroundColor: token.floatButtonBackgroundColor,
|
2022-11-17 23:31:41 +08:00
|
|
|
transition: `background-color ${token.motionDurationMid}`,
|
2022-09-23 14:31:16 +08:00
|
|
|
'&:hover': {
|
|
|
|
backgroundColor: token.colorFillContent,
|
|
|
|
},
|
|
|
|
[`${componentCls}-content`]: {
|
|
|
|
[`${componentCls}-icon`]: {
|
|
|
|
color: token.colorText,
|
|
|
|
},
|
|
|
|
[`${componentCls}-description`]: {
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
2023-11-15 11:46:17 +08:00
|
|
|
lineHeight: unit(token.fontSizeLG),
|
2022-09-23 14:31:16 +08:00
|
|
|
color: token.colorText,
|
|
|
|
fontSize: token.fontSizeSM,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${componentCls}-primary`]: {
|
|
|
|
backgroundColor: token.colorPrimary,
|
|
|
|
[`${componentCls}-body`]: {
|
|
|
|
backgroundColor: token.colorPrimary,
|
2022-11-17 23:31:41 +08:00
|
|
|
transition: `background-color ${token.motionDurationMid}`,
|
2022-09-23 14:31:16 +08:00
|
|
|
'&:hover': {
|
|
|
|
backgroundColor: token.colorPrimaryHover,
|
|
|
|
},
|
|
|
|
[`${componentCls}-content`]: {
|
|
|
|
[`${componentCls}-icon`]: {
|
|
|
|
color: token.colorTextLightSolid,
|
|
|
|
},
|
|
|
|
[`${componentCls}-description`]: {
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
2023-11-15 11:46:17 +08:00
|
|
|
lineHeight: unit(token.fontSizeLG),
|
2022-09-23 14:31:16 +08:00
|
|
|
color: token.colorTextLightSolid,
|
|
|
|
fontSize: token.fontSizeSM,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2023-11-15 11:46:17 +08:00
|
|
|
export const prepareComponentToken: GetDefaultToken<'FloatButton'> = (token) => ({
|
|
|
|
dotOffsetInCircle: getOffset(token.controlHeightLG / 2),
|
|
|
|
dotOffsetInSquare: getOffset(token.borderRadiusLG),
|
|
|
|
});
|
2023-03-20 10:28:20 +08:00
|
|
|
|
2023-11-29 17:23:45 +08:00
|
|
|
export default genStyleHooks(
|
2023-11-15 11:46:17 +08:00
|
|
|
'FloatButton',
|
|
|
|
(token) => {
|
|
|
|
const {
|
|
|
|
colorTextLightSolid,
|
|
|
|
colorBgElevated,
|
|
|
|
controlHeightLG,
|
|
|
|
marginXXL,
|
|
|
|
marginLG,
|
|
|
|
fontSize,
|
|
|
|
fontSizeIcon,
|
|
|
|
controlItemBgHover,
|
|
|
|
paddingXXS,
|
|
|
|
calc,
|
|
|
|
} = token;
|
2023-03-20 10:28:20 +08:00
|
|
|
|
2023-11-15 11:46:17 +08:00
|
|
|
const floatButtonToken = mergeToken<FloatButtonToken>(token, {
|
|
|
|
floatButtonBackgroundColor: colorBgElevated,
|
|
|
|
floatButtonColor: colorTextLightSolid,
|
|
|
|
floatButtonHoverBackgroundColor: controlItemBgHover,
|
|
|
|
floatButtonFontSize: fontSize,
|
|
|
|
floatButtonIconSize: calc(fontSizeIcon).mul(1.5).equal(),
|
|
|
|
floatButtonSize: controlHeightLG,
|
|
|
|
floatButtonInsetBlockEnd: marginXXL,
|
|
|
|
floatButtonInsetInlineEnd: marginLG,
|
|
|
|
floatButtonBodySize: calc(controlHeightLG).sub(calc(paddingXXS).mul(2)).equal(),
|
|
|
|
// 这里的 paddingXXS 是简写,完整逻辑是 (controlHeightLG - (controlHeightLG - paddingXXS * 2)) / 2,
|
|
|
|
floatButtonBodyPadding: paddingXXS,
|
|
|
|
badgeOffset: calc(paddingXXS).mul(1.5).equal(),
|
|
|
|
});
|
|
|
|
|
|
|
|
return [
|
|
|
|
floatButtonGroupStyle(floatButtonToken),
|
|
|
|
sharedFloatButtonStyle(floatButtonToken),
|
|
|
|
initFadeMotion(token),
|
|
|
|
initFloatButtonGroupMotion(floatButtonToken),
|
|
|
|
];
|
|
|
|
},
|
|
|
|
prepareComponentToken,
|
|
|
|
);
|