Skip to content

demo: add select a11y demo #6384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/demo-app/a11y/a11y-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {InputAccessibilityDemo} from './input/input-a11y';
import {ProgressSpinnerAccessibilityDemo} from './progress-spinner/progress-spinner-a11y';
import {SliderAccessibilityDemo} from './slider/slider-a11y';
import {SnackBarAccessibilityDemo} from './snack-bar/snack-bar-a11y';
import {SelectAccessibilityDemo} from './select/select-a11y';


@NgModule({
Expand Down Expand Up @@ -54,6 +55,7 @@ export class AccessibilityRoutingModule {}
RadioAccessibilityDemo,
SliderAccessibilityDemo,
SnackBarAccessibilityDemo,
SelectAccessibilityDemo,
]
})
export class AccessibilityDemoModule {}
1 change: 1 addition & 0 deletions src/demo-app/a11y/a11y.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ export class AccessibilityDemo {
{name: 'Radio buttons', route: 'radio'},
{name: 'Slider', route: 'slider'},
{name: 'Snack bar', route: 'snack-bar'},
{name: 'Select', route: 'select'},
];
}
2 changes: 2 additions & 0 deletions src/demo-app/a11y/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {InputAccessibilityDemo} from './input/input-a11y';
import {ProgressSpinnerAccessibilityDemo} from './progress-spinner/progress-spinner-a11y';
import {SliderAccessibilityDemo} from './slider/slider-a11y';
import {SnackBarAccessibilityDemo} from './snack-bar/snack-bar-a11y';
import {SelectAccessibilityDemo} from './select/select-a11y';

export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
{path: '', component: AccessibilityHome},
Expand All @@ -29,4 +30,5 @@ export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
{path: 'radio', component: RadioAccessibilityDemo},
{path: 'slider', component: SliderAccessibilityDemo},
{path: 'snack-bar', component: SnackBarAccessibilityDemo},
{path: 'select', component: SelectAccessibilityDemo},
];
72 changes: 72 additions & 0 deletions src/demo-app/a11y/select/select-a11y.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<section>
<h2>Single selection</h2>
<p>Select your favorite color</p>

<md-select placeholder="Colors" [(ngModel)]="selectedColor">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does each select need an aria-label?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The select's aria-label defaults to the placeholder.

<md-option *ngFor="let color of colors" [value]="color.value">
{{ color.label }}
</md-option>
</md-select>
</section>

<section>
<h2>Multiple selection</h2>
<p>Pick toppings for your pizza</p>

<md-select placeholder="Toppings" [(ngModel)]="selectedTopping" multiple>
<md-option *ngFor="let topping of toppings" [value]="topping.value">
{{ topping.label }}
</md-option>
</md-select>
</section>

<section>
<h2>Grouped options</h2>
<p>Pick your Pokemon</p>

<md-select placeholder="Pokemon" [(ngModel)]="selectedPokemon">
<md-optgroup *ngFor="let group of pokemon" [label]="group.label">
<md-option *ngFor="let creature of group.pokemon" [value]="creature.value">
{{ creature.label }}
</md-option>
</md-optgroup>
</md-select>
</section>

<section>
<h2>Colors</h2>

<div class="select-a11y-spacer">
<md-select placeholder="ZIP code" color="primary">
<md-option value="2000">2000</md-option>
<md-option value="2100">2100</md-option>
</md-select>

<md-select placeholder="State" color="accent">
<md-option value="alaska">Alaska</md-option>
<md-option value="alabama">Alabama</md-option>
</md-select>

<md-select placeholder="Language" color="warn">
<md-option value="english">English</md-option>
<md-option value="spanish">Spanish</md-option>
</md-select>
</div>

<div class="select-a11y-spacer">
<md-select placeholder="Digimon" color="primary" multiple>
<md-option value="mihiramon">Mihiramon</md-option>
<md-option value="sandiramon">Sandiramon</md-option>
</md-select>

<md-select placeholder="Drink" color="accent" multiple>
<md-option value="water">Water</md-option>
<md-option value="coke">Coke</md-option>
</md-select>

<md-select placeholder="Theme" color="warn" multiple>
<md-option value="light">Light</md-option>
<md-option value="dark">Dark</md-option>
</md-select>
</div>
</section>
3 changes: 3 additions & 0 deletions src/demo-app/a11y/select/select-a11y.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.select-a11y-spacer {
margin-bottom: 10px;
}
72 changes: 72 additions & 0 deletions src/demo-app/a11y/select/select-a11y.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {Component} from '@angular/core';


@Component({
moduleId: module.id,
selector: 'select-a11y',
templateUrl: 'select-a11y.html',
styleUrls: ['select-a11y.css'],
})
export class SelectAccessibilityDemo {
selectedColor: string;
selectedTopping: string[];
selectedPokemon: string;

colors = [
{value: 'red', label: 'Red'},
{value: 'green', label: 'Green'},
{value: 'blue', label: 'Blue'},
{value: 'cyan', label: 'Cyan'},
{value: 'magenta', label: 'Magenta'},
{value: 'yellow', label: 'Yellow'},
{value: 'black', label: 'Black'},
];

toppings = [
{value: 'pepperoni', label: 'Pepperoni'},
{value: 'mushrooms', label: 'Mushrooms'},
{value: 'onions', label: 'Onions'},
{value: 'sausage', label: 'Sausage'},
{value: 'bacon', label: 'Bacon'},
{value: 'cheese', label: 'Cheese'},
{value: 'olives', label: 'Olives'},
{value: 'peppers', label: 'Peppers'},
{value: 'pineapple', label: 'Pineapple'},
{value: 'spinach', label: 'Spinach'},
];

pokemon = [
{
label: 'Grass',
pokemon: [
{value: 'bulbasaur', label: 'Bulbasaur'},
{value: 'oddish', label: 'Oddish'},
{value: 'bellsprout', label: 'Bellsprout'}
]
},
{
label: 'Water',
pokemon: [
{value: 'squirtle', label: 'Squirtle'},
{value: 'psyduck', label: 'Psyduck'},
{value: 'horsea', label: 'Horsea'}
]
},
{
label: 'Fire',
disabled: true,
pokemon: [
{value: 'charmander', label: 'Charmander'},
{value: 'vulpix', label: 'Vulpix'},
{value: 'flareon', label: 'Flareon'}
]
},
{
label: 'Psychic',
pokemon: [
{value: 'mew', label: 'Mew'},
{value: 'mewtwo', label: 'Mewtwo'}
]
}
];
}