Skip to content

Commit 3e03b77

Browse files
committed
docs: add treeview demo stories
Signed-off-by: Akshat Patel <akshat@live.ca>
1 parent eda96b2 commit 3e03b77

File tree

3 files changed

+452
-0
lines changed

3 files changed

+452
-0
lines changed

src/icon/icon.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import ErrorFilled16 from "@carbon/icons/es/error--filled/16";
3838
import ErrorFilled20 from "@carbon/icons/es/error--filled/20";
3939
import Fade16 from "@carbon/icons/es/fade/16";
4040
import Fade20 from "@carbon/icons/es/fade/20";
41+
import Folder16 from "@carbon/icons/es/folder/16";
4142
import Incomplete16 from "@carbon/icons/es/incomplete/16";
4243
import InformationFilled16 from "@carbon/icons/es/information--filled/16";
4344
import InformationFilled20 from "@carbon/icons/es/information--filled/20";
@@ -118,6 +119,7 @@ export class IconModule {
118119
ErrorFilled20,
119120
Fade16,
120121
Fade20,
122+
Folder16,
121123
Incomplete16,
122124
InformationFilled16,
123125
InformationFilled20,
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
import { AfterViewInit, Component, TemplateRef, ViewChild } from "@angular/core";
2+
import { Node } from "../tree-node.types";
3+
4+
@Component({
5+
selector: "app-treeview-icon-component",
6+
template: `
7+
<cds-tree-view
8+
label="Tree view"
9+
style="width: 18rem; display: block;"
10+
[tree]="tree">
11+
</cds-tree-view>
12+
13+
<ng-template #document>
14+
<svg cdsIcon="document" class="cds--tree-node__icon" size="16"></svg>
15+
</ng-template>
16+
`
17+
})
18+
export class IconTreeviewDemoComponent implements AfterViewInit {
19+
20+
tree: Node[] = [];
21+
22+
@ViewChild("document") documentIcon: TemplateRef<any>;
23+
24+
constructor() { }
25+
26+
ngAfterViewInit() {
27+
// Wait for the view child to be picked up
28+
this.tree = [
29+
{
30+
id: "1",
31+
value: "Artificial intelligence",
32+
label: "Artificial intelligence",
33+
icon: this.documentIcon
34+
},
35+
{
36+
id: "2",
37+
value: "Blockchain",
38+
label: "Blockchain",
39+
icon: this.documentIcon
40+
},
41+
{
42+
id: "3",
43+
value: "Business automation",
44+
label: "Business automation",
45+
children: [
46+
{
47+
id: "3-1",
48+
value: "Business process automation",
49+
label: "Business process automation",
50+
icon: this.documentIcon
51+
},
52+
{
53+
id: "3-2",
54+
value: "Business process mapping",
55+
label: "Business process mapping",
56+
icon: this.documentIcon
57+
}
58+
],
59+
icon: "folder"
60+
},
61+
{
62+
id: "4",
63+
value: "Business operations",
64+
label: "Business operations",
65+
icon: this.documentIcon
66+
},
67+
{
68+
id: "5",
69+
value: "Cloud computing",
70+
label: "Cloud computing",
71+
"expanded": true,
72+
children: [
73+
{
74+
id: "5-1",
75+
value: "Containers",
76+
label: "Containers",
77+
icon: this.documentIcon
78+
},
79+
{
80+
id: "5-2",
81+
value: "Databases",
82+
label: "Databases",
83+
icon: this.documentIcon
84+
},
85+
{
86+
id: "5-3",
87+
value: "DevOps",
88+
label: "DevOps",
89+
"expanded": true,
90+
children: [
91+
{
92+
id: "5-4",
93+
value: "Solutions",
94+
label: "Solutions",
95+
icon: this.documentIcon
96+
},
97+
{
98+
id: "5-5",
99+
value: "Case studies",
100+
label: "Case studies",
101+
"expanded": true,
102+
children: [
103+
{
104+
id: "5-6",
105+
value: "Resources",
106+
label: "Resources",
107+
icon: this.documentIcon
108+
}
109+
],
110+
icon: "folder"
111+
}
112+
],
113+
icon: "folder"
114+
}
115+
],
116+
icon: "folder"
117+
},
118+
{
119+
id: "6",
120+
value: "Data & Analytics",
121+
label: "Data & Analytics",
122+
children: [
123+
{
124+
id: "6-1",
125+
value: "Big data",
126+
label: "Big data",
127+
icon: this.documentIcon
128+
},
129+
{
130+
id: "6-2",
131+
value: "Business intelligence",
132+
label: "Business intelligence",
133+
icon: this.documentIcon
134+
}
135+
],
136+
icon: "folder"
137+
},
138+
{
139+
id: "7",
140+
value: "IT infrastructure",
141+
label: "IT infrastructure",
142+
"expanded": true,
143+
"disabled": true,
144+
children: [
145+
{
146+
id: "7-1",
147+
value: "Data storage",
148+
label: "Data storage",
149+
icon: this.documentIcon
150+
},
151+
{
152+
id: "7-2",
153+
value: "Enterprise servers",
154+
label: "Enterprise servers",
155+
icon: this.documentIcon
156+
},
157+
{
158+
id: "8",
159+
value: "Hybrid cloud infrastructure",
160+
label: "Hybrid cloud infrastructure",
161+
"expanded": true,
162+
children: [
163+
{
164+
id: "8-1",
165+
value: "Insights",
166+
label: "Insights",
167+
icon: this.documentIcon
168+
},
169+
{
170+
id: "8-2",
171+
value: "Benefits",
172+
label: "Benefits",
173+
icon: this.documentIcon
174+
}
175+
],
176+
icon: "folder"
177+
}
178+
],
179+
icon: "folder"
180+
}
181+
];
182+
}
183+
}

0 commit comments

Comments
 (0)