Skip to content

Commit

Permalink
fix(comp:tree): modify tree line spacing (#1839)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Jan 29, 2024
1 parent fc63a44 commit f091062
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
42 changes: 18 additions & 24 deletions packages/components/tree/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,24 @@
position: relative;
color: var(--ix-tree-expand-icon-color);

@line-height: calc(var(--ix-tree-node-content-height) / 2 - var(--ix-margin-size-xs));
@line-offset: calc((var(--ix-tree-node-content-height) - var(--ix-font-size-icon)) / 2 - @line-height);

&-top-line {
position: absolute;
height: calc(var(--ix-tree-node-content-height) / 2 - 4px);
top: calc((var(--ix-tree-node-content-height) / 4 - 4px) * -1);
right: 50%;
height: @line-height;
top: @line-offset;
.vertical-line();
}
&-bottom-line {
position: absolute;
height: calc(var(--ix-tree-node-content-height) / 2 - 4px);
bottom: calc((var(--ix-tree-node-content-height) / 4 - 4px) * -1);
right: 50%;
height: @line-height;
bottom: @line-offset;
.vertical-line();
}

&::after {
position: absolute;
top: calc(50% - var(--ix-line-width) / 2);
right: 0;
right: var(--ix-margin-size-2xs);
width: calc((var(--ix-tree-node-icon-width) - var(--ix-font-size-icon)) / 2);
z-index: 1;
.horizontal-line();
Expand All @@ -106,10 +105,8 @@
&:not(&-expanded):not(&-last) {
.@{tree-node-prefix}-expand {
&::before {
position: absolute;
top: calc(var(--ix-tree-node-content-height) - 6px);
right: 50%;
height: calc(var(--ix-tree-node-content-height) / 2 - 4px);
height: calc(var(--ix-tree-node-content-height) / 2 - var(--ix-margin-size-xs));
z-index: 1;
.vertical-line();

Expand All @@ -128,9 +125,7 @@
height: 100%;

&::before {
position: absolute;
top: calc(var(--ix-tree-node-padding-vertical) * -1);
right: calc(var(--ix-tree-node-icon-width) / 2);
bottom: calc(var(--ix-tree-node-padding-vertical) * -1);
.vertical-line();

Expand All @@ -155,7 +150,7 @@
position: relative;
display: flex;
align-items: center;
padding: var(--ix-tree-node-padding-vertical) 0;
padding: var(--ix-tree-node-padding-vertical) var(--ix-tree-node-padding-horizontal);
white-space: nowrap;

.@{icon-prefix} {
Expand Down Expand Up @@ -190,7 +185,7 @@
height: var(--ix-tree-node-content-height);
display: flex;
align-items: center;
justify-content: center;
justify-content: start;
cursor: pointer;

&-noop {
Expand All @@ -199,7 +194,7 @@
}

& &-checkbox {
margin: var(--ix-tree-node-checkbox-margin);
margin-right: var(--ix-tree-node-checkbox-margin-right);
}

&-leaf {
Expand All @@ -208,7 +203,7 @@
text-align: center;
display: flex;
align-items: center;
justify-content: center;
justify-content: left;
cursor: default;

&-line {
Expand All @@ -219,9 +214,7 @@
width: 100%;

&::before {
position: absolute;
top: calc(var(--ix-tree-node-padding-vertical) * -1);
right: calc(var(--ix-tree-node-icon-width) / 2);
bottom: calc(var(--ix-tree-node-padding-vertical) * -1);
.vertical-line();

Expand All @@ -232,8 +225,8 @@
position: absolute;
top: calc(50% - var(--ix-line-width));
bottom: 0;
left: 50%;
right: 0;
left: calc(var(--ix-font-size-icon) / 2);
right: var(--ix-margin-size-2xs);
.horizontal-line();

content: ' ';
Expand All @@ -248,7 +241,6 @@
min-height: var(--ix-tree-node-content-height);
line-height: var(--ix-tree-node-content-height);
transition: background-color var(--ix-motion-duration-medium);
padding: var(--ix-tree-node-content-padding);

&:hover {
background-color: var(--ix-tree-node-bg-color-hover);
Expand All @@ -260,11 +252,13 @@
justify-items: center;
align-items: center;
}
&-prefix {
margin-right: var(--ix-tree-node-content-prefix-margin-right);
}

&-label {
display: inline-block;
flex-grow: 1;
padding: var(--ix-tree-node-content-label-padding);

&-highlight {
color: var(--ix-tree-node-content-label-highlight-color);
Expand Down
4 changes: 2 additions & 2 deletions packages/components/tree/style/mixin.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
.horizontal-line() {
height: var(--ix-line-width);
background-color: var(--ix-color-separator);
background-size: 3px 100%;
}

.vertical-line() {
position: absolute;
left: calc(var(--ix-font-size-icon) / 2);
width: var(--ix-line-width);
background-color: var(--ix-color-separator);
background-size: 100% 3px;
}
10 changes: 4 additions & 6 deletions packages/components/tree/theme/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export function getDefaultThemeTokens(tokens: GlobalThemeTokens): CertainThemeTo
const {
heightMd,
heightSm,
fontSizeIcon,
marginSizeXs,
paddingSizeXs,
paddingSizeSm,
colorPrimaryHover,
colorPrimaryText,
colorContainerBgHover,
Expand All @@ -33,13 +30,14 @@ export function getDefaultThemeTokens(tokens: GlobalThemeTokens): CertainThemeTo

nodeColorSelected: colorPrimaryText,

nodePaddingHorizontal: marginSizeXs,
nodePaddingVertical: `0px`,
nodeContentHeight: heightMd,
nodeContentPadding: `0 ${paddingSizeSm}px 0 ${paddingSizeXs}px`,
nodeContentLabelPadding: `0 ${paddingSizeXs}px`,
nodeContentLabelHighlightColor: colorPrimaryText,

nodeCheckboxMargin: `0 ${marginSizeXs}px 0 ${Math.max((fontSizeIcon - nodeIconWidth) / 2 + 1, 1)}px`,
nodeContentPrefixMarginRight: marginSizeXs,

nodeCheckboxMarginRight: marginSizeXs,
nodeIconWidth,
expandIconColor: colorIconInfo,
}
Expand Down
7 changes: 4 additions & 3 deletions packages/components/tree/theme/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ export interface TreeThemeTokens {

nodeColorSelected: string

nodePaddingHorizontal: string | number
nodePaddingVertical: string | number
nodeContentHeight: number
nodeContentPadding: string | number
nodeContentLabelPadding: string | number
nodeContentLabelHighlightColor: string

nodeCheckboxMargin: string
nodeContentPrefixMarginRight: number
nodeCheckboxMarginRight: number

nodeIconWidth: number
expandIconColor: string
}

0 comments on commit f091062

Please sign in to comment.