2022-02-18 14:17:32 +08:00
|
|
|
// deps-lint-skip-all
|
|
|
|
import { CSSInterpolation, CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import { TinyColor } from '@ctrl/tinycolor';
|
2022-03-03 14:55:19 +08:00
|
|
|
import {
|
2022-03-24 18:44:42 +08:00
|
|
|
AliasToken,
|
2022-03-03 14:55:19 +08:00
|
|
|
UseComponentStyleResult,
|
|
|
|
useStyleRegister,
|
|
|
|
useToken,
|
2022-03-24 18:44:42 +08:00
|
|
|
GenerateStyle,
|
2022-03-03 14:55:19 +08:00
|
|
|
} from '../../_util/theme';
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
|
|
|
export interface ComponentToken {
|
|
|
|
colorBgTextHover: string;
|
|
|
|
colorBgTextActive: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ButtonToken extends AliasToken, ComponentToken {
|
|
|
|
btnCls: string;
|
|
|
|
iconPrefixCls: string;
|
|
|
|
}
|
|
|
|
|
2022-02-18 14:17:32 +08:00
|
|
|
// ============================== Shared ==============================
|
2022-03-24 18:44:42 +08:00
|
|
|
const genSharedButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token): CSSObject => {
|
|
|
|
const { btnCls, iconPrefixCls } = token;
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
return {
|
|
|
|
[btnCls]: {
|
|
|
|
outline: 'none',
|
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-block',
|
|
|
|
fontWeight: 400,
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
textAlign: 'center',
|
|
|
|
backgroundImage: 'none',
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
border: `${token.controlLineWidth}px ${token.controlLineType} transparent`,
|
|
|
|
cursor: 'pointer',
|
|
|
|
transition: `all ${token.motionDurationSlow} ${token.motionEaseInOut}`,
|
|
|
|
userSelect: 'none',
|
|
|
|
touchAction: 'manipulation',
|
|
|
|
lineHeight: token.lineHeight,
|
|
|
|
color: token.colorText,
|
|
|
|
|
|
|
|
'> span': {
|
|
|
|
display: 'inline-block',
|
|
|
|
},
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
// Leave a space between icon and text.
|
|
|
|
[`> .${iconPrefixCls} + span, > span + .${iconPrefixCls}`]: {
|
|
|
|
marginInlineStart: token.marginXS,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${btnCls}-block`]: {
|
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
const genHoverActiveButtonStyle = (hoverStyle: CSSObject, activeStyle: CSSObject): CSSObject => ({
|
|
|
|
'&:not(:disabled)': {
|
|
|
|
'&:hover, &:focus': hoverStyle,
|
|
|
|
'&:active': activeStyle,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// ============================== Shape ===============================
|
2022-03-24 18:44:42 +08:00
|
|
|
const genCircleButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
2022-03-08 10:29:00 +08:00
|
|
|
minWidth: token.controlHeight,
|
2022-03-11 17:07:16 +08:00
|
|
|
paddingInlineStart: 0,
|
|
|
|
paddingInlineEnd: 0,
|
2022-02-18 14:17:32 +08:00
|
|
|
borderRadius: '50%',
|
|
|
|
});
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const genRoundButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
2022-03-08 10:29:00 +08:00
|
|
|
borderRadius: token.controlHeight,
|
2022-03-11 17:07:16 +08:00
|
|
|
paddingInlineStart: token.controlHeight / 2,
|
|
|
|
paddingInlineEnd: token.controlHeight / 2,
|
2022-02-18 14:17:32 +08:00
|
|
|
width: 'auto',
|
|
|
|
});
|
|
|
|
|
|
|
|
// =============================== Type ===============================
|
|
|
|
const genGhostButtonStyle = (
|
2022-03-24 18:44:42 +08:00
|
|
|
btnCls: string,
|
2022-02-18 14:17:32 +08:00
|
|
|
textColor: string | false,
|
|
|
|
borderColor: string | false,
|
|
|
|
textColorDisabled: string | false,
|
|
|
|
borderColorDisabled: string | false,
|
|
|
|
): CSSObject => ({
|
2022-03-24 18:44:42 +08:00
|
|
|
[`&${btnCls}-background-ghost`]: {
|
2022-02-18 14:17:32 +08:00
|
|
|
color: textColor || undefined,
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
borderColor: borderColor || undefined,
|
2022-03-24 18:44:42 +08:00
|
|
|
boxShadow: 'none',
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
'&:disabled': {
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
color: textColorDisabled || undefined,
|
|
|
|
borderColor: borderColorDisabled || undefined,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const genSolidDisabledButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
2022-02-18 14:17:32 +08:00
|
|
|
'&:disabled': {
|
|
|
|
cursor: 'not-allowed',
|
2022-03-22 13:26:29 +08:00
|
|
|
borderColor: token.colorBorder,
|
|
|
|
color: token.colorTextDisabled,
|
2022-03-22 20:02:04 +08:00
|
|
|
backgroundColor: token.colorBgComponentDisabled,
|
2022-02-18 14:17:32 +08:00
|
|
|
boxShadow: 'none',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const genSolidButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
2022-03-22 13:26:29 +08:00
|
|
|
borderRadius: token.controlRadius,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
...genSolidDisabledButtonStyle(token),
|
|
|
|
});
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const genPureDisabledButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
2022-02-18 14:17:32 +08:00
|
|
|
'&:disabled': {
|
|
|
|
cursor: 'not-allowed',
|
2022-03-22 13:26:29 +08:00
|
|
|
color: token.colorTextDisabled,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Type: Default
|
2022-03-24 18:44:42 +08:00
|
|
|
const genDefaultButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
2022-02-18 14:17:32 +08:00
|
|
|
...genSolidButtonStyle(token),
|
|
|
|
|
2022-03-22 20:02:04 +08:00
|
|
|
backgroundColor: token.colorBgComponent,
|
2022-03-22 13:26:29 +08:00
|
|
|
borderColor: token.colorBorder,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.colorDefaultOutline}`,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
color: token.colorPrimaryHover,
|
|
|
|
borderColor: token.colorPrimaryHover,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
color: token.colorPrimaryActive,
|
|
|
|
borderColor: token.colorPrimaryActive,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
...genGhostButtonStyle(
|
2022-03-24 18:44:42 +08:00
|
|
|
token.btnCls,
|
2022-03-22 20:02:04 +08:00
|
|
|
token.colorBgComponent,
|
|
|
|
token.colorBgComponent,
|
2022-03-22 13:26:29 +08:00
|
|
|
token.colorTextDisabled,
|
|
|
|
token.colorBorder,
|
2022-02-18 14:17:32 +08:00
|
|
|
),
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
[`&${token.btnCls}-dangerous`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorError,
|
|
|
|
borderColor: token.colorError,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
color: token.colorErrorHover,
|
|
|
|
borderColor: token.colorErrorHover,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
color: token.colorErrorActive,
|
|
|
|
borderColor: token.colorErrorActive,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
...genGhostButtonStyle(
|
2022-03-24 18:44:42 +08:00
|
|
|
token.btnCls,
|
2022-03-22 09:37:37 +08:00
|
|
|
token.colorError,
|
|
|
|
token.colorError,
|
2022-03-22 13:26:29 +08:00
|
|
|
token.colorTextDisabled,
|
|
|
|
token.colorBorder,
|
2022-02-18 14:17:32 +08:00
|
|
|
),
|
|
|
|
...genSolidDisabledButtonStyle(token),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Type: Primary
|
2022-03-24 18:44:42 +08:00
|
|
|
const genPrimaryButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
2022-02-18 14:17:32 +08:00
|
|
|
...genSolidButtonStyle(token),
|
|
|
|
|
|
|
|
color: '#FFF',
|
2022-03-22 09:37:37 +08:00
|
|
|
backgroundColor: token.colorPrimary,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.colorPrimaryOutline}`,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
backgroundColor: token.colorPrimaryHover,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
backgroundColor: token.colorPrimaryActive,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
...genGhostButtonStyle(
|
2022-03-24 18:44:42 +08:00
|
|
|
token.btnCls,
|
2022-03-22 09:37:37 +08:00
|
|
|
token.colorPrimary,
|
|
|
|
token.colorPrimary,
|
2022-03-22 13:26:29 +08:00
|
|
|
token.colorTextDisabled,
|
|
|
|
token.colorBorder,
|
2022-02-18 14:17:32 +08:00
|
|
|
),
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
[`&${token.btnCls}-dangerous`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
backgroundColor: token.colorError,
|
2022-03-24 18:44:42 +08:00
|
|
|
boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.colorErrorOutline}`,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
backgroundColor: token.colorErrorHover,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
backgroundColor: token.colorErrorActive,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
...genGhostButtonStyle(
|
2022-03-24 18:44:42 +08:00
|
|
|
token.btnCls,
|
2022-03-22 09:37:37 +08:00
|
|
|
token.colorError,
|
|
|
|
token.colorError,
|
2022-03-22 13:26:29 +08:00
|
|
|
token.colorTextDisabled,
|
|
|
|
token.colorBorder,
|
2022-02-18 14:17:32 +08:00
|
|
|
),
|
|
|
|
...genSolidDisabledButtonStyle(token),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Type: Dashed
|
2022-03-24 18:44:42 +08:00
|
|
|
const genDashedButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
|
|
|
...genDefaultButtonStyle(token),
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
borderStyle: 'dashed',
|
|
|
|
});
|
|
|
|
|
|
|
|
// Type: Link
|
2022-03-24 18:44:42 +08:00
|
|
|
const genLinkButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
2022-03-24 14:30:48 +08:00
|
|
|
color: token.colorLink,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
2022-03-24 14:30:48 +08:00
|
|
|
color: token.colorLinkHover,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-24 14:30:48 +08:00
|
|
|
color: token.colorLinkActive,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
...genPureDisabledButtonStyle(token),
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
[`&${token.btnCls}-dangerous`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorError,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
color: token.colorErrorHover,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-22 20:02:04 +08:00
|
|
|
color: token.colorErrorActive,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
...genPureDisabledButtonStyle(token),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Type: Text
|
2022-03-24 18:44:42 +08:00
|
|
|
const genTextButtonStyle: GenerateStyle<ButtonToken, CSSObject> = token => ({
|
|
|
|
borderRadius: token.controlRadius,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
|
|
|
backgroundColor: token.colorBgTextHover,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
backgroundColor: token.colorBgTextActive,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
...genPureDisabledButtonStyle(token),
|
|
|
|
|
|
|
|
[`&${token.btnCls}-dangerous`]: {
|
|
|
|
color: token.colorError,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
...genPureDisabledButtonStyle(token),
|
2022-03-24 18:44:42 +08:00
|
|
|
},
|
|
|
|
});
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const genTypeButtonStyle: GenerateStyle<ButtonToken> = token => {
|
|
|
|
const { btnCls } = token;
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
return {
|
|
|
|
[`${btnCls}-default`]: genDefaultButtonStyle(token),
|
|
|
|
[`${btnCls}-primary`]: genPrimaryButtonStyle(token),
|
|
|
|
[`${btnCls}-dashed`]: genDashedButtonStyle(token),
|
|
|
|
[`${btnCls}-link`]: genLinkButtonStyle(token),
|
|
|
|
[`${btnCls}-text`]: genTextButtonStyle(token),
|
2022-02-18 14:17:32 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// =============================== Size ===============================
|
2022-03-24 18:44:42 +08:00
|
|
|
const genSizeButtonStyle = (token: ButtonToken, sizePrefixCls: string = ''): CSSInterpolation => {
|
|
|
|
const { btnCls, iconPrefixCls } = token;
|
|
|
|
|
2022-02-18 14:17:32 +08:00
|
|
|
const paddingVertical = Math.max(
|
|
|
|
0,
|
2022-03-22 13:26:29 +08:00
|
|
|
(token.controlHeight - token.fontSize * token.lineHeight) / 2 - token.controlLineWidth,
|
2022-02-18 14:17:32 +08:00
|
|
|
);
|
2022-03-22 13:26:29 +08:00
|
|
|
const paddingHorizontal = token.padding - token.controlLineWidth;
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const iconOnlyCls = `${btnCls}-icon-only`;
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
return [
|
|
|
|
// Size
|
2022-03-24 18:44:42 +08:00
|
|
|
{
|
|
|
|
[`${btnCls}${sizePrefixCls}`]: {
|
2022-02-18 14:17:32 +08:00
|
|
|
fontSize: token.fontSize,
|
2022-03-08 10:29:00 +08:00
|
|
|
height: token.controlHeight,
|
2022-02-18 14:17:32 +08:00
|
|
|
padding: `${paddingVertical}px ${paddingHorizontal}px`,
|
|
|
|
|
|
|
|
[`&${iconOnlyCls}`]: {
|
2022-03-08 10:29:00 +08:00
|
|
|
width: token.controlHeight,
|
2022-03-11 17:07:16 +08:00
|
|
|
paddingInlineStart: 0,
|
|
|
|
paddingInlineEnd: 0,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
'> span': {
|
|
|
|
transform: 'scale(1.143)', // 14px -> 16px
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Loading
|
2022-03-24 18:44:42 +08:00
|
|
|
[`&${btnCls}-loading`]: {
|
2022-02-18 14:17:32 +08:00
|
|
|
opacity: 0.65,
|
|
|
|
cursor: 'default',
|
|
|
|
},
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
[`${btnCls}-loading-icon`]: {
|
2022-03-22 20:02:04 +08:00
|
|
|
transition: `width ${token.motionDurationSlow} ${token.motionEaseInOut}, opacity ${token.motionDurationSlow} ${token.motionEaseInOut}`,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
[`&:not(${iconOnlyCls}) ${btnCls}-loading-icon > .${iconPrefixCls}`]: {
|
2022-02-18 14:17:32 +08:00
|
|
|
marginInlineEnd: token.marginXS,
|
|
|
|
},
|
|
|
|
},
|
2022-03-24 18:44:42 +08:00
|
|
|
},
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
// Shape - patch prefixCls again to override solid border radius style
|
2022-03-24 18:44:42 +08:00
|
|
|
{
|
|
|
|
[`${btnCls}${btnCls}-circle${sizePrefixCls}`]: genCircleButtonStyle(token),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
[`${btnCls}${btnCls}-round${sizePrefixCls}`]: genRoundButtonStyle(token),
|
|
|
|
},
|
2022-02-18 14:17:32 +08:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const genSizeBaseButtonStyle: GenerateStyle<ButtonToken> = token => genSizeButtonStyle(token);
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const genSizeSmallButtonStyle: GenerateStyle<ButtonToken> = token => {
|
|
|
|
const largeToken: ButtonToken = {
|
2022-02-18 14:17:32 +08:00
|
|
|
...token,
|
2022-03-08 10:29:00 +08:00
|
|
|
controlHeight: token.controlHeightSM,
|
2022-02-18 14:17:32 +08:00
|
|
|
padding: token.paddingXS,
|
|
|
|
};
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
return genSizeButtonStyle(largeToken, `${token.btnCls}-sm`);
|
2022-02-18 14:17:32 +08:00
|
|
|
};
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const genSizeLargeButtonStyle: GenerateStyle<ButtonToken> = token => {
|
|
|
|
const largeToken: ButtonToken = {
|
2022-02-18 14:17:32 +08:00
|
|
|
...token,
|
2022-03-08 10:29:00 +08:00
|
|
|
controlHeight: token.controlHeightLG,
|
2022-02-18 14:17:32 +08:00
|
|
|
fontSize: token.fontSizeLG,
|
|
|
|
};
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
return genSizeButtonStyle(largeToken, `${token.btnCls}-lg`);
|
2022-02-18 14:17:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-03-03 14:55:19 +08:00
|
|
|
export default function useStyle(
|
|
|
|
prefixCls: string,
|
|
|
|
iconPrefixCls: string,
|
|
|
|
): UseComponentStyleResult {
|
2022-02-27 22:17:17 +08:00
|
|
|
const [theme, token, hashId] = useToken();
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-03 14:55:19 +08:00
|
|
|
return [
|
2022-03-24 18:44:42 +08:00
|
|
|
useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => {
|
|
|
|
const { colorText, button = {} } = token;
|
|
|
|
const textColor = new TinyColor(colorText);
|
|
|
|
|
|
|
|
const buttonToken: ButtonToken = {
|
|
|
|
...token,
|
|
|
|
colorBgTextHover: textColor
|
|
|
|
.clone()
|
|
|
|
.setAlpha(textColor.getAlpha() * 0.02)
|
|
|
|
.toRgbString(),
|
|
|
|
colorBgTextActive: textColor
|
|
|
|
.clone()
|
|
|
|
.setAlpha(textColor.getAlpha() * 0.03)
|
|
|
|
.toRgbString(),
|
|
|
|
|
|
|
|
iconPrefixCls,
|
|
|
|
btnCls: `.${prefixCls}`,
|
|
|
|
|
|
|
|
// Override by developer
|
|
|
|
...button,
|
|
|
|
};
|
|
|
|
|
|
|
|
return [
|
|
|
|
// Shared
|
|
|
|
genSharedButtonStyle(buttonToken),
|
|
|
|
|
|
|
|
// Size
|
|
|
|
genSizeSmallButtonStyle(buttonToken),
|
|
|
|
genSizeBaseButtonStyle(buttonToken),
|
|
|
|
genSizeLargeButtonStyle(buttonToken),
|
|
|
|
|
|
|
|
// Group (type, ghost, danger, disabled, loading)
|
|
|
|
genTypeButtonStyle(buttonToken),
|
|
|
|
];
|
|
|
|
}),
|
2022-03-03 14:55:19 +08:00
|
|
|
hashId,
|
|
|
|
];
|
2022-02-18 14:17:32 +08:00
|
|
|
}
|