-
Notifications
You must be signed in to change notification settings - Fork 6.8k
a11y(chips): Add accessibility demo page for chips #5947
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<section> | ||
<h2>Basic chips</h2> | ||
<md-chip-list> | ||
<md-chip>Carnation</md-chip> | ||
<md-chip>Irises</md-chip> | ||
<md-chip>Buttercup</md-chip> | ||
</md-chip-list> | ||
|
||
</section> | ||
|
||
<section> | ||
<h2>Unstyled chips</h2> | ||
|
||
<md-chip-list> | ||
<md-basic-chip>Husky </md-basic-chip> | ||
<md-basic-chip>Golden Retriever </md-basic-chip> | ||
<md-basic-chip>Border Collie </md-basic-chip> | ||
</md-chip-list> | ||
</section> | ||
|
||
<section> | ||
<h2>Removable chips in input container</h2> | ||
|
||
<md-input-container> | ||
<md-chip-list mdPrefix #chipList> | ||
<md-chip *ngFor="let person of people" [color]="color"> | ||
{{person.name}} | ||
</md-chip> | ||
</md-chip-list> | ||
<input mdInput placeholder="New Contributor..." | ||
aria-label="New contributor" | ||
[mdChipInputFor]="chipList" | ||
[mdChipInputAddOnBlur]="addOnBlur" | ||
(mdChipInputTokenEnd)="add($event)" /> | ||
</md-input-container> | ||
</section> | ||
|
||
<section> | ||
<h2>Colored chips</h2> | ||
<p>This example is good for contrast-radio checking.</p> | ||
<md-chip-list> | ||
<md-chip color="primary" selected="true">Primary</md-chip> | ||
<md-chip color="accent" selected="true">Accent</md-chip> | ||
<md-chip color="warn" selected="true">Warn</md-chip> | ||
</md-chip-list> | ||
</section> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a comment here that this example is good to have for contrast-radio checking |
||
|
||
|
||
<section> | ||
<h2>Stacked chips</h2> | ||
<md-chip-list class="mat-chip-list-stacked"> | ||
<md-chip [selectable]="false">Lemon</md-chip> | ||
<md-chip [selectable]="false">Lime</md-chip> | ||
<md-chip [selectable]="false">Grapefruit</md-chip> | ||
</md-chip-list> | ||
</section> |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import {Component} from '@angular/core'; | ||
import {MdChipInputEvent} from '@angular/material'; | ||
|
||
|
||
export interface Person { | ||
name: string; | ||
} | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'chips-a11y', | ||
templateUrl: 'chips-a11y.html', | ||
styleUrls: ['chips-a11y.css'], | ||
}) | ||
export class ChipsAccessibilityDemo { | ||
visible: boolean = true; | ||
color: string = ''; | ||
selectable: boolean = true; | ||
removable: boolean = true; | ||
addOnBlur: boolean = true; | ||
message: string = ''; | ||
|
||
people: Person[] = [ | ||
{ name: 'Kara' }, | ||
{ name: 'Jeremy' }, | ||
{ name: 'Topher' }, | ||
{ name: 'Elad' }, | ||
{ name: 'Kristiyan' }, | ||
{ name: 'Paul' } | ||
]; | ||
|
||
displayMessage(message: string): void { | ||
this.message = message; | ||
} | ||
|
||
add(event: MdChipInputEvent): void { | ||
let input = event.input; | ||
let value = event.value; | ||
|
||
// Add our person | ||
if ((value || '').trim()) { | ||
this.people.push({ name: value.trim() }); | ||
} | ||
|
||
// Reset the input value | ||
if (input) { | ||
input.value = ''; | ||
} | ||
} | ||
|
||
remove(person: Person): void { | ||
let index = this.people.indexOf(person); | ||
|
||
if (index >= 0) { | ||
this.people.splice(index, 1); | ||
} | ||
} | ||
|
||
toggleVisible(): void { | ||
this.visible = false; | ||
} | ||
|
||
|
||
availableColors = [ | ||
{ name: 'none', color: '' }, | ||
{ name: 'Primary', color: 'primary' }, | ||
{ name: 'Accent', color: 'accent' }, | ||
{ name: 'Warn', color: 'warn' } | ||
]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import {Routes} from '@angular/router'; | ||
import {ButtonAccessibilityDemo} from './button/button-a11y'; | ||
import {CheckboxAccessibilityDemo} from './checkbox/checkbox-a11y'; | ||
import {ChipsAccessibilityDemo} from './chips/chips-a11y'; | ||
import {RadioAccessibilityDemo} from './radio/radio-a11y'; | ||
import {AccessibilityHome} from './a11y'; | ||
|
||
export const ACCESSIBILITY_DEMO_ROUTES: Routes = [ | ||
{path: '', component: AccessibilityHome}, | ||
{path: 'button', component: ButtonAccessibilityDemo}, | ||
{path: 'checkbox', component: CheckboxAccessibilityDemo}, | ||
{path: 'chips', component: ChipsAccessibilityDemo}, | ||
{path: 'radio', component: RadioAccessibilityDemo}, | ||
]; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add an
aria-label
for the input