Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explorer: added styling for nodes at root #11967

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}