Skip to content

Commit 2b1e3f5

Browse files
committed
Add MdNavList
1 parent 65a0708 commit 2b1e3f5

File tree

5 files changed

+35
-25
lines changed

5 files changed

+35
-25
lines changed

src/demo-app/a11y/list/list-a11y.html

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,13 @@ <h2> Seasoning </h2>
1010

1111
<section>
1212
<h2>Mailbox navigation</h2>
13-
<p>Showing a navigation list with links to google search, and "more information" icon button</p>
13+
<p>Showing a navigation list with links to google search</p>
1414
<md-nav-list>
15-
<md-list-item *ngFor="let link of links">
16-
<a md-line href="https://www.google.com/search?q={{link.name}}">{{ link.name }}</a>
17-
<button md-icon-button aria-label="Show info" (click)="showInfo(link.name)">
18-
<md-icon>info</md-icon>
19-
</button>
20-
</md-list-item>
15+
<a md-list-item *ngFor="let link of links"
16+
href="https://www.google.com/search?q={{link.name}}">
17+
{{link.name}}
18+
</a>
2119
</md-nav-list>
22-
<div *ngIf="infoClicked">
23-
More information about {{infoClicked}}!
24-
</div>
2520
</section>
2621

2722
<section>

src/demo-app/a11y/list/list-a11y.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export class ListAccessibilityDemo {
1313
'Paprika'
1414
];
1515

16-
infoClicked: string | undefined;
17-
1816
messages: any[] = [
1917
{
2018
from: 'Nancy',
@@ -54,12 +52,4 @@ export class ListAccessibilityDemo {
5452
{name: 'Update screenshots', updated: 'Kara'},
5553
{name: 'Install new application', updated: 'Andrew'},
5654
];
57-
58-
showInfo(name: string) {
59-
if (this.infoClicked === name) {
60-
this.infoClicked = undefined;
61-
} else {
62-
this.infoClicked = name;
63-
}
64-
}
6555
}

src/lib/list/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
MdList,
1414
MdListItem,
1515
MdListDivider,
16+
MdNavList,
1617
MdListAvatarCssMatStyler,
1718
MdListIconCssMatStyler,
1819
MdListCssMatStyler,
@@ -29,6 +30,7 @@ import {MdSelectionList, MdListOption} from './selection-list';
2930
MdList,
3031
MdListItem,
3132
MdListDivider,
33+
MdNavList,
3234
MdListAvatarCssMatStyler,
3335
MdLineModule,
3436
MdCommonModule,
@@ -45,6 +47,7 @@ import {MdSelectionList, MdListOption} from './selection-list';
4547
MdList,
4648
MdListItem,
4749
MdListDivider,
50+
MdNavList,
4851
MdListAvatarCssMatStyler,
4952
MdListIconCssMatStyler,
5053
MdListCssMatStyler,

src/lib/list/list.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,13 @@ To add a divider, use `<md-divider>`.
141141
</md-list-item>
142142
</md-list>
143143
```
144+
145+
### Accessibility
146+
By default, the list assumes that it will be used in a purely decorative fashion and thus sets no
147+
roles, ARIA attributes, or keyboard shortcuts.
148+
This is equivalent to having a sequence of <div> elements on the page. Any interactive content
149+
within the grid-list should be given an appropriate accessibility treatment based on the specific
150+
workflow of your application.
151+
152+
If the list is used to present a list of non-interactive content items, then the list element should
153+
be given `role="list"` and each tile should be given `role="listitem"`.

src/lib/list/list.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,22 @@ export const _MdListItemMixinBase = mixinDisableRipple(MdListItemBase);
4242
})
4343
export class MdListDivider {}
4444

45+
46+
@Component({
47+
moduleId: module.id,
48+
selector: 'md-nav-list, mat-nav-list',
49+
host: {'role': 'navigation'},
50+
template: '<ng-content></ng-content>',
51+
styleUrls: ['list.css'],
52+
inputs: ['disableRipple'],
53+
encapsulation: ViewEncapsulation.None,
54+
changeDetection: ChangeDetectionStrategy.OnPush,
55+
})
56+
export class MdNavList extends _MdListMixinBase implements CanDisableRipple {}
57+
4558
@Component({
4659
moduleId: module.id,
47-
selector: 'md-list, mat-list, md-nav-list, mat-nav-list',
48-
host: {'role': 'list'},
60+
selector: 'md-list, mat-list',
4961
template: '<ng-content></ng-content>',
5062
styleUrls: ['list.css'],
5163
inputs: ['disableRipple'],
@@ -146,9 +158,9 @@ export class MdListItem extends _MdListItemMixinBase implements AfterContentInit
146158
constructor(private _renderer: Renderer2,
147159
private _element: ElementRef,
148160
@Optional() private _list: MdList,
149-
@Optional() navList: MdNavListCssMatStyler) {
161+
@Optional() private _navList: MdNavList) {
150162
super();
151-
this._isNavList = !!navList;
163+
this._isNavList = !!_navList;
152164
}
153165

154166
ngAfterContentInit() {
@@ -157,7 +169,7 @@ export class MdListItem extends _MdListItemMixinBase implements AfterContentInit
157169

158170
/** Whether this list item should show a ripple effect when clicked. */
159171
isRippleEnabled() {
160-
return !this.disableRipple && this._isNavList && !this._list.disableRipple;
172+
return !this.disableRipple && this._isNavList && !this._navList.disableRipple;
161173
}
162174

163175
_handleFocus() {

0 commit comments

Comments
 (0)