mirror of
https://github.com/ant-design/ant-design.git
synced 2025-07-31 12:18:42 +08:00
fix: token calc of padding input (#52865)
This commit is contained in:
parent
0e8ed2cb66
commit
a8f116f8b4
@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import { UserOutlined } from '@ant-design/icons';
|
||||
import { ConfigProvider, Input } from 'antd';
|
||||
|
||||
const App: React.FC = () => (
|
||||
@ -12,6 +13,9 @@ const App: React.FC = () => (
|
||||
>
|
||||
<Input placeholder="Basic usage" />
|
||||
</ConfigProvider>
|
||||
<ConfigProvider theme={{ components: { Input: { inputFontSize: 10 } } }}>
|
||||
<Input placeholder="With prefix" prefix={<UserOutlined />} />
|
||||
</ConfigProvider>
|
||||
</>
|
||||
);
|
||||
|
||||
|
@ -103,7 +103,9 @@ export function initInputToken(token: AliasToken): SharedInputToken {
|
||||
});
|
||||
}
|
||||
|
||||
export const initComponentToken = (token: AliasToken): SharedComponentToken => {
|
||||
export const initComponentToken = (
|
||||
token: AliasToken & Partial<SharedComponentToken>,
|
||||
): SharedComponentToken => {
|
||||
const {
|
||||
controlHeight,
|
||||
fontSize,
|
||||
@ -124,19 +126,26 @@ export const initComponentToken = (token: AliasToken): SharedComponentToken => {
|
||||
colorErrorOutline,
|
||||
colorWarningOutline,
|
||||
colorBgContainer,
|
||||
inputFontSize,
|
||||
inputFontSizeLG,
|
||||
inputFontSizeSM,
|
||||
} = token;
|
||||
|
||||
const mergedFontSize = inputFontSize || fontSize;
|
||||
const mergedFontSizeSM = inputFontSizeSM || mergedFontSize;
|
||||
const mergedFontSizeLG = inputFontSizeLG || fontSizeLG;
|
||||
|
||||
return {
|
||||
paddingBlock: Math.max(
|
||||
Math.round(((controlHeight - fontSize * lineHeight) / 2) * 10) / 10 - lineWidth,
|
||||
Math.round(((controlHeight - mergedFontSize * lineHeight) / 2) * 10) / 10 - lineWidth,
|
||||
0,
|
||||
),
|
||||
paddingBlockSM: Math.max(
|
||||
Math.round(((controlHeightSM - fontSize * lineHeight) / 2) * 10) / 10 - lineWidth,
|
||||
Math.round(((controlHeightSM - mergedFontSizeSM * lineHeight) / 2) * 10) / 10 - lineWidth,
|
||||
0,
|
||||
),
|
||||
paddingBlockLG:
|
||||
Math.ceil(((controlHeightLG - fontSizeLG * lineHeightLG) / 2) * 10) / 10 - lineWidth,
|
||||
Math.ceil(((controlHeightLG - mergedFontSizeLG * lineHeightLG) / 2) * 10) / 10 - lineWidth,
|
||||
paddingInline: paddingSM - lineWidth,
|
||||
paddingInlineSM: controlPaddingHorizontalSM - lineWidth,
|
||||
paddingInlineLG: controlPaddingHorizontal - lineWidth,
|
||||
@ -148,8 +157,8 @@ export const initComponentToken = (token: AliasToken): SharedComponentToken => {
|
||||
warningActiveShadow: `0 0 0 ${controlOutlineWidth}px ${colorWarningOutline}`,
|
||||
hoverBg: colorBgContainer,
|
||||
activeBg: colorBgContainer,
|
||||
inputFontSize: fontSize,
|
||||
inputFontSizeLG: fontSizeLG,
|
||||
inputFontSizeSM: fontSize,
|
||||
inputFontSize: mergedFontSize,
|
||||
inputFontSizeLG: mergedFontSizeLG,
|
||||
inputFontSizeSM: mergedFontSizeSM,
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user