Skip to content

Commit 04e1f4f

Browse files
authored
feat(design): add deep tree example (#3067)
1 parent b911d12 commit 04e1f4f

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

apps/design-land/src/app/tree/tree.component.html

+4
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ <h3>Basic Tree</h3>
1919
<design-land-example-viewer-container example="basic-tree">
2020
</design-land-example-viewer-container>
2121

22+
<h3>Deep Tree</h3>
23+
<design-land-example-viewer-container example="deep-tree">
24+
</design-land-example-viewer-container>
25+
2226
<h2>Accessibility</h2>
2327
<p>The <code>DaffTreeComponent</code> follows the specification for a <a href="https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/" target="_blank">disclosure navigation menu</a> instead of a <a href="https://www.w3.org/WAI/ARIA/apg/patterns/treeview/" target="_blank">tree view</a>.</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<ul daff-tree [tree]="tree">
2+
<ng-template #daffTreeItemWithChildrenTpl let-node>
3+
<button daffTreeItem [node]="node">{{ node.title }} </button>
4+
</ng-template>
5+
6+
<ng-template #daffTreeItemTpl let-node>
7+
<a daffTreeItem [node]="node" [routerLink]="node.url">{{ node.title }}</a>
8+
</ng-template>
9+
</ul>
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import {
2+
ChangeDetectionStrategy,
3+
Component,
4+
} from '@angular/core';
5+
import { RouterLink } from '@angular/router';
6+
7+
import {
8+
DaffTreeData,
9+
DaffTreeModule,
10+
} from '@daffodil/design/tree';
11+
12+
@Component({
13+
// eslint-disable-next-line @angular-eslint/component-selector
14+
selector: 'deep-tree',
15+
templateUrl: './deep-tree.component.html',
16+
changeDetection: ChangeDetectionStrategy.OnPush,
17+
standalone: true,
18+
imports: [DaffTreeModule, RouterLink],
19+
})
20+
export class DeepTreeComponent {
21+
tree: DaffTreeData<unknown> = {
22+
title: 'Root',
23+
items: [
24+
{
25+
title: 'Example Children',
26+
items: [
27+
{
28+
title: 'Example Child',
29+
url: '#',
30+
id: '',
31+
items: [
32+
{
33+
title: 'Nested Child',
34+
url: '#',
35+
id: '',
36+
items: [],
37+
data: {},
38+
},
39+
],
40+
data: {},
41+
},
42+
],
43+
url: '#',
44+
id: '',
45+
data: {},
46+
},
47+
{
48+
title: 'Example Link',
49+
items: [],
50+
url: '#',
51+
id: '',
52+
data: {},
53+
},
54+
],
55+
url: '',
56+
id: '',
57+
data: {},
58+
};
59+
}
+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { BasicTreeComponent } from './basic-tree/basic-tree.component';
2+
import { DeepTreeComponent } from './deep-tree/deep-tree.component';
23

3-
export { BasicTreeComponent };
4+
export {
5+
BasicTreeComponent,
6+
DeepTreeComponent,
7+
};
48

59
export const TREE_EXAMPLES = [
610
BasicTreeComponent,
11+
DeepTreeComponent,
712
];

0 commit comments

Comments
 (0)