Skip to content

Commit 4a2f422

Browse files
committed
demo: add select a11y demo
Adds an a11y demo page for `md-select`. Fixes #6119.
1 parent fd5e5ff commit 4a2f422

File tree

6 files changed

+152
-0
lines changed

6 files changed

+152
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {RadioAccessibilityDemo} from './radio/radio-a11y';
1515
import {DatepickerAccessibilityDemo} from './datepicker/datepicker-a11y';
1616
import {InputAccessibilityDemo} from './input/input-a11y';
1717
import {SliderAccessibilityDemo} from './slider/slider-a11y';
18+
import {SelectAccessibilityDemo} from './select/select-a11y';
1819

1920

2021
@NgModule({
@@ -48,6 +49,7 @@ export class AccessibilityRoutingModule {}
4849
InputAccessibilityDemo,
4950
RadioAccessibilityDemo,
5051
SliderAccessibilityDemo,
52+
SelectAccessibilityDemo,
5153
]
5254
})
5355
export class AccessibilityDemoModule {}

src/demo-app/a11y/a11y.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ export class AccessibilityDemo {
2727
{name: 'Input', route: 'input'},
2828
{name: 'Radio buttons', route: 'radio'},
2929
{name: 'Slider', route: 'slider'},
30+
{name: 'Select', route: 'select'},
3031
];
3132
}

src/demo-app/a11y/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {AccessibilityHome} from './a11y';
1010
import {DatepickerAccessibilityDemo} from './datepicker/datepicker-a11y';
1111
import {InputAccessibilityDemo} from './input/input-a11y';
1212
import {SliderAccessibilityDemo} from './slider/slider-a11y';
13+
import {SelectAccessibilityDemo} from './select/select-a11y';
1314

1415
export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
1516
{path: '', component: AccessibilityHome},
@@ -23,4 +24,5 @@ export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
2324
{path: 'input', component: InputAccessibilityDemo},
2425
{path: 'radio', component: RadioAccessibilityDemo},
2526
{path: 'slider', component: SliderAccessibilityDemo},
27+
{path: 'select', component: SelectAccessibilityDemo},
2628
];
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<section>
2+
<h2>Single selection</h2>
3+
<p>Select your favorite color</p>
4+
5+
<md-select placeholder="Colors" [(ngModel)]="selectedColor">
6+
<md-option *ngFor="let color of colors" [value]="color.value">
7+
{{ color.label }}
8+
</md-option>
9+
</md-select>
10+
</section>
11+
12+
<section>
13+
<h2>Multiple selection</h2>
14+
<p>Pick toppings for your pizza</p>
15+
16+
<md-select placeholder="Toppings" [(ngModel)]="selectedTopping" multiple>
17+
<md-option *ngFor="let topping of toppings" [value]="topping.value">
18+
{{ topping.label }}
19+
</md-option>
20+
</md-select>
21+
</section>
22+
23+
<section>
24+
<h2>Grouped options</h2>
25+
<p>Pick your Pokemon</p>
26+
27+
<md-select placeholder="Pokemon" [(ngModel)]="selectedPokemon">
28+
<md-optgroup *ngFor="let group of pokemon" [label]="group.label">
29+
<md-option *ngFor="let creature of group.pokemon" [value]="creature.value">
30+
{{ creature.label }}
31+
</md-option>
32+
</md-optgroup>
33+
</md-select>
34+
</section>
35+
36+
<section>
37+
<h2>Colors</h2>
38+
39+
<div class="select-a11y-spacer">
40+
<md-select placeholder="Primary" color="primary">
41+
<md-option value="one">One</md-option>
42+
<md-option value="two">Two</md-option>
43+
</md-select>
44+
45+
<md-select placeholder="Accent" color="accent">
46+
<md-option value="one">One</md-option>
47+
<md-option value="two">Two</md-option>
48+
</md-select>
49+
50+
<md-select placeholder="Warn" color="warn">
51+
<md-option value="one">One</md-option>
52+
<md-option value="two">Two</md-option>
53+
</md-select>
54+
</div>
55+
56+
<div class="select-a11y-spacer">
57+
<md-select placeholder="Primary" color="primary" multiple>
58+
<md-option value="one">One</md-option>
59+
<md-option value="two">Two</md-option>
60+
</md-select>
61+
62+
<md-select placeholder="Accent" color="accent" multiple>
63+
<md-option value="one">One</md-option>
64+
<md-option value="two">Two</md-option>
65+
</md-select>
66+
67+
<md-select placeholder="Warn" color="warn" multiple>
68+
<md-option value="one">One</md-option>
69+
<md-option value="two">Two</md-option>
70+
</md-select>
71+
</div>
72+
</section>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.select-a11y-spacer {
2+
margin-bottom: 10px;
3+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import {Component} from '@angular/core';
2+
3+
4+
@Component({
5+
moduleId: module.id,
6+
selector: 'select-a11y',
7+
templateUrl: 'select-a11y.html',
8+
styleUrls: ['select-a11y.css'],
9+
})
10+
export class SelectAccessibilityDemo {
11+
selectedColor: string;
12+
selectedTopping: string[];
13+
selectedPokemon: string;
14+
15+
colors = [
16+
{value: 'red', label: 'Red'},
17+
{value: 'green', label: 'Green'},
18+
{value: 'blue', label: 'Blue'},
19+
{value: 'cyan', label: 'Cyan'},
20+
{value: 'magenta', label: 'Magenta'},
21+
{value: 'yellow', label: 'Yellow'},
22+
{value: 'black', label: 'Black'},
23+
];
24+
25+
toppings = [
26+
{value: 'pepperoni', label: 'Pepperoni'},
27+
{value: 'mushrooms', label: 'Mushrooms'},
28+
{value: 'onions', label: 'Onions'},
29+
{value: 'sausage', label: 'Sausage'},
30+
{value: 'bacon', label: 'Bacon'},
31+
{value: 'cheese', label: 'Cheese'},
32+
{value: 'olives', label: 'Olives'},
33+
{value: 'peppers', label: 'Peppers'},
34+
{value: 'pineapple', label: 'Pineapple'},
35+
{value: 'spinach', label: 'Spinach'},
36+
];
37+
38+
pokemon = [
39+
{
40+
label: 'Grass',
41+
pokemon: [
42+
{value: 'bulbasaur', label: 'Bulbasaur'},
43+
{value: 'oddish', label: 'Oddish'},
44+
{value: 'bellsprout', label: 'Bellsprout'}
45+
]
46+
},
47+
{
48+
label: 'Water',
49+
pokemon: [
50+
{value: 'squirtle', label: 'Squirtle'},
51+
{value: 'psyduck', label: 'Psyduck'},
52+
{value: 'horsea', label: 'Horsea'}
53+
]
54+
},
55+
{
56+
label: 'Fire',
57+
disabled: true,
58+
pokemon: [
59+
{value: 'charmander', label: 'Charmander'},
60+
{value: 'vulpix', label: 'Vulpix'},
61+
{value: 'flareon', label: 'Flareon'}
62+
]
63+
},
64+
{
65+
label: 'Psychic',
66+
pokemon: [
67+
{value: 'mew', label: 'Mew'},
68+
{value: 'mewtwo', label: 'Mewtwo'}
69+
]
70+
}
71+
];
72+
}

0 commit comments

Comments
 (0)