Skip to content

Commit 1179868

Browse files
crisbetokara
authored andcommitted
chore(select): add select a11y demo (#6384)
Fixes #6119.
1 parent 372436c commit 1179868

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
@@ -18,6 +18,7 @@ import {InputAccessibilityDemo} from './input/input-a11y';
1818
import {ProgressSpinnerAccessibilityDemo} from './progress-spinner/progress-spinner-a11y';
1919
import {SliderAccessibilityDemo} from './slider/slider-a11y';
2020
import {SnackBarAccessibilityDemo} from './snack-bar/snack-bar-a11y';
21+
import {SelectAccessibilityDemo} from './select/select-a11y';
2122

2223

2324
@NgModule({
@@ -54,6 +55,7 @@ export class AccessibilityRoutingModule {}
5455
RadioAccessibilityDemo,
5556
SliderAccessibilityDemo,
5657
SnackBarAccessibilityDemo,
58+
SelectAccessibilityDemo,
5759
]
5860
})
5961
export class AccessibilityDemoModule {}

src/demo-app/a11y/a11y.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ export class AccessibilityDemo {
3030
{name: 'Radio buttons', route: 'radio'},
3131
{name: 'Slider', route: 'slider'},
3232
{name: 'Snack bar', route: 'snack-bar'},
33+
{name: 'Select', route: 'select'},
3334
];
3435
}

src/demo-app/a11y/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {InputAccessibilityDemo} from './input/input-a11y';
1313
import {ProgressSpinnerAccessibilityDemo} from './progress-spinner/progress-spinner-a11y';
1414
import {SliderAccessibilityDemo} from './slider/slider-a11y';
1515
import {SnackBarAccessibilityDemo} from './snack-bar/snack-bar-a11y';
16+
import {SelectAccessibilityDemo} from './select/select-a11y';
1617

1718
export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
1819
{path: '', component: AccessibilityHome},
@@ -29,4 +30,5 @@ export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
2930
{path: 'radio', component: RadioAccessibilityDemo},
3031
{path: 'slider', component: SliderAccessibilityDemo},
3132
{path: 'snack-bar', component: SnackBarAccessibilityDemo},
33+
{path: 'select', component: SelectAccessibilityDemo},
3234
];
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="ZIP code" color="primary">
41+
<md-option value="2000">2000</md-option>
42+
<md-option value="2100">2100</md-option>
43+
</md-select>
44+
45+
<md-select placeholder="State" color="accent">
46+
<md-option value="alaska">Alaska</md-option>
47+
<md-option value="alabama">Alabama</md-option>
48+
</md-select>
49+
50+
<md-select placeholder="Language" color="warn">
51+
<md-option value="english">English</md-option>
52+
<md-option value="spanish">Spanish</md-option>
53+
</md-select>
54+
</div>
55+
56+
<div class="select-a11y-spacer">
57+
<md-select placeholder="Digimon" color="primary" multiple>
58+
<md-option value="mihiramon">Mihiramon</md-option>
59+
<md-option value="sandiramon">Sandiramon</md-option>
60+
</md-select>
61+
62+
<md-select placeholder="Drink" color="accent" multiple>
63+
<md-option value="water">Water</md-option>
64+
<md-option value="coke">Coke</md-option>
65+
</md-select>
66+
67+
<md-select placeholder="Theme" color="warn" multiple>
68+
<md-option value="light">Light</md-option>
69+
<md-option value="dark">Dark</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)