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-04-02 22:55:02 +08:00
|
|
|
import genComponentStyleHook, { FullToken } from '../../_util/hooks/genComponentStyleHook';
|
|
|
|
import { GenerateStyle, mergeToken } 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;
|
|
|
|
}
|
|
|
|
|
2022-04-02 22:55:02 +08:00
|
|
|
interface ButtonToken extends FullToken<'Button'> {
|
2022-03-24 18:44:42 +08:00
|
|
|
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 => {
|
2022-04-02 22:55:02 +08:00
|
|
|
const { componentCls, iconPrefixCls } = token;
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
return {
|
2022-04-02 22:55:02 +08:00
|
|
|
[componentCls]: {
|
2022-03-24 18:44:42 +08:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
|
2022-04-02 22:55:02 +08:00
|
|
|
[`&${componentCls}-block`]: {
|
2022-03-24 18:44:42 +08:00
|
|
|
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-04-02 22:55:02 +08:00
|
|
|
token.componentCls,
|
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-04-02 22:55:02 +08:00
|
|
|
[`&${token.componentCls}-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-04-02 22:55:02 +08:00
|
|
|
token.componentCls,
|
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-04-02 22:55:02 +08:00
|
|
|
token.componentCls,
|
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-04-02 22:55:02 +08:00
|
|
|
[`&${token.componentCls}-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-04-02 22:55:02 +08:00
|
|
|
token.componentCls,
|
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-04-02 22:55:02 +08:00
|
|
|
[`&${token.componentCls}-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),
|
|
|
|
|
2022-04-02 22:55:02 +08:00
|
|
|
[`&${token.componentCls}-dangerous`]: {
|
2022-03-24 18:44:42 +08:00
|
|
|
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 => {
|
2022-04-02 22:55:02 +08:00
|
|
|
const { componentCls } = token;
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
return {
|
2022-04-02 22:55:02 +08:00
|
|
|
[`${componentCls}-default`]: genDefaultButtonStyle(token),
|
|
|
|
[`${componentCls}-primary`]: genPrimaryButtonStyle(token),
|
|
|
|
[`${componentCls}-dashed`]: genDashedButtonStyle(token),
|
|
|
|
[`${componentCls}-link`]: genLinkButtonStyle(token),
|
|
|
|
[`${componentCls}-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 => {
|
2022-04-02 22:55:02 +08:00
|
|
|
const { componentCls, iconPrefixCls } = token;
|
2022-03-24 18:44:42 +08:00
|
|
|
|
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-04-02 22:55:02 +08:00
|
|
|
const iconOnlyCls = `${componentCls}-icon-only`;
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
return [
|
|
|
|
// Size
|
2022-03-24 18:44:42 +08:00
|
|
|
{
|
2022-04-02 22:55:02 +08:00
|
|
|
[`${componentCls}${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-04-02 22:55:02 +08:00
|
|
|
[`&${componentCls}-loading`]: {
|
2022-02-18 14:17:32 +08:00
|
|
|
opacity: 0.65,
|
|
|
|
cursor: 'default',
|
|
|
|
},
|
|
|
|
|
2022-04-02 22:55:02 +08:00
|
|
|
[`${componentCls}-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-04-02 22:55:02 +08:00
|
|
|
[`&:not(${iconOnlyCls}) ${componentCls}-loading-icon:not(:only-child) > .${iconPrefixCls}`]:
|
|
|
|
{
|
|
|
|
marginInlineEnd: token.marginXS,
|
|
|
|
},
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
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
|
|
|
{
|
2022-04-02 22:55:02 +08:00
|
|
|
[`${componentCls}${componentCls}-circle${sizePrefixCls}`]: genCircleButtonStyle(token),
|
2022-03-24 18:44:42 +08:00
|
|
|
},
|
|
|
|
{
|
2022-04-02 22:55:02 +08:00
|
|
|
[`${componentCls}${componentCls}-round${sizePrefixCls}`]: genRoundButtonStyle(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 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 => {
|
2022-04-01 17:00:12 +08:00
|
|
|
const largeToken = mergeToken<ButtonToken>(token, {
|
2022-03-08 10:29:00 +08:00
|
|
|
controlHeight: token.controlHeightSM,
|
2022-02-18 14:17:32 +08:00
|
|
|
padding: token.paddingXS,
|
2022-04-01 17:00:12 +08:00
|
|
|
});
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-04-02 22:55:02 +08:00
|
|
|
return genSizeButtonStyle(largeToken, `${token.componentCls}-sm`);
|
2022-02-18 14:17:32 +08:00
|
|
|
};
|
|
|
|
|
2022-03-24 18:44:42 +08:00
|
|
|
const genSizeLargeButtonStyle: GenerateStyle<ButtonToken> = token => {
|
2022-04-01 17:00:12 +08:00
|
|
|
const largeToken = mergeToken<ButtonToken>(token, {
|
2022-03-08 10:29:00 +08:00
|
|
|
controlHeight: token.controlHeightLG,
|
2022-02-18 14:17:32 +08:00
|
|
|
fontSize: token.fontSizeLG,
|
2022-04-01 17:00:12 +08:00
|
|
|
});
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-04-02 22:55:02 +08:00
|
|
|
return genSizeButtonStyle(largeToken, `${token.componentCls}-lg`);
|
2022-02-18 14:17:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-04-02 22:55:02 +08:00
|
|
|
export default genComponentStyleHook(
|
|
|
|
'Button',
|
|
|
|
(token, { iconPrefixCls }) => {
|
|
|
|
const buttonToken: ButtonToken = {
|
|
|
|
...token,
|
|
|
|
iconPrefixCls,
|
|
|
|
};
|
|
|
|
|
|
|
|
return [
|
|
|
|
// Shared
|
|
|
|
genSharedButtonStyle(buttonToken),
|
|
|
|
|
|
|
|
// Size
|
|
|
|
genSizeSmallButtonStyle(buttonToken),
|
|
|
|
genSizeBaseButtonStyle(buttonToken),
|
|
|
|
genSizeLargeButtonStyle(buttonToken),
|
|
|
|
|
|
|
|
// Group (type, ghost, danger, disabled, loading)
|
|
|
|
genTypeButtonStyle(buttonToken),
|
|
|
|
];
|
|
|
|
},
|
|
|
|
token => {
|
|
|
|
const { colorText } = token;
|
|
|
|
const textColor = new TinyColor(colorText);
|
|
|
|
|
|
|
|
return {
|
|
|
|
colorBgTextHover: textColor
|
|
|
|
.clone()
|
|
|
|
.setAlpha(textColor.getAlpha() * 0.02)
|
|
|
|
.toRgbString(),
|
|
|
|
colorBgTextActive: textColor
|
|
|
|
.clone()
|
|
|
|
.setAlpha(textColor.getAlpha() * 0.03)
|
|
|
|
.toRgbString(),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
);
|