Skip to content

Commit

Permalink
Explorer: added styling for nodes at root
Browse files Browse the repository at this point in the history
of workspace

Added a tabbing for the child nodes of a root, to have a visual
difference and avoid confusion
  • Loading branch information
Estelle Foisy committed Jan 12, 2023
1 parent 73f32f7 commit 7df9bc5
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 7df9bc5

Please sign in to comment.