Skip to content

Commit e25b77f

Browse files
committed
Add accessibility demo page for tabs
1 parent 215ff3c commit e25b77f

File tree

6 files changed

+146
-0
lines changed

6 files changed

+146
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ import {SliderAccessibilityDemo} from './slider/slider-a11y';
3131
import {SlideToggleAccessibilityDemo} from './slide-toggle/slide-toggle-a11y';
3232
import {SnackBarAccessibilityDemo} from './snack-bar/snack-bar-a11y';
3333
import {SelectAccessibilityDemo} from './select/select-a11y';
34+
import {
35+
TabsAccessibilityDemo,
36+
SunnyTabContent,
37+
RainyTabContent,
38+
FoggyTabContent,
39+
} from './tabs/tabs-a11y';
3440

3541

3642
@NgModule({
@@ -77,6 +83,10 @@ export class AccessibilityRoutingModule {}
7783
SlideToggleAccessibilityDemo,
7884
SnackBarAccessibilityDemo,
7985
SelectAccessibilityDemo,
86+
TabsAccessibilityDemo,
87+
SunnyTabContent,
88+
RainyTabContent,
89+
FoggyTabContent,
8090
],
8191
entryComponents: [
8292
DialogAccessibilityDemo,
@@ -85,6 +95,9 @@ export class AccessibilityRoutingModule {}
8595
DialogNeptuneExampleDialog,
8696
DialogNeptuneIFrameDialog,
8797
DialogWelcomeExampleDialog,
98+
SunnyTabContent,
99+
RainyTabContent,
100+
FoggyTabContent,
88101
]
89102
})
90103
export class AccessibilityDemoModule {}

src/demo-app/a11y/a11y.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ export class AccessibilityDemo {
3535
{name: 'Slide toggle', route: 'slide-toggle'},
3636
{name: 'Snack bar', route: 'snack-bar'},
3737
{name: 'Select', route: 'select'},
38+
{name: 'Tabs', route: 'tabs'},
3839
];
3940
}

src/demo-app/a11y/routes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {SliderAccessibilityDemo} from './slider/slider-a11y';
1818
import {SlideToggleAccessibilityDemo} from './slide-toggle/slide-toggle-a11y';
1919
import {SnackBarAccessibilityDemo} from './snack-bar/snack-bar-a11y';
2020
import {SelectAccessibilityDemo} from './select/select-a11y';
21+
import {TabsAccessibilityDemo} from './tabs/tabs-a11y';
22+
import {TABS_DEMO_ROUTES} from './tabs/routes';
2123

2224
export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
2325
{path: '', component: AccessibilityHome},
@@ -39,4 +41,5 @@ export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
3941
{path: 'slide-toggle', component: SlideToggleAccessibilityDemo},
4042
{path: 'snack-bar', component: SnackBarAccessibilityDemo},
4143
{path: 'select', component: SelectAccessibilityDemo},
44+
{path: 'tabs', component: TabsAccessibilityDemo, children: TABS_DEMO_ROUTES},
4245
];

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<section>
2+
<h2>Weather</h2>
3+
<p>Switch tabs to navigate</p>
4+
5+
<nav md-tab-nav-bar aria-label="weather navigation links">
6+
<a md-tab-link
7+
*ngFor="let tabLink of tabLinks; let i = index"
8+
[routerLink]="tabLink.link"
9+
routerLinkActive #rla="routerLinkActive"
10+
[active]="rla.isActive">
11+
{{tabLink.label}}
12+
</a>
13+
</nav>
14+
<router-outlet></router-outlet>
15+
</section>
16+
17+
<section>
18+
<h2>Dog breeds</h2>
19+
<p>Dynamic height tabs</p>
20+
21+
<md-tab-group class="demo-tab-group" dynamicHeight [(selectedIndex)]="activeTabIndex">
22+
<md-tab *ngFor="let tab of tabs" [disabled]="tab.disabled">
23+
<ng-template md-tab-label>{{tab.label}}</ng-template>
24+
<div class="tab-content">
25+
{{tab.content}}
26+
<br>
27+
<br>
28+
<div *ngIf="tab.extraContent">
29+
The Labrador Retriever, also Labrador, is a type of retriever-gun dog. The Labrador is
30+
one of the most popular breeds of dog in the United Kingdom and the United States.
31+
<br>
32+
<br>
33+
A favourite disability assistance breed in many countries, Labradors are frequently
34+
trained to aid the blind, those who have autism, to act as a therapy dog and perform
35+
screening and detection work for law enforcement and other official agencies. They are
36+
prized as sporting and hunting dogs.
37+
<br>
38+
<br>
39+
A few kennels breeding their ancestors, the St. John's water dog, were in England.
40+
At the same time, a combination of the sheep protection policy in Newfoundland and rabies
41+
quarantine in the United Kingdom, led to the gradual demise of the St. John's water dog
42+
in Canada.
43+
<br>
44+
<br>
45+
In the 1830s, the 10th Earl of Home and his nephews the 5th Duke of Buccleuch and Lord
46+
John Scott, had imported progenitors of the breed from Newfoundland to Europe for
47+
use as gundogs. Another early advocate of these Newfoundland dogs, or Labrador Retrievers
48+
as they later became known, was the 2nd Earl of Malmesbury who bred them for their
49+
expertise in waterfowling.
50+
51+
During the 1880s, the 3rd Earl of Malmesbury, the 6th Duke of Buccleuch and the 12th Earl
52+
of Home collaborated to develop and establish the modern Labrador breed. The dogs
53+
Buccleuch Avon and Buccleuch Ned, given by Malmesbury to Buccleuch, were mated with
54+
bitches carrying blood from those originally imported by the 5th Duke and the 10th Earl
55+
of Home. The offspring are considered to be the ancestors of modern Labradors.
56+
<br>
57+
<br>
58+
</div>
59+
</div>
60+
</md-tab>
61+
</md-tab-group>
62+
</section>
63+

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

Whitespace-only changes.

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import {Component} from '@angular/core';
2+
import {Observable} from 'rxjs/Observable';
3+
4+
@Component({
5+
moduleId: module.id,
6+
selector: 'tabs-a11y',
7+
templateUrl: 'tabs-a11y.html',
8+
styleUrls: ['tabs-a11y.css'],
9+
})
10+
export class TabsAccessibilityDemo {
11+
// Nav bar demo
12+
tabLinks = [
13+
{label: 'Sun', link: 'sunny-tab'},
14+
{label: 'Rain', link: 'rainy-tab'},
15+
{label: 'Fog', link: 'foggy-tab'},
16+
];
17+
18+
// Standard tabs demo
19+
tabs = [
20+
{
21+
label: 'German Shepherd',
22+
content: `The German Shepherd is a breed of medium to large-sized working dog that originated
23+
in Germany. The breed's officially recognized name is German Shepherd Dog in the
24+
English language. The breed is also known as the Alsatian in Britain and Ireland.`
25+
}, {
26+
label: 'Labrador Retriever',
27+
extraContent: true,
28+
content: `The Labrador Retriever, also Labrador, is a type of retriever-gun dog. The Labrador
29+
is one of the most popular breeds of dog in the United Kingdom and the United States.`
30+
}, {
31+
label: 'Rottweiler',
32+
disabled: true,
33+
content: `The Rottweiler is a breed of domestic dog, regarded as medium-to-large or large.
34+
The dogs were known in German as Rottweiler Metzgerhund, meaning Rottweil butchers' dogs,
35+
because their main use was to ...`
36+
}, {
37+
label: 'Beagle',
38+
content: `The Beagle is a breed of small hound, similar in appearance to the much larger
39+
foxhound. The beagle is a scent hound, developed primarily for hunting hare.`
40+
},
41+
];
42+
}
43+
44+
45+
@Component({
46+
moduleId: module.id,
47+
selector: 'sunny-routed-content',
48+
template: 'Having a lot of light from the sun.',
49+
})
50+
export class SunnyTabContent {}
51+
52+
53+
@Component({
54+
moduleId: module.id,
55+
selector: 'rainy-routed-content',
56+
template: 'A rainy period of time is one when it rains a lot',
57+
})
58+
export class RainyTabContent {}
59+
60+
61+
@Component({
62+
moduleId: module.id,
63+
selector: 'foggy-routed-content',
64+
template: 'If the weather is foggy, there is fog',
65+
})
66+
export class FoggyTabContent {}

0 commit comments

Comments
 (0)