Skip to content

Commit c590d37

Browse files
committed
Add accessibility page
1 parent 3cb3945 commit c590d37

22 files changed

+618
-257
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {NgModule} from '@angular/core';
2+
import {CommonModule} from '@angular/common';
3+
import {RouterModule} from '@angular/router';
4+
import {ACCESSIBILITY_DEMO_ROUTES} from './routes';
5+
import {DemoMaterialModule} from '../demo-material-module';
6+
import {AccessibilityHome, AccessibilityDemo} from './a11y';
7+
import {ButtonAccessibilityDemo} from './button/button-a11y';
8+
import {CheckboxAccessibilityDemo} from './checkbox/checkbox-a11y';
9+
import {ChipsAccessibilityDemo} from './chips/chips-a11y';
10+
11+
@NgModule({
12+
imports: [
13+
RouterModule.forChild(ACCESSIBILITY_DEMO_ROUTES)
14+
],
15+
exports: [
16+
RouterModule
17+
]
18+
})
19+
export class AccessibilityRoutingModule {}
20+
21+
@NgModule({
22+
imports: [
23+
CommonModule,
24+
AccessibilityRoutingModule,
25+
DemoMaterialModule,
26+
],
27+
declarations: [
28+
AccessibilityDemo,
29+
AccessibilityHome,
30+
ButtonAccessibilityDemo,
31+
CheckboxAccessibilityDemo,
32+
ChipsAccessibilityDemo,
33+
]
34+
})
35+
export class AccessibilityDemoModule {}

src/demo-app/a11y/a11y.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<h1>Accessibility Demo</h1>
2+
3+
<nav>
4+
<a *ngFor="let navItem of navItems" [routerLink]="[navItem.route]">
5+
{{navItem.name}}
6+
</a>
7+
</nav>
8+
9+
<router-outlet></router-outlet>

src/demo-app/a11y/a11y.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
body {
2+
font-family: Roboto, 'Helvetica Neue', sans-serif;
3+
4+
// Helps fonts on OSX looks more consistent with other systems
5+
// Isn't currently in button styles due to performance concerns
6+
* {
7+
-webkit-font-smoothing: antialiased;
8+
-moz-osx-font-smoothing: grayscale;
9+
}
10+
11+
h1 {
12+
font-size: 20px;
13+
}
14+
15+
ul, li {
16+
list-style: none;
17+
}
18+
19+
nav a {
20+
margin: 2px;
21+
}
22+
}

src/demo-app/a11y/a11y.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {Component, ViewEncapsulation} from '@angular/core';
2+
3+
@Component({
4+
moduleId: module.id,
5+
selector: 'accessibility-home',
6+
template: `<p>Welcome to the accessibility demos for Angular Material!</p>`,
7+
})
8+
export class AccessibilityHome {}
9+
10+
@Component({
11+
moduleId: module.id,
12+
selector: 'accessibility-demo',
13+
templateUrl: 'a11y.html',
14+
styleUrls: ['a11y.css'],
15+
encapsulation: ViewEncapsulation.None,
16+
})
17+
export class AccessibilityDemo {
18+
navItems = [
19+
{name: 'Home', route: '.'},
20+
{name: 'Button', route: 'button'},
21+
{name: 'Checkbox', route: 'checkbox'},
22+
{name: 'Chips', route: 'chips'},
23+
];
24+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div class="demo-button">
2+
<section>
3+
<h2>Button elements</h2>
4+
<button md-button>Check</button>
5+
<button md-raised-button>raised</button>
6+
<button md-fab aria-label="Activate floating action style button">
7+
<md-icon class="md-24">check</md-icon>
8+
</button>
9+
<button md-mini-fab aria-label="Activate mini floating action style button">
10+
<md-icon class="md-24">check</md-icon>
11+
</button>
12+
<button md-icon-button aria-label="Activate icon style button">
13+
<md-icon class="md-24">check</md-icon>
14+
</button>
15+
</section>
16+
17+
<section>
18+
<h2>Anchor elements</h2>
19+
<a href="http://www.google.com" md-button color="primary">Google search</a>
20+
<a href="http://www.google.com" md-raised-button>Google search</a>
21+
<a href="http://www.google.com" md-fab aria-label="Activate floating action style link">
22+
<md-icon class="md-24">check</md-icon>
23+
</a>
24+
<a href="http://www.google.com" md-mini-fab aria-label="Activate mini floating action style link">
25+
<md-icon class="md-24">check</md-icon>
26+
</a>
27+
<a md-icon-button aria-label="Activate icon style link">
28+
<md-icon class="md-24">check</md-icon>
29+
</a>
30+
</section>
31+
</div>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
.demo-button {
3+
button, a {
4+
margin: 8px;
5+
text-transform: uppercase;
6+
}
7+
8+
section {
9+
display: flex;
10+
align-items: center;
11+
margin: 8px;
12+
}
13+
14+
p {
15+
padding: 5px 15px;
16+
}
17+
}
18+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {Component} from '@angular/core';
2+
3+
4+
@Component({
5+
moduleId: module.id,
6+
selector: 'button-a11y',
7+
templateUrl: 'button-a11y.html',
8+
styleUrls: ['button-a11y.css'],
9+
})
10+
export class ButtonAccessibilityDemo {
11+
// TODO(tinayuangao): Add use cases
12+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Checkbox Placeholder

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

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {Component} from '@angular/core';
2+
3+
4+
@Component({
5+
moduleId: module.id,
6+
selector: 'checkbox-a11y',
7+
templateUrl: 'checkbox-a11y.html',
8+
styleUrls: ['checkbox-a11y.css'],
9+
})
10+
export class CheckboxAccessibilityDemo {
11+
// TODO(tinayuangao): Add use cases
12+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<section>
2+
<h2>Basic chips</h2>
3+
<md-chip-list>
4+
<md-chip>Chip 1</md-chip>
5+
<md-chip>Chip 2</md-chip>
6+
<md-chip>Chip 3</md-chip>
7+
</md-chip-list>
8+
9+
</section>
10+
11+
<section>
12+
<h2>Unstyled chips</h2>
13+
14+
<md-chip-list>
15+
<md-basic-chip>Basic Chip 1</md-basic-chip>
16+
<md-basic-chip>Basic Chip 2</md-basic-chip>
17+
<md-basic-chip>Basic Chip 3</md-basic-chip>
18+
</md-chip-list>
19+
</section>
20+
21+
<section>
22+
<h2>Removable chips in input container</h2>
23+
24+
<md-input-container>
25+
<md-chip-list mdPrefix #chipList>
26+
<md-chip *ngFor="let person of people" [color]="color">
27+
{{person.name}}
28+
</md-chip>
29+
</md-chip-list>
30+
<input mdInput placeholder="New Contributor..."
31+
[mdChipInputFor]="chipList"
32+
[mdChipInputAddOnBlur]="addOnBlur"
33+
(mdChipInputTokenEnd)="add($event)" />
34+
</md-input-container>
35+
</section>
36+
37+
<section>
38+
<h2>Colored chips</h2>
39+
<md-chip-list>
40+
<md-chip color="primary" selected="true">Primary</md-chip>
41+
<md-chip color="accent" selected="true">Accent</md-chip>
42+
<md-chip color="warn" selected="true">Warn</md-chip>
43+
</md-chip-list>
44+
</section>
45+
46+
47+
<section>
48+
<h2>Stacked chips</h2>
49+
<md-chip-list class="mat-chip-list-stacked">
50+
<md-chip [selectable]="false">Stacked chip 1</md-chip>
51+
<md-chip [selectable]="false">Stacked chip 2</md-chip>
52+
<md-chip [selectable]="false">Stacked chip 3</md-chip>
53+
</md-chip-list>
54+
</section>

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

Whitespace-only changes.

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import {Component} from '@angular/core';
2+
import {MdChipInputEvent} from '@angular/material';
3+
4+
5+
interface Person {
6+
name: string;
7+
}
8+
9+
@Component({
10+
moduleId: module.id,
11+
selector: 'chips-a11y',
12+
templateUrl: 'chips-a11y.html',
13+
styleUrls: ['chips-a11y.css'],
14+
})
15+
export class ChipsAccessibilityDemo {
16+
visible: boolean = true;
17+
color: string = '';
18+
selectable: boolean = true;
19+
removable: boolean = true;
20+
addOnBlur: boolean = true;
21+
message: string = '';
22+
23+
people: Person[] = [
24+
{ name: 'Kara' },
25+
{ name: 'Jeremy' },
26+
{ name: 'Topher' },
27+
{ name: 'Elad' },
28+
{ name: 'Kristiyan' },
29+
{ name: 'Paul' }
30+
];
31+
32+
displayMessage(message: string): void {
33+
this.message = message;
34+
}
35+
36+
add(event: MdChipInputEvent): void {
37+
let input = event.input;
38+
let value = event.value;
39+
40+
// Add our person
41+
if ((value || '').trim()) {
42+
this.people.push({ name: value.trim() });
43+
}
44+
45+
// Reset the input value
46+
if (input) {
47+
input.value = '';
48+
}
49+
}
50+
51+
remove(person: Person): void {
52+
let index = this.people.indexOf(person);
53+
54+
if (index >= 0) {
55+
this.people.splice(index, 1);
56+
}
57+
}
58+
59+
toggleVisible(): void {
60+
this.visible = false;
61+
}
62+
63+
64+
availableColors = [
65+
{ name: 'none', color: '' },
66+
{ name: 'Primary', color: 'primary' },
67+
{ name: 'Accent', color: 'accent' },
68+
{ name: 'Warn', color: 'warn' }
69+
];
70+
}

src/demo-app/a11y/routes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {Routes} from '@angular/router';
2+
import {ButtonAccessibilityDemo} from './button/button-a11y';
3+
import {CheckboxAccessibilityDemo} from './checkbox/checkbox-a11y';
4+
import {ChipsAccessibilityDemo} from './chips/chips-a11y';
5+
import {AccessibilityHome} from './a11y';
6+
7+
export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
8+
{path: '', component: AccessibilityHome},
9+
{path: 'button', component: ButtonAccessibilityDemo},
10+
{path: 'checkbox', component: CheckboxAccessibilityDemo},
11+
{path: 'chips', component: ChipsAccessibilityDemo},
12+
];

0 commit comments

Comments
 (0)