Skip to content

Commit cc75fe7

Browse files
committed
Merge branch 'a11y-tab' of github.com:tinayuangao/material2 into a11y-tab
2 parents 44b53bf + 0073995 commit cc75fe7

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
@@ -33,6 +33,12 @@ import {SliderAccessibilityDemo} from './slider/slider-a11y';
3333
import {SlideToggleAccessibilityDemo} from './slide-toggle/slide-toggle-a11y';
3434
import {SnackBarAccessibilityDemo} from './snack-bar/snack-bar-a11y';
3535
import {SelectAccessibilityDemo} from './select/select-a11y';
36+
import {
37+
TabsAccessibilityDemo,
38+
SunnyTabContent,
39+
RainyTabContent,
40+
FoggyTabContent,
41+
} from './tabs/tabs-a11y';
3642

3743

3844
@NgModule({
@@ -81,6 +87,10 @@ export class AccessibilityRoutingModule {}
8187
SlideToggleAccessibilityDemo,
8288
SnackBarAccessibilityDemo,
8389
SelectAccessibilityDemo,
90+
TabsAccessibilityDemo,
91+
SunnyTabContent,
92+
RainyTabContent,
93+
FoggyTabContent,
8494
],
8595
entryComponents: [
8696
DialogAccessibilityDemo,
@@ -89,6 +99,9 @@ export class AccessibilityRoutingModule {}
8999
DialogNeptuneExampleDialog,
90100
DialogNeptuneIFrameDialog,
91101
DialogWelcomeExampleDialog,
102+
SunnyTabContent,
103+
RainyTabContent,
104+
FoggyTabContent,
92105
]
93106
})
94107
export class AccessibilityDemoModule {}

src/demo-app/a11y/a11y.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class AccessibilityDemo {
3636
{name: 'Slide toggle', route: 'slide-toggle'},
3737
{name: 'Snack bar', route: 'snack-bar'},
3838
{name: 'Select', route: 'select'},
39+
{name: 'Tabs', route: 'tabs'},
3940
{name: 'Toolbar', route: 'toolbar'},
4041
];
4142
}

src/demo-app/a11y/routes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {SliderAccessibilityDemo} from './slider/slider-a11y';
2020
import {SlideToggleAccessibilityDemo} from './slide-toggle/slide-toggle-a11y';
2121
import {SnackBarAccessibilityDemo} from './snack-bar/snack-bar-a11y';
2222
import {SelectAccessibilityDemo} from './select/select-a11y';
23+
import {TabsAccessibilityDemo} from './tabs/tabs-a11y';
24+
import {TABS_DEMO_ROUTES} from './tabs/routes';
2325

2426
export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
2527
{path: '', component: AccessibilityHome},
@@ -42,5 +44,6 @@ export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
4244
{path: 'slide-toggle', component: SlideToggleAccessibilityDemo},
4345
{path: 'snack-bar', component: SnackBarAccessibilityDemo},
4446
{path: 'select', component: SelectAccessibilityDemo},
47+
{path: 'tabs', component: TabsAccessibilityDemo, children: TABS_DEMO_ROUTES},
4548
{path: 'toolbar', component: ToolbarAccessibilityDemo},
4649
];

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)