Skip to content

Commit

Permalink
navigator: updated styling for children of root nodes (#11967)
Browse files Browse the repository at this point in the history
The commit updates the styling for children root nodes in file-tree-widgets so that they include additional padding compared to the root which is often displayed as a tree-view section. The change helps more easily identify the hierarchy of the tree.
  • Loading branch information
EstFoisy authored Jan 16, 2023
1 parent f94ad05 commit d383fe2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/browser/tree/tree-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
} else {
classNames.push(renderIndentGuides === 'onHover' ? 'hover' : 'always');
}
const paddingLeft = this.props.leftPadding * depth;
const paddingLeft = this.getDepthPadding(depth);
indentDivs.unshift(<div key={depth} className={classNames.join(' ')} style={{
paddingLeft: `${paddingLeft}px`
}} />);
Expand Down Expand Up @@ -969,7 +969,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
}

protected getPaddingLeft(node: TreeNode, props: NodeProps): number {
return props.depth * this.props.leftPadding + (this.needsExpansionTogglePadding(node) ? this.props.expansionTogglePadding : 0);
return this.getDepthPadding(props.depth) + (this.needsExpansionTogglePadding(node) ? this.props.expansionTogglePadding : 0);
}

/**
Expand Down Expand Up @@ -1419,7 +1419,9 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
protected toNodeDescription(node: TreeNode): string {
return this.labelProvider.getLongName(node);
}

protected getDepthPadding(depth: number): number {
return depth * this.props.leftPadding;
}
}
export namespace TreeWidget {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,8 @@ export class FileTreeWidget extends CompressedTreeWidget {
return inflated;
}

protected override getDepthPadding(depth: number): number {
// add additional depth so file nodes are rendered with padding in relation to the top level root node.
return super.getDepthPadding(depth + 1);
}
}

0 comments on commit d383fe2

Please sign in to comment.