feat: Tree component adds nodeHoverColor and nodeSelectedColor tokens (#51367)

Co-authored-by: zmbxy <zhaoqingwei@wangtai-tech.com>
This commit is contained in:
zmbxy 2024-10-27 00:06:02 +08:00 committed by GitHub
parent 158b4c7539
commit a8d9aeecbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View File

@ -47,7 +47,9 @@ const App: React.FC = () => {
components: {
Tree: {
nodeHoverBg: '#fff2f0',
nodeHoverColor: '#1677ff',
nodeSelectedBg: '#ffa39e',
nodeSelectedColor: '#fff',
indentSize: 80,
},
},

View File

@ -23,11 +23,21 @@ export interface TreeSharedToken {
* @descEN Background color of hovered node
*/
nodeHoverBg: string;
/**
* @desc
* @descEN Text color of hovered node
*/
nodeHoverColor: string;
/**
* @desc
* @descEN Background color of selected node
*/
nodeSelectedBg: string;
/**
* @desc
* @descEN Text color of selected node
*/
nodeSelectedColor: string;
}
export interface ComponentToken extends TreeSharedToken {
@ -194,6 +204,16 @@ export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject =>
},
},
// not disable
[`&:not(${treeNodeCls}-disabled)`]: {
// >>> Title
[`${treeCls}-node-content-wrapper`]: {
'&:hover': {
color: token.nodeHoverColor,
},
},
},
[`&-active ${treeCls}-node-content-wrapper`]: {
background: token.controlItemBgHover,
},
@ -354,6 +374,7 @@ export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject =>
},
[`&${treeCls}-node-selected`]: {
color: token.nodeSelectedColor,
backgroundColor: nodeSelectedBg,
},
@ -558,7 +579,9 @@ export const initComponentToken = (token: AliasToken): TreeSharedToken => {
titleHeight,
indentSize: titleHeight,
nodeHoverBg: controlItemBgHover,
nodeHoverColor: token.colorText,
nodeSelectedBg: controlItemBgActive,
nodeSelectedColor: token.colorText,
};
};