Skip to content

Commit 2745835

Browse files
committed
demo(list): Add accessibility demo page for list
1 parent 333ec80 commit 2745835

File tree

6 files changed

+144
-0
lines changed

6 files changed

+144
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {ButtonToggleAccessibilityDemo} from './button-toggle/button-toggle-a11y'
1111
import {CheckboxAccessibilityDemo} from './checkbox/checkbox-a11y';
1212
import {ChipsAccessibilityDemo} from './chips/chips-a11y';
1313
import {GridListAccessibilityDemo} from './grid-list/grid-list-a11y';
14+
import {ListAccessibilityDemo} from './list/list-a11y';
1415
import {RadioAccessibilityDemo} from './radio/radio-a11y';
1516
import {DatepickerAccessibilityDemo} from './datepicker/datepicker-a11y';
1617
import {InputAccessibilityDemo} from './input/input-a11y';
@@ -46,6 +47,7 @@ export class AccessibilityRoutingModule {}
4647
DatepickerAccessibilityDemo,
4748
GridListAccessibilityDemo,
4849
InputAccessibilityDemo,
50+
ListAccessibilityDemo,
4951
RadioAccessibilityDemo,
5052
SliderAccessibilityDemo,
5153
]

src/demo-app/a11y/a11y.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class AccessibilityDemo {
2525
{name: 'Datepicker', route: 'datepicker'},
2626
{name: 'Grid list', route: 'grid-list'},
2727
{name: 'Input', route: 'input'},
28+
{name: 'List', route: 'list'},
2829
{name: 'Radio buttons', route: 'radio'},
2930
{name: 'Slider', route: 'slider'},
3031
];

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<div class="demo-list">
2+
<section>
3+
<h2> Seasoning (Simple list) </h2>
4+
<md-list>
5+
<md-list-item *ngFor="let item of items"> {{item}} </md-list-item>
6+
</md-list>
7+
</section>
8+
9+
10+
<section>
11+
<h2>Mailbox navigation (Navigation list)</h2>
12+
<md-nav-list>
13+
<md-list-item *ngFor="let link of links">
14+
<a md-line href="https://www.google.com/search?q={{link.name}}">{{ link.name }}</a>
15+
<button md-icon-button aria-label="Show info" (click)="showInfo(link.name)">
16+
<md-icon>info</md-icon>
17+
</button>
18+
</md-list-item>
19+
</md-nav-list>
20+
<div *ngIf="infoClicked">
21+
More information about {{infoClicked}}!
22+
</div>
23+
</section>
24+
25+
<section>
26+
<h2>Messages (Multi-line list)</h2>
27+
<md-list>
28+
<md-list-item *ngFor="let message of messages">
29+
<img md-list-avatar [src]="message.image" [alt]="message.from">
30+
<h3 md-line> {{message.from}} </h3>
31+
<p md-line> {{message.subject}} </p>
32+
<p md-line class="demo-secondary-text"> {{message.message}} </p>
33+
</md-list-item>
34+
</md-list>
35+
36+
</section>
37+
38+
<section>
39+
<h2> Seasoning (Dense list)</h2>
40+
<md-list dense>
41+
<md-list-item *ngFor="let item of items"> {{item}} </md-list-item>
42+
</md-list>
43+
</section>
44+
45+
<section>
46+
<h2>Folders and notes for mailbox (List with multiple sections)</h2>
47+
<md-list>
48+
<h3 md-subheader>Folders</h3>
49+
<md-list-item *ngFor="let folder of folders">
50+
<md-icon md-list-icon aria-label="Folder">folder</md-icon>
51+
<h4 md-line>{{folder.name}}</h4>
52+
<p md-line class="demo-secondary-text"> {{folder.updated}} </p>
53+
</md-list-item>
54+
<md-divider></md-divider>
55+
<h3 md-subheader>Notes</h3>
56+
<md-list-item *ngFor="let note of notes">
57+
<md-icon md-list-icon aria-label="Note">note</md-icon>
58+
<h4 md-line>{{note.name}}</h4>
59+
<p md-line class="demo-secondary-text"> {{note.updated}} </p>
60+
</md-list-item>
61+
</md-list>
62+
</section>
63+
</div>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.demo-list {
2+
.mat-list, .mat-nav-list {
3+
border: 1px solid rgba(0, 0, 0, 0.12);
4+
max-width: 350px;
5+
margin: 20px 20px 0 0;
6+
}
7+
8+
.demo-secondary-text {
9+
color: rgba(0, 0, 0, 0.54);
10+
}
11+
}

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import {Component} from '@angular/core';
2+
3+
@Component({
4+
moduleId: module.id,
5+
selector: 'list-a11y',
6+
templateUrl: 'list-a11y.html',
7+
styleUrls: ['list-a11y.css']
8+
})
9+
export class ListAccessibilityDemo {
10+
items: string[] = [
11+
'Pepper',
12+
'Salt',
13+
'Paprika'
14+
];
15+
16+
infoClicked: string | undefined;
17+
18+
messages: any[] = [
19+
{
20+
from: 'Nancy',
21+
subject: 'Brunch?',
22+
message: 'Did you want to go on Sunday? I was thinking that might work.',
23+
image: 'https://angular.io/generated/images/bios/julie-ralph.jpg'
24+
},
25+
{
26+
from: 'Mary',
27+
subject: 'Summer BBQ',
28+
message: 'Wish I could come, but I have some prior obligations.',
29+
image: 'https://angular.io/generated/images/bios/juleskremer.jpg'
30+
},
31+
{
32+
from: 'Bobby',
33+
subject: 'Oui oui',
34+
message: 'Do you have Paris reservations for the 15th? I just booked!',
35+
image: 'https://angular.io/generated/images/bios/jelbourn.jpg'
36+
}
37+
];
38+
39+
links: any[] = [
40+
{name: 'Inbox'},
41+
{name: 'Outbox'},
42+
{name: 'Spam'},
43+
{name: 'Trash'}
44+
45+
];
46+
47+
folders: any[] = [
48+
{name: 'Imported', updated: 'Miles'},
49+
{name: 'Important', updated: 'Tina'},
50+
{name: 'Unread', updated: 'Jeremy'},
51+
];
52+
53+
notes: any[] = [
54+
{name: 'Update screenshots', updated: 'Kara'},
55+
{name: 'Install new application', updated: 'Andrew'},
56+
];
57+
58+
showInfo(name: string) {
59+
if (this.infoClicked === name) {
60+
this.infoClicked = undefined;
61+
} else {
62+
this.infoClicked = name;
63+
}
64+
}
65+
}

src/demo-app/a11y/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {RadioAccessibilityDemo} from './radio/radio-a11y';
99
import {AccessibilityHome} from './a11y';
1010
import {DatepickerAccessibilityDemo} from './datepicker/datepicker-a11y';
1111
import {InputAccessibilityDemo} from './input/input-a11y';
12+
import {ListAccessibilityDemo} from './list/list-a11y';
1213
import {SliderAccessibilityDemo} from './slider/slider-a11y';
1314

1415
export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
@@ -21,6 +22,7 @@ export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
2122
{path: 'datepicker', component: DatepickerAccessibilityDemo},
2223
{path: 'grid-list', component: GridListAccessibilityDemo},
2324
{path: 'input', component: InputAccessibilityDemo},
25+
{path: 'list', component: ListAccessibilityDemo},
2426
{path: 'radio', component: RadioAccessibilityDemo},
2527
{path: 'slider', component: SliderAccessibilityDemo},
2628
];

0 commit comments

Comments
 (0)