feat: Button support buttonFontWeight (#42121)

This commit is contained in:
MadCcc 2023-05-04 13:39:38 +08:00 committed by GitHub
parent 4a4eae5221
commit 4cf6f1b83b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,9 @@ import { genComponentStyleHook, mergeToken } from '../../theme/internal';
import genGroupStyle from './group';
/** Component only token. Which will handle additional calculation of alias token */
export interface ComponentToken {}
export interface ComponentToken {
buttonFontWeight: number;
}
export interface ButtonToken extends FullToken<'Button'> {
colorOutlineDefault: string;
@ -17,14 +19,14 @@ export interface ButtonToken extends FullToken<'Button'> {
// ============================== Shared ==============================
const genSharedButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token): CSSObject => {
const { componentCls, iconCls } = token;
const { componentCls, iconCls, buttonFontWeight } = token;
return {
[componentCls]: {
outline: 'none',
position: 'relative',
display: 'inline-block',
fontWeight: 400,
fontWeight: buttonFontWeight,
whiteSpace: 'nowrap',
textAlign: 'center',
backgroundImage: 'none',
@ -502,35 +504,41 @@ const genBlockButtonStyle: GenerateStyle<ButtonToken> = (token) => {
};
// ============================== Export ==============================
export default genComponentStyleHook('Button', (token) => {
const { controlTmpOutline, paddingContentHorizontal } = token;
export default genComponentStyleHook(
'Button',
(token) => {
const { controlTmpOutline, paddingContentHorizontal } = token;
const buttonToken = mergeToken<ButtonToken>(token, {
colorOutlineDefault: controlTmpOutline,
buttonPaddingHorizontal: paddingContentHorizontal,
buttonIconOnlyFontSize: token.fontSizeLG,
});
const buttonToken = mergeToken<ButtonToken>(token, {
colorOutlineDefault: controlTmpOutline,
buttonPaddingHorizontal: paddingContentHorizontal,
buttonIconOnlyFontSize: token.fontSizeLG,
});
return [
// Shared
genSharedButtonStyle(buttonToken),
return [
// Shared
genSharedButtonStyle(buttonToken),
// Size
genSizeSmallButtonStyle(buttonToken),
genSizeBaseButtonStyle(buttonToken),
genSizeLargeButtonStyle(buttonToken),
// Size
genSizeSmallButtonStyle(buttonToken),
genSizeBaseButtonStyle(buttonToken),
genSizeLargeButtonStyle(buttonToken),
// Block
genBlockButtonStyle(buttonToken),
// Block
genBlockButtonStyle(buttonToken),
// Group (type, ghost, danger, disabled, loading)
genTypeButtonStyle(buttonToken),
// Group (type, ghost, danger, disabled, loading)
genTypeButtonStyle(buttonToken),
// Button Group
genGroupStyle(buttonToken),
// Button Group
genGroupStyle(buttonToken),
// Space Compact
genCompactItemStyle(token),
genCompactItemVerticalStyle(token),
];
});
// Space Compact
genCompactItemStyle(token),
genCompactItemVerticalStyle(token),
];
},
{
buttonFontWeight: 400,
},
);