Skip to content

Commit a6fda02

Browse files
crisbetojosephperrott
authored andcommitted
demo(tooltip): add accessibility demo for tooltip (angular#7058)
Adds an accessibility demo page for the tooltip. Fixes angular#6499.
1 parent 5e6438d commit a6fda02

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
RainyTabContent,
4040
FoggyTabContent,
4141
} from './tabs/tabs-a11y';
42+
import {TooltipAccessibilityDemo} from './tooltip/tooltip-a11y';
4243

4344

4445
@NgModule({
@@ -91,6 +92,7 @@ export class AccessibilityRoutingModule {}
9192
SunnyTabContent,
9293
RainyTabContent,
9394
FoggyTabContent,
95+
TooltipAccessibilityDemo,
9496
],
9597
entryComponents: [
9698
DialogAccessibilityDemo,

src/demo-app/a11y/a11y.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class AccessibilityDemo {
4040
{name: 'Select', route: 'select'},
4141
{name: 'Tabs', route: 'tabs'},
4242
{name: 'Toolbar', route: 'toolbar'},
43+
{name: 'Tooltip', route: 'tooltip'},
4344
];
4445

4546
skipNavigation() {

src/demo-app/a11y/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {SnackBarAccessibilityDemo} from './snack-bar/snack-bar-a11y';
2222
import {SelectAccessibilityDemo} from './select/select-a11y';
2323
import {TabsAccessibilityDemo} from './tabs/tabs-a11y';
2424
import {TABS_DEMO_ROUTES} from './tabs/routes';
25+
import {TooltipAccessibilityDemo} from './tooltip/tooltip-a11y';
2526

2627
export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
2728
{path: '', component: AccessibilityHome},
@@ -46,4 +47,5 @@ export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
4647
{path: 'select', component: SelectAccessibilityDemo},
4748
{path: 'tabs', component: TabsAccessibilityDemo, children: TABS_DEMO_ROUTES},
4849
{path: 'toolbar', component: ToolbarAccessibilityDemo},
50+
{path: 'tooltip', component: TooltipAccessibilityDemo},
4951
];
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<section>
2+
<h2>Mouse over or tab to trigger a tooltip</h2>
3+
<p>Mouse over or focus the button to show and hide the tooltip</p>
4+
<button md-raised-button mdTooltip="This is an example of a tooltip">What is this?</button>
5+
</section>
6+
7+
8+
<section>
9+
<h2>Click to trigger a tooltip</h2>
10+
<button md-raised-button (click)="tooltip.toggle(); $event.stopPropagation()">Toggle the tooltip</button>
11+
<button md-raised-button mdTooltip="This is a tooltip that shows on click" #tooltip="mdTooltip">I have a tooltip</button>
12+
</section>
13+
14+
15+
<section>
16+
<h2>Different tooltip positions</h2>
17+
18+
<button
19+
md-raised-button
20+
mdTooltip="This tooltip appears below the trigger"
21+
mdTooltipPosition="below">Below</button>
22+
23+
<button
24+
md-raised-button
25+
mdTooltip="This tooltip appears above the trigger"
26+
mdTooltipPosition="above">Above</button>
27+
28+
<button
29+
md-raised-button
30+
mdTooltip="This tooltip appears to the left of the trigger"
31+
mdTooltipPosition="left">Left</button>
32+
33+
<button
34+
md-raised-button
35+
mdTooltip="This tooltip appears to the right of the trigger"
36+
mdTooltipPosition="right">Right</button>
37+
</section>
38+
39+
<section>
40+
<h2>Delayed tooltip</h2>
41+
<button
42+
md-raised-button
43+
mdTooltip="This tooltip will show up after a delay"
44+
[mdTooltipShowDelay]="2000">What is this?</button>
45+
</section>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {Component} from '@angular/core';
2+
3+
@Component({
4+
moduleId: module.id,
5+
selector: 'tooltip-a11y',
6+
templateUrl: 'tooltip-a11y.html',
7+
})
8+
export class TooltipAccessibilityDemo {}

0 commit comments

Comments
 (0)