From 5a86ee34ee9764aeede9632c45714cdc46775d23 Mon Sep 17 00:00:00 2001 From: Anveshreddy mekala Date: Wed, 4 Dec 2024 18:14:33 -0600 Subject: [PATCH 1/6] feat(tree,tree-item): update indentation --- .../src/components/tree-item/tree-item.scss | 107 +++++++----------- .../src/components/tree-item/tree-item.tsx | 33 +++--- 2 files changed, 61 insertions(+), 79 deletions(-) diff --git a/packages/calcite-components/src/components/tree-item/tree-item.scss b/packages/calcite-components/src/components/tree-item/tree-item.scss index 35cfb8714c1..22851769d37 100644 --- a/packages/calcite-components/src/components/tree-item/tree-item.scss +++ b/packages/calcite-components/src/components/tree-item/tree-item.scss @@ -17,20 +17,20 @@ .node-actions-container { @apply min-h-[1.5rem]; - .node-container { - .checkbox, - .checkmark, - .bullet-point { - margin-inline: theme("margin.1"); - } - .icon-start { - margin-inline: theme("margin.3"); - } - .chevron { - padding: theme("padding.1"); - } + .node-container, + .checkbox-container { + gap: 0.25rem; } } + .children-container { + margin-inline-start: theme("margin.3"); + } +} + +:host([scale="s"][lines]) { + .children-container ::slotted(*) { + padding-inline-start: 0.5rem; + } } :host([scale="m"]) { @@ -38,20 +38,19 @@ .node-actions-container { @apply min-h-[2rem]; - .node-container { - .checkbox, - .checkmark, - .bullet-point { - margin-inline: theme("margin.2"); - } - .icon-start { - margin-inline: theme("margin.3"); - } - .chevron { - padding: theme("padding.2"); - } + .node-container, + .checkbox-container { + gap: 0.5rem; } } + .children-container { + margin-inline-start: theme("margin.4"); + } +} +:host([scale="m"][lines]) { + .children-container ::slotted(*) { + padding-inline-start: 0.6rem; + } } :host([scale="l"]) { @@ -59,21 +58,20 @@ .node-actions-container { @apply min-h-[2.75rem]; - .node-container { - .checkbox, - .checkmark, - .bullet-point { - margin-inline: theme("margin.3"); - } - .icon-start { - margin-inline: theme("margin.3"); - } - .chevron { - padding-inline: var(--calcite-spacing-md); - padding-block: var(--calcite-spacing-sm-plus); - } + .node-container, + .checkbox-container { + gap: 0.75rem; } } + .children-container { + margin-inline-start: theme("margin.6"); + } +} + +:host([scale="l"][lines]) { + .children-container ::slotted(*) { + padding-inline-start: 0.8rem; + } } :host([lines]) { @@ -154,7 +152,7 @@ .children-container { @apply relative h-0 overflow-hidden opacity-0 origin-top; - margin-inline-start: theme("margin.5"); + // margin-inline-start: theme("margin.5"); transform: scaleY(0); transition: var(--calcite-animation-timing) $easing-function, @@ -198,35 +196,14 @@ } } -:host([selection-mode="none"]:not([has-children])) { - &:host([scale="s"]) .node-container { - padding-inline-start: theme("padding.2"); - } - &:host([scale="m"]) .node-container { - padding-inline-start: theme("padding.4"); - } - &:host([scale="l"]) .node-container { - padding-inline-start: theme("padding.6"); - } +:host([scale="s"]) .node-container { + padding-inline-start: theme("padding.1"); } - -// ancestors selection-mode, dropdown without children -:host(:not([has-children])) { - &:host([scale="s"]) .node-container[data-selection-mode="ancestors"] .checkbox { - padding-inline-start: theme("padding.5"); - } - &:host([scale="m"]) .node-container[data-selection-mode="ancestors"] .checkbox { - padding-inline-start: theme("padding.6"); - } - &:host([scale="l"]) .node-container[data-selection-mode="ancestors"] .checkbox { - padding-inline-start: 1.75rem; - } +:host([scale="m"]) .node-container { + padding-inline-start: theme("padding.2"); } -// ancestors selection-mode, dropdown with children -:host([has-children]) .node-container[data-selection-mode="ancestors"] { - .checkbox { - margin-inline-start: 0; - } +:host([scale="l"]) .node-container { + padding-inline-start: theme("padding.3"); } // dropdown with children diff --git a/packages/calcite-components/src/components/tree-item/tree-item.tsx b/packages/calcite-components/src/components/tree-item/tree-item.tsx index 941990ed8da..0daa035b74e 100644 --- a/packages/calcite-components/src/components/tree-item/tree-item.tsx +++ b/packages/calcite-components/src/components/tree-item/tree-item.tsx @@ -354,18 +354,19 @@ export class TreeItem extends LitElement implements InteractiveComponent { const showBlank = this.selectionMode === "none" && !this.hasChildren; const checkboxIsIndeterminate = this.hasChildren && this.indeterminate; - const chevron = this.hasChildren ? ( - - ) : null; + const chevron = + this.hasChildren || this.selectionMode === "ancestors" ? ( + + ) : null; const defaultSlotNode: JsxNode = ; const checkbox = @@ -382,7 +383,6 @@ export class TreeItem extends LitElement implements InteractiveComponent { } scale={getIconScale(this.scale)} /> - ) : null; const selectedIcon = showBulletPoint @@ -462,8 +462,13 @@ export class TreeItem extends LitElement implements InteractiveComponent { > {chevron} {itemIndicator} + {checkbox ? checkbox : null} {this.iconStart ? iconStartEl : null} - {checkbox ? checkbox : defaultSlotNode} + {checkbox ? ( + + ) : ( + defaultSlotNode + )}