Skip to content

Commit d15ddbd

Browse files
committed
feat(aria/tree): adds tree-rtl-active-descendant-example to dev-app
Creates tree-rtl-active-descendant-example and adds it to the dev-app.
1 parent 0b6c31a commit d15ddbd

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
lines changed

src/components-examples/aria/tree/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export {TreeDisabledSkippedExample} from './tree-disabled-skipped/tree-disabled-
66
export {TreeMultiSelectExample} from './tree-multi-select/tree-multi-select-example';
77
export {TreeMultiSelectFollowFocusExample} from './tree-multi-select-follow-focus/tree-multi-select-follow-focus-example';
88
export {TreeNavExample} from './tree-nav/tree-nav-example';
9+
export {TreeRtlActiveDescendantExample} from './tree-rtl-active-descendant/tree-rtl-active-descendant-example';
910
export {TreeSingleSelectExample} from './tree-single-select/tree-single-select-example';
1011
export {TreeSingleSelectFollowFocusExample} from './tree-single-select-follow-focus/tree-single-select-follow-focus-example';

src/components-examples/aria/tree/tree-common.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@
4444
transform: rotate(90deg);
4545
}
4646

47+
.example-tree[dir='rtl'] .example-tree-item .example-parent-icon {
48+
transform: scaleX(-1);
49+
}
50+
51+
.example-tree[dir='rtl'] .example-tree-item[aria-expanded='true'] .example-parent-icon {
52+
transform: scaleX(-1) rotate(90deg);
53+
}
54+
55+
4756
.example-selected-icon {
4857
visibility: hidden;
4958
margin-left: auto;
@@ -57,3 +66,7 @@
5766
li[aria-expanded='false'] + ul[role='group'] {
5867
display: none;
5968
}
69+
70+
.example-tree.ng-rtl {
71+
background-color: red;
72+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<ul ngTree focusMode="activedescendant" #tree="ngTree" class="example-tree" dir="rtl">
2+
<ng-template
3+
[ngTemplateOutlet]="treeNodes"
4+
[ngTemplateOutletContext]="{nodes: nodes, parent: tree}"
5+
/>
6+
</ul>
7+
8+
<ng-template #treeNodes let-nodes="nodes" let-parent="parent">
9+
@for (node of nodes; track node.value) {
10+
<li
11+
ngTreeItem
12+
[parent]="parent"
13+
[value]="node.value"
14+
[label]="node.name"
15+
[disabled]="node.disabled"
16+
#treeItem="ngTreeItem"
17+
class="example-tree-item example-selectable example-stateful"
18+
>
19+
<span aria-hidden="true" class="material-symbols-outlined example-parent-icon example-icon">{{node.children ? 'chevron_right' : ''}}</span>
20+
<span aria-hidden="true" class="material-symbols-outlined example-icon">{{node.children ? 'folder' : 'docs'}}</span>
21+
{{ node.name }}
22+
<span aria-hidden="true" class="material-symbols-outlined example-selected-icon example-icon">check</span>
23+
</li>
24+
25+
@if (node.children) {
26+
<ul role="group">
27+
<ng-template ngTreeItemGroup [ownedBy]="treeItem" #group="ngTreeItemGroup">
28+
<ng-template
29+
[ngTemplateOutlet]="treeNodes"
30+
[ngTemplateOutletContext]="{nodes: node.children, parent: group}"
31+
/>
32+
</ng-template>
33+
</ul>
34+
} }
35+
</ng-template>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
9+
import {Component} from '@angular/core';
10+
import {NgTemplateOutlet} from '@angular/common';
11+
import {Tree, TreeItem, TreeItemGroup} from '@angular/aria/tree';
12+
import {TreeNode, NODES} from '../tree-data';
13+
14+
/**
15+
* @title Tree with active descendant focus.
16+
*/
17+
@Component({
18+
selector: 'tree-rtl-active-descendant-example',
19+
templateUrl: 'tree-rtl-active-descendant-example.html',
20+
styleUrl: '../tree-common.css',
21+
imports: [Tree, TreeItem, TreeItemGroup, NgTemplateOutlet],
22+
})
23+
export class TreeRtlActiveDescendantExample {
24+
nodes: TreeNode[] = NODES;
25+
}

src/dev-app/aria-tree/tree-demo.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ <h2>Active Descendant</h2>
4444
<h2>Nav Mode</h2>
4545
<tree-nav-example></tree-nav-example>
4646
</div>
47+
48+
<div class="example-tree-container">
49+
<h2>RTL Active Descendant</h2>
50+
<tree-rtl-active-descendant-example></tree-rtl-active-descendant-example>
51+
</div>
4752
</div>
4853

4954
<div class="example-configurable-tree-container">

src/dev-app/aria-tree/tree-demo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
TreeMultiSelectExample,
1717
TreeMultiSelectFollowFocusExample,
1818
TreeNavExample,
19+
TreeRtlActiveDescendantExample,
1920
TreeSingleSelectExample,
2021
TreeSingleSelectFollowFocusExample,
2122
} from '@angular/components-examples/aria/tree';
@@ -31,6 +32,7 @@ import {
3132
TreeMultiSelectExample,
3233
TreeMultiSelectFollowFocusExample,
3334
TreeNavExample,
35+
TreeRtlActiveDescendantExample,
3436
TreeSingleSelectExample,
3537
TreeSingleSelectFollowFocusExample,
3638
],

0 commit comments

Comments
 (0)