2022-05-09 22:20:07 +08:00
|
|
|
import type { CSSInterpolation, CSSObject } from '@ant-design/cssinjs';
|
2022-06-27 14:25:59 +08:00
|
|
|
import type { FullToken, GenerateStyle } from '../../theme';
|
|
|
|
import { genComponentStyleHook, mergeToken } from '../../theme';
|
2022-04-22 22:36:50 +08:00
|
|
|
import genGroupStyle from './group';
|
2022-09-09 10:53:03 +08:00
|
|
|
import { genFocusStyle } from '../../style';
|
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 */
|
2022-06-24 11:11:42 +08:00
|
|
|
export interface ComponentToken {}
|
|
|
|
|
|
|
|
export interface ButtonToken extends FullToken<'Button'> {
|
2022-06-17 18:47:47 +08:00
|
|
|
// FIXME: should be removed
|
|
|
|
colorOutlineDefault: string;
|
2022-03-24 18:44:42 +08:00
|
|
|
}
|
|
|
|
|
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-06 12:20:52 +08:00
|
|
|
const { componentCls, iconCls } = 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',
|
2022-09-07 14:08:14 +08:00
|
|
|
transition: `all ${token.motionDurationFast} ${token.motionEaseInOut}`,
|
2022-03-24 18:44:42 +08:00
|
|
|
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.
|
2022-04-06 12:20:52 +08:00
|
|
|
[`> ${iconCls} + span, > span + ${iconCls}`]: {
|
2022-03-24 18:44:42 +08:00
|
|
|
marginInlineStart: token.marginXS,
|
|
|
|
},
|
|
|
|
|
2022-04-02 22:55:02 +08:00
|
|
|
[`&${componentCls}-block`]: {
|
2022-03-24 18:44:42 +08:00
|
|
|
width: '100%',
|
|
|
|
},
|
2022-09-09 10:53:03 +08:00
|
|
|
|
|
|
|
'&:not(:disabled)': {
|
|
|
|
...genFocusStyle(token),
|
|
|
|
},
|
2022-03-24 18:44:42 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
const genHoverActiveButtonStyle = (hoverStyle: CSSObject, activeStyle: CSSObject): CSSObject => ({
|
|
|
|
'&:not(:disabled)': {
|
2022-09-09 10:53:03 +08:00
|
|
|
'&:hover': hoverStyle,
|
2022-02-18 14:17:32 +08:00
|
|
|
'&: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
|
|
|
|
2022-06-17 18:47:47 +08:00
|
|
|
'&:hover': {
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
},
|
|
|
|
|
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-06-28 20:33:01 +08:00
|
|
|
backgroundColor: token.colorBgContainerDisabled,
|
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-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-06-28 20:33:01 +08:00
|
|
|
backgroundColor: token.colorBgContainer,
|
2022-03-22 13:26:29 +08:00
|
|
|
borderColor: token.colorBorder,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-06-29 21:24:29 +08:00
|
|
|
boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.controlTmpOutline}`,
|
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-06-28 20:33:01 +08:00
|
|
|
token.colorBgContainer,
|
|
|
|
token.colorBgContainer,
|
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,
|
2022-09-20 21:50:36 +08:00
|
|
|
borderColor: token.colorErrorBorder,
|
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),
|
|
|
|
|
2022-07-05 10:35:44 +08:00
|
|
|
color: token.colorTextLightSolid,
|
2022-03-22 09:37:37 +08:00
|
|
|
backgroundColor: token.colorPrimary,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-07-21 17:00:42 +08:00
|
|
|
boxShadow: `0 ${token.controlOutlineWidth}px 0 ${token.controlOutline}`,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
2022-08-29 20:03:09 +08:00
|
|
|
color: token.colorTextLightSolid,
|
2022-03-22 20:02:04 +08:00
|
|
|
backgroundColor: token.colorPrimaryHover,
|
2022-02-18 14:17:32 +08:00
|
|
|
},
|
|
|
|
{
|
2022-08-29 20:03:09 +08:00
|
|
|
color: token.colorTextLightSolid,
|
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 => ({
|
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
2022-08-29 20:03:09 +08:00
|
|
|
color: token.colorText,
|
2022-03-24 18:44:42 +08:00
|
|
|
backgroundColor: token.colorBgTextHover,
|
|
|
|
},
|
|
|
|
{
|
2022-08-29 20:03:09 +08:00
|
|
|
color: token.colorText,
|
2022-03-24 18:44:42 +08:00
|
|
|
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-08-29 20:03:09 +08:00
|
|
|
...genHoverActiveButtonStyle(
|
|
|
|
{
|
2022-09-20 21:50:36 +08:00
|
|
|
color: token.colorErrorHover,
|
|
|
|
backgroundColor: token.colorErrorBg,
|
2022-08-29 20:03:09 +08:00
|
|
|
},
|
|
|
|
{
|
2022-09-20 21:50:36 +08:00
|
|
|
color: token.colorErrorHover,
|
|
|
|
backgroundColor: token.colorErrorBg,
|
2022-08-29 20:03:09 +08:00
|
|
|
},
|
|
|
|
),
|
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-06 12:20:52 +08:00
|
|
|
const { componentCls, iconCls } = 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`,
|
2022-08-19 10:10:51 +08:00
|
|
|
borderRadius: token.controlRadius,
|
2022-02-18 14:17:32 +08:00
|
|
|
|
|
|
|
[`&${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-06-17 18:47:47 +08:00
|
|
|
opacity: token.opacityLoading,
|
2022-02-18 14:17:32 +08:00
|
|
|
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-06-23 12:13:41 +08:00
|
|
|
[`&:not(${iconOnlyCls}) ${componentCls}-loading-icon > ${iconCls}`]: {
|
2022-04-06 12:20:52 +08:00
|
|
|
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-08-19 10:10:51 +08:00
|
|
|
const smallToken = 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-08-19 10:10:51 +08:00
|
|
|
controlRadius: token.controlRadiusSM,
|
2022-04-01 17:00:12 +08:00
|
|
|
});
|
2022-02-18 14:17:32 +08:00
|
|
|
|
2022-08-19 10:10:51 +08:00
|
|
|
return genSizeButtonStyle(smallToken, `${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-08-19 10:10:51 +08:00
|
|
|
controlRadius: token.controlRadiusLG,
|
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-06-24 11:11:42 +08:00
|
|
|
export default genComponentStyleHook('Button', token => {
|
2022-09-07 12:00:00 +08:00
|
|
|
const { controlTmpOutline } = token;
|
2022-06-24 11:11:42 +08:00
|
|
|
|
|
|
|
const buttonToken = mergeToken<ButtonToken>(token, {
|
2022-06-29 21:24:29 +08:00
|
|
|
colorOutlineDefault: controlTmpOutline,
|
2022-06-24 11:11:42 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
return [
|
2022-04-06 12:20:52 +08:00
|
|
|
// Shared
|
2022-06-24 11:11:42 +08:00
|
|
|
genSharedButtonStyle(buttonToken),
|
2022-04-02 22:55:02 +08:00
|
|
|
|
2022-04-06 12:20:52 +08:00
|
|
|
// Size
|
2022-06-24 11:11:42 +08:00
|
|
|
genSizeSmallButtonStyle(buttonToken),
|
|
|
|
genSizeBaseButtonStyle(buttonToken),
|
|
|
|
genSizeLargeButtonStyle(buttonToken),
|
2022-04-02 22:55:02 +08:00
|
|
|
|
2022-04-06 12:20:52 +08:00
|
|
|
// Group (type, ghost, danger, disabled, loading)
|
2022-06-24 11:11:42 +08:00
|
|
|
genTypeButtonStyle(buttonToken),
|
2022-04-22 22:36:50 +08:00
|
|
|
|
|
|
|
// Button Group
|
2022-06-24 11:11:42 +08:00
|
|
|
genGroupStyle(buttonToken),
|
|
|
|
];
|
|
|
|
});
|