Skip to content

Commit

Permalink
feat: colapsable tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
domiSchenk committed Aug 4, 2021
1 parent 743f6da commit a2f4ee7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,17 @@
</div>

<div *ngSwitchDefault class="comander-tree-row commander-tree-folder-row">
<cds-icon shape="folder-open" solid="true"></cds-icon>
<span class="comander-tree-row-text">
<ng-container *ngIf="!node.hideChildren">
<cds-icon shape="angle" class="commander-tree-arrow" size="sm" direction="down"
(click)="hideChild(node)"></cds-icon>
<cds-icon shape="folder-open" solid="true" (click)="hideChild(node)"></cds-icon>
</ng-container>
<ng-container *ngIf="node.hideChildren">
<cds-icon shape="angle" class="commander-tree-arrow" direction="right" (click)="hideChild(node)">
</cds-icon>
<cds-icon shape="folder" solid="true" (click)="hideChild(node)"></cds-icon>
</ng-container>
<span cds-text="secondary" class="comander-tree-row-text" (click)="hideChild(node)">
{{node.name}}
</span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ cds-textarea {
--cds-global-layout-space-xxl: 32px;
--padding: var(--cds-global-space-4)
}

.commander-tree-arrow {
--color: var(--cds-global-color-warm-gray-400);
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,8 @@ export class RepositoryCommitComponent implements OnInit {
}


hideChild(node: any) {
node.hideChildren = !node.hideChildren;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ng-container>

</div>
<ng-container *ngIf="node.children.length > 0">
<ng-container *ngIf="node.children.length > 0 && !node.hideChildren">
<ng-container *ngTemplateOutlet="recursiveListTmpl; context:{ list: node.children, index: index+1 }">
</ng-container>
</ng-container>
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/components/tree-view/tree-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export class TreeViewComponent implements OnInit {
ngOnInit(): void {
}


}
4 changes: 3 additions & 1 deletion src/theme/tree.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@
display: grid !important;
grid-template-columns: 16px 1fr 0 0 auto;
box-sizing: border-box !important;
margin-left: 16px;
&:hover {
grid-template-columns: 16px 1fr 24px 24px auto;
}
}

.commander-tree-folder-row {
display: grid !important;
grid-template-columns: 16px 1fr auto;
grid-template-columns: 16px 16px 1fr auto;
}

.comander-tree-title {
Expand All @@ -76,6 +77,7 @@

.commander-tree-item {
--base-padding: 10px;
cursor: pointer;
&:hover {
background: var(--cds-global-color-gray-100);
}
Expand Down

0 comments on commit a2f4ee7

Please sign in to comment.