diff --git a/components/button/style/index.ts b/components/button/style/index.ts index 7f001cd9d6..bdce1c754f 100644 --- a/components/button/style/index.ts +++ b/components/button/style/index.ts @@ -7,14 +7,13 @@ import { genComponentStyleHook, mergeToken } from '../../theme/internal'; import genGroupStyle from './group'; /** Component only token. Which will handle additional calculation of alias token */ -export interface ComponentToken { - buttonFontWeight: number; -} +export interface ComponentToken {} export interface ButtonToken extends FullToken<'Button'> { colorOutlineDefault: string; buttonPaddingHorizontal: number; buttonIconOnlyFontSize: number; + buttonFontWeight: number; } // ============================== Shared ============================== @@ -504,41 +503,36 @@ const genBlockButtonStyle: GenerateStyle = (token) => { }; // ============================== Export ============================== -export default genComponentStyleHook( - 'Button', - (token) => { - const { controlTmpOutline, paddingContentHorizontal } = token; - - const buttonToken = mergeToken(token, { - colorOutlineDefault: controlTmpOutline, - buttonPaddingHorizontal: paddingContentHorizontal, - buttonIconOnlyFontSize: token.fontSizeLG, - }); - - return [ - // Shared - genSharedButtonStyle(buttonToken), - - // Size - genSizeSmallButtonStyle(buttonToken), - genSizeBaseButtonStyle(buttonToken), - genSizeLargeButtonStyle(buttonToken), - - // Block - genBlockButtonStyle(buttonToken), - - // Group (type, ghost, danger, disabled, loading) - genTypeButtonStyle(buttonToken), - - // Button Group - genGroupStyle(buttonToken), - - // Space Compact - genCompactItemStyle(token), - genCompactItemVerticalStyle(token), - ]; - }, - { +export default genComponentStyleHook('Button', (token) => { + const { controlTmpOutline, paddingContentHorizontal } = token; + + const buttonToken = mergeToken(token, { + colorOutlineDefault: controlTmpOutline, + buttonPaddingHorizontal: paddingContentHorizontal, + buttonIconOnlyFontSize: token.fontSizeLG, buttonFontWeight: 400, - }, -); + }); + + return [ + // Shared + genSharedButtonStyle(buttonToken), + + // Size + genSizeSmallButtonStyle(buttonToken), + genSizeBaseButtonStyle(buttonToken), + genSizeLargeButtonStyle(buttonToken), + + // Block + genBlockButtonStyle(buttonToken), + + // Group (type, ghost, danger, disabled, loading) + genTypeButtonStyle(buttonToken), + + // Button Group + genGroupStyle(buttonToken), + + // Space Compact + genCompactItemStyle(token), + genCompactItemVerticalStyle(token), + ]; +}); diff --git a/components/drawer/__tests__/__snapshots__/demo-extend.test.tsx.snap b/components/drawer/__tests__/__snapshots__/demo-extend.test.tsx.snap index e52d4ad36f..a1a8cc55e6 100644 --- a/components/drawer/__tests__/__snapshots__/demo-extend.test.tsx.snap +++ b/components/drawer/__tests__/__snapshots__/demo-extend.test.tsx.snap @@ -99,6 +99,70 @@ Array [ ] `; +exports[`renders components/drawer/demo/component-token.tsx extend context correctly 1`] = ` +
+
+
+
+
+ +
+ Hello Title +
+
+
+
+ Hello Content +
+ +
+
+
+`; + exports[`renders components/drawer/demo/config-provider.tsx extend context correctly 1`] = `
`; +exports[`renders components/drawer/demo/component-token.tsx correctly 1`] = ` +
+
+
+
+
+ +
+ Hello Title +
+
+
+
+ Hello Content +
+ +
+
+
+`; + exports[`renders components/drawer/demo/config-provider.tsx correctly 1`] = `
( + +
+ + Hello Content + +
+
+); diff --git a/components/drawer/index.en-US.md b/components/drawer/index.en-US.md index 5244fc234c..e54cca9d93 100644 --- a/components/drawer/index.en-US.md +++ b/components/drawer/index.en-US.md @@ -34,6 +34,7 @@ A Drawer is a panel that is typically overlaid on top of a page and slides in fr No mask _InternalPanelDoNotUseOrYouWillBeFired Scroll Debug +Component Token ## API diff --git a/components/drawer/index.zh-CN.md b/components/drawer/index.zh-CN.md index 664984968f..6f6f9ec7cc 100644 --- a/components/drawer/index.zh-CN.md +++ b/components/drawer/index.zh-CN.md @@ -33,6 +33,7 @@ demo: 无遮罩 _InternalPanelDoNotUseOrYouWillBeFired 滚动锁定调试 +组件 Token ## API diff --git a/components/drawer/style/index.ts b/components/drawer/style/index.ts index 3fe3db3d5c..2630def032 100644 --- a/components/drawer/style/index.ts +++ b/components/drawer/style/index.ts @@ -4,8 +4,8 @@ import genMotionStyle from './motion'; export interface ComponentToken { zIndexPopup: number; - drawerFooterPaddingVertical: number; - drawerFooterPaddingHorizontal: number; + footerPaddingBlock: number; + footerPaddingInline: number; } export interface DrawerToken extends FullToken<'Drawer'> {} @@ -31,8 +31,8 @@ const genDrawerStyle: GenerateStyle = (token: DrawerToken) => { colorIconHover, colorText, fontWeightStrong, - drawerFooterPaddingVertical, - drawerFooterPaddingHorizontal, + footerPaddingBlock, + footerPaddingInline, } = token; const wrapperCls = `${componentCls}-content-wrapper`; @@ -200,7 +200,7 @@ const genDrawerStyle: GenerateStyle = (token: DrawerToken) => { // Footer [`${componentCls}-footer`]: { flexShrink: 0, - padding: `${drawerFooterPaddingVertical}px ${drawerFooterPaddingHorizontal}px`, + padding: `${footerPaddingBlock}px ${footerPaddingInline}px`, borderTop: `${lineWidth}px ${lineType} ${colorSplit}`, }, @@ -222,7 +222,7 @@ export default genComponentStyleHook( }, (token) => ({ zIndexPopup: token.zIndexPopupBase, - drawerFooterPaddingVertical: token.paddingXS, - drawerFooterPaddingHorizontal: token.padding, + footerPaddingBlock: token.paddingXS, + footerPaddingInline: token.padding, }), ); diff --git a/components/message/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/message/__tests__/__snapshots__/demo-extend.test.ts.snap index 241e18a520..9531a5c88f 100644 --- a/components/message/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/message/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -1,5 +1,42 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`renders components/message/demo/component-token.tsx extend context correctly 1`] = ` +
+
+
+ + + + + Hello World! + +
+
+
+`; + exports[`renders components/message/demo/custom-style.tsx extend context correctly 1`] = `
+`; + exports[`renders components/message/demo/custom-style.tsx correctly 1`] = ` `; +exports[`renders components/modal/demo/component-token.tsx extend context correctly 1`] = ` +
+