Skip to content

Commit f2cae6e

Browse files
authored
demo(tabs): Add accessibility demo page for tabs (#6610)
* Add accessibility demo page for tabs * fix lint; * .
1 parent 4f4c48c commit f2cae6e

File tree

7 files changed

+155
-0
lines changed

7 files changed

+155
-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
@@ -38,6 +38,7 @@ export class AccessibilityDemo {
3838
{name: 'Slide toggle', route: 'slide-toggle'},
3939
{name: 'Snack bar', route: 'snack-bar'},
4040
{name: 'Select', route: 'select'},
41+
{name: 'Tabs', route: 'tabs'},
4142
{name: 'Toolbar', route: 'toolbar'},
4243
];
4344

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/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+
3+
import {SunnyTabContent, RainyTabContent, FoggyTabContent} from './tabs-a11y';
4+
5+
export const TABS_DEMO_ROUTES: Routes = [
6+
{path: '', redirectTo: 'sunny-tab', pathMatch: 'full'},
7+
{path: 'sunny-tab', component: SunnyTabContent},
8+
{path: 'rainy-tab', component: RainyTabContent},
9+
{path: 'foggy-tab', component: FoggyTabContent},
10+
];

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

0 commit comments

Comments
 (0)