From 34af3ec55016a70dd3b33ffb71500898d20549b1 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Tue, 9 May 2023 19:24:50 +0800 Subject: [PATCH] feat: component token rename (#42184) * feat: component token naming rules * dcos: update * feat: modal token rename * feat: rename result token * feat: statsitic token rename * feat: steps token remane * chore: update snapshot * chore: fix lint * feat: semantic part component * revert: button & notification * revert: files * chore: code clean --- components/button/style/index.ts | 72 +- .../__snapshots__/demo-extend.test.tsx.snap | 64 ++ .../__tests__/__snapshots__/demo.test.ts.snap | 64 ++ components/drawer/demo/component-token.md | 7 + components/drawer/demo/component-token.tsx | 17 + components/drawer/index.en-US.md | 1 + components/drawer/index.zh-CN.md | 1 + components/drawer/style/index.ts | 14 +- .../__snapshots__/demo-extend.test.ts.snap | 37 + .../__tests__/__snapshots__/demo.test.ts.snap | 37 + components/message/demo/component-token.md | 7 + components/message/demo/component-token.tsx | 20 + components/message/index.en-US.md | 3 +- components/message/index.zh-CN.md | 1 + components/message/style/index.tsx | 28 +- .../__snapshots__/demo-extend.test.ts.snap | 326 ++++++++ .../__snapshots__/demo.test.tsx.snap | 326 ++++++++ components/modal/demo/component-token.md | 7 + components/modal/demo/component-token.tsx | 39 + components/modal/index.en-US.md | 1 + components/modal/index.zh-CN.md | 1 + components/modal/style/index.tsx | 60 +- components/notification/style/index.tsx | 30 +- .../__snapshots__/demo-extend.test.ts.snap | 60 ++ .../__tests__/__snapshots__/demo.test.ts.snap | 60 ++ components/result/demo/component-token.md | 7 + components/result/demo/component-token.tsx | 31 + components/result/index.en-US.md | 1 + components/result/index.zh-CN.md | 1 + components/result/style/index.tsx | 55 +- .../__snapshots__/demo-extend.test.ts.snap | 101 +++ .../__tests__/__snapshots__/demo.test.ts.snap | 101 +++ components/statistic/demo/component-token.md | 7 + components/statistic/demo/component-token.tsx | 32 + components/statistic/index.en-US.md | 1 + components/statistic/index.zh-CN.md | 1 + components/statistic/style/index.tsx | 24 +- .../__snapshots__/demo-extend.test.ts.snap | 711 ++++++++++++++++++ .../__tests__/__snapshots__/demo.test.ts.snap | 711 ++++++++++++++++++ components/steps/demo/component-token.md | 7 + components/steps/demo/component-token.tsx | 134 ++++ components/steps/index.en-US.md | 1 + components/steps/index.zh-CN.md | 1 + components/steps/style/custom-icon.ts | 12 +- components/steps/style/index.tsx | 77 +- components/steps/style/label-placement.ts | 8 +- components/steps/style/nav.ts | 10 +- components/steps/style/progress-dot.ts | 50 +- components/steps/style/progress.ts | 10 +- components/steps/style/small.ts | 20 +- components/steps/style/vertical.ts | 14 +- docs/react/migrate-less-variables.en-US.md | 127 ++-- docs/react/migrate-less-variables.zh-CN.md | 121 ++- 53 files changed, 3266 insertions(+), 393 deletions(-) create mode 100644 components/drawer/demo/component-token.md create mode 100644 components/drawer/demo/component-token.tsx create mode 100644 components/message/demo/component-token.md create mode 100644 components/message/demo/component-token.tsx create mode 100644 components/modal/demo/component-token.md create mode 100644 components/modal/demo/component-token.tsx create mode 100644 components/result/demo/component-token.md create mode 100644 components/result/demo/component-token.tsx create mode 100644 components/statistic/demo/component-token.md create mode 100644 components/statistic/demo/component-token.tsx create mode 100644 components/steps/demo/component-token.md create mode 100644 components/steps/demo/component-token.tsx 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; +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), - ]; - }, - { + 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`] = ` +
+