Skip to content

Commit 8edbe47

Browse files
tinayuangaoandrewseguin
authored andcommitted
Add accessibility page to demo-app (#5748)
* Add accessibility page * fix lint
1 parent 641a38f commit 8edbe47

20 files changed

+499
-258
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
10+
@NgModule({
11+
imports: [
12+
RouterModule.forChild(ACCESSIBILITY_DEMO_ROUTES)
13+
],
14+
exports: [
15+
RouterModule
16+
]
17+
})
18+
export class AccessibilityRoutingModule {}
19+
20+
@NgModule({
21+
imports: [
22+
CommonModule,
23+
AccessibilityRoutingModule,
24+
DemoMaterialModule,
25+
],
26+
declarations: [
27+
AccessibilityDemo,
28+
AccessibilityHome,
29+
ButtonAccessibilityDemo,
30+
CheckboxAccessibilityDemo,
31+
]
32+
})
33+
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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
];
23+
}
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+
}

src/demo-app/a11y/routes.ts

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

0 commit comments

Comments
 (0)