feat: Tree add indentWidth token (#50989)

This commit is contained in:
afc163 2024-09-25 10:33:01 +08:00 committed by GitHub
parent a172d070c9
commit 9c3478ed77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 6 deletions

View File

@ -48,6 +48,7 @@ const App: React.FC = () => {
Tree: {
nodeHoverBg: '#fff2f0',
nodeSelectedBg: '#ffa39e',
indentWidth: 80,
},
},
}}

View File

@ -13,6 +13,11 @@ export interface TreeSharedToken {
* @descEN Node title height
*/
titleHeight: number;
/**
* @desc
* @descEN Indent width of tree
*/
indentWidth?: number;
/**
* @desc
* @descEN Background color of hovered node
@ -94,7 +99,15 @@ type TreeToken = FullToken<'Tree'> & {
};
export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject => {
const { treeCls, treeNodeCls, treeNodePadding, titleHeight, nodeSelectedBg, nodeHoverBg } = token;
const {
treeCls,
treeNodeCls,
treeNodePadding,
titleHeight,
indentWidth,
nodeSelectedBg,
nodeHoverBg,
} = token;
const treeCheckBoxMarginHorizontal = token.paddingXS;
return {
@ -223,7 +236,7 @@ export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject =>
userSelect: 'none',
'&-unit': {
display: 'inline-block',
width: titleHeight,
width: indentWidth,
},
},
@ -534,12 +547,14 @@ export const genTreeStyle = (
};
export const initComponentToken = (token: AliasToken): TreeSharedToken => {
const { controlHeightSM } = token;
const { controlHeightSM, controlItemBgHover, controlItemBgActive } = token;
const titleHeight = controlHeightSM;
return {
titleHeight: controlHeightSM,
nodeHoverBg: token.controlItemBgHover,
nodeSelectedBg: token.controlItemBgActive,
titleHeight,
indentWidth: titleHeight,
nodeHoverBg: controlItemBgHover,
nodeSelectedBg: controlItemBgActive,
};
};