From e597fe8ec6d9c3a6cb2982a511790b957d0f1bf4 Mon Sep 17 00:00:00 2001
From: lijianan <574980606@qq.com>
Date: Fri, 6 Jan 2023 09:46:00 +0800
Subject: [PATCH] fix: Button block prop not work (#39992)
* fix: Button block prop not work
* fix
* remove auto
* update demo
* fix
* fix
* fix width
* fix
* update demo
---
.../__snapshots__/demo-extend.test.ts.snap | 56 +++++++++++++++++++
.../__tests__/__snapshots__/demo.test.ts.snap | 56 +++++++++++++++++++
components/button/demo/debug-block.md | 7 +++
components/button/demo/debug-block.tsx | 14 +++++
components/button/index.en-US.md | 1 +
components/button/index.zh-CN.md | 1 +
components/button/style/index.ts | 31 ++++++----
7 files changed, 154 insertions(+), 12 deletions(-)
create mode 100644 components/button/demo/debug-block.md
create mode 100644 components/button/demo/debug-block.tsx
diff --git a/components/button/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/button/__tests__/__snapshots__/demo-extend.test.ts.snap
index 7a5635f723..dc6ab5dbae 100644
--- a/components/button/__tests__/__snapshots__/demo-extend.test.ts.snap
+++ b/components/button/__tests__/__snapshots__/demo-extend.test.ts.snap
@@ -423,6 +423,62 @@ exports[`renders ./components/button/demo/danger.tsx extend context correctly 1`
`;
+exports[`renders ./components/button/demo/debug-block.tsx extend context correctly 1`] = `
+
`;
+exports[`renders ./components/button/demo/debug-block.tsx correctly 1`] = `
+
+`;
+
exports[`renders ./components/button/demo/debug-icon.tsx correctly 1`] = `
Array [
(
+
+
+ } />
+
+);
+
+export default App;
diff --git a/components/button/index.en-US.md b/components/button/index.en-US.md
index 335f642585..0cdc009294 100644
--- a/components/button/index.en-US.md
+++ b/components/button/index.en-US.md
@@ -36,6 +36,7 @@ And 4 other properties additionally.
Type
Icon
Debug Icon
+Debug Block
Size
Disabled
Loading
diff --git a/components/button/index.zh-CN.md b/components/button/index.zh-CN.md
index 907ae592cc..e79e9850e9 100644
--- a/components/button/index.zh-CN.md
+++ b/components/button/index.zh-CN.md
@@ -39,6 +39,7 @@ group:
按钮类型
图标按钮
调试图标按钮
+调试按钮block属性
按钮尺寸
不可用状态
加载中状态
diff --git a/components/button/style/index.ts b/components/button/style/index.ts
index 574b9a6133..59142b72c8 100644
--- a/components/button/style/index.ts
+++ b/components/button/style/index.ts
@@ -113,7 +113,6 @@ const genRoundButtonStyle: GenerateStyle = (token) => ({
borderRadius: token.controlHeight,
paddingInlineStart: token.controlHeight / 2,
paddingInlineEnd: token.controlHeight / 2,
- width: 'auto',
});
// =============================== Type ===============================
@@ -390,13 +389,19 @@ const genTypeButtonStyle: GenerateStyle = (token) => {
// =============================== Size ===============================
const genSizeButtonStyle = (token: ButtonToken, sizePrefixCls: string = ''): CSSInterpolation => {
- const { componentCls, iconCls } = token;
+ const {
+ componentCls,
+ iconCls,
+ controlHeight,
+ fontSize,
+ lineHeight,
+ lineWidth,
+ borderRadius,
+ buttonPaddingHorizontal,
+ } = token;
- const paddingVertical = Math.max(
- 0,
- (token.controlHeight - token.fontSize * token.lineHeight) / 2 - token.lineWidth,
- );
- const paddingHorizontal = token.buttonPaddingHorizontal - token.lineWidth;
+ const paddingVertical = Math.max(0, (controlHeight - fontSize * lineHeight) / 2 - lineWidth);
+ const paddingHorizontal = buttonPaddingHorizontal - lineWidth;
const iconOnlyCls = `${componentCls}-icon-only`;
@@ -404,16 +409,18 @@ const genSizeButtonStyle = (token: ButtonToken, sizePrefixCls: string = ''): CSS
// Size
{
[`${componentCls}${sizePrefixCls}`]: {
- fontSize: token.fontSize,
- height: token.controlHeight,
+ fontSize,
+ height: controlHeight,
padding: `${paddingVertical}px ${paddingHorizontal}px`,
- borderRadius: token.borderRadius,
+ borderRadius,
[`&${iconOnlyCls}`]: {
- width: token.controlHeight,
+ width: controlHeight,
paddingInlineStart: 0,
paddingInlineEnd: 0,
-
+ [`&${componentCls}-round`]: {
+ width: 'auto',
+ },
'> span': {
transform: 'scale(1.143)', // 14px -> 16px
},