Skip to content

demo(card): Add accessibility demo page for card #6358

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 2 commits 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 @@ -8,6 +8,7 @@ import {AccessibilityDemo, AccessibilityHome} from './a11y';
import {AutocompleteAccessibilityDemo} from './autocomplete/autocomplete-a11y';
import {ButtonAccessibilityDemo} from './button/button-a11y';
import {ButtonToggleAccessibilityDemo} from './button-toggle/button-toggle-a11y';
import {CardAccessibilityDemo} from './card/card-a11y';
import {CheckboxAccessibilityDemo} from './checkbox/checkbox-a11y';
import {ChipsAccessibilityDemo} from './chips/chips-a11y';
import {GridListAccessibilityDemo} from './grid-list/grid-list-a11y';
Expand Down Expand Up @@ -44,6 +45,7 @@ export class AccessibilityRoutingModule {}
AutocompleteAccessibilityDemo,
ButtonAccessibilityDemo,
ButtonToggleAccessibilityDemo,
CardAccessibilityDemo,
CheckboxAccessibilityDemo,
ChipsAccessibilityDemo,
DatepickerAccessibilityDemo,
Expand Down
1 change: 1 addition & 0 deletions src/demo-app/a11y/a11y.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class AccessibilityDemo {
{name: 'Autocomplete', route: 'autocomplete'},
{name: 'Button', route: 'button'},
{name: 'Button toggle', route: 'button-toggle'},
{name: 'Card', route: 'card'},
{name: 'Checkbox', route: 'checkbox'},
{name: 'Chips', route: 'chips'},
{name: 'Datepicker', route: 'datepicker'},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/demo-app/a11y/card/assets/dachshund.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/demo-app/a11y/card/assets/shiba-inu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions src/demo-app/a11y/card/card-a11y.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<section>
<h2>Dogs group</h2>
<p>Showing a card with a group of content</p>
<md-card class="example-card" role="group">
<md-card-content>
<p>Herding Group</p>
<p>Hound Group</p>
<p>Non-Sporting Group</p>
<p>Sporting Group</p>
<p>Terrier Group</p>
<p>Toy Group</p>
<p>Working Group</p>
<p>Foundation Stock Service</p>
<p>Miscellaneous Class</p>
</md-card-content>
</md-card>
</section>

<section>
<h2>Husky</h2>
<p>Showing a card with title only</p>
<md-card class="example-card">
Copy link
Member

Choose a reason for hiding this comment

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

Should any of these <md-card> instances have role="group"?
(to line up with the docs https://material.angular.io/components/card/overview)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added another example with role="group"

Siberian Husky
</md-card>
</section>

<section>
<h2>Malamute</h2>
<p>Showing a Card with title and subtitle. </p>
<md-card class="example-card">
<md-card-title>Alaskan Malamute</md-card-title>
<md-card-subtitle>Dog breed</md-card-subtitle>
</md-card>
</section>


<section>
<h2>German Shepherd</h2>
<p>
Showing a card with title, subtitle, and a footer.
</p>
<md-card class="example-card">
<md-card-subtitle>Dog breed</md-card-subtitle>
<md-card-title>German Shepherd</md-card-title>
<md-card-content>
The German Shepherd is a breed of medium to large-sized working dog that originated in
Germany. The breed's officially recognized name is German Shepherd Dog in the English
language. The breed is also known as the Alsatian in Britain and Ireland.
</md-card-content>
<md-card-footer>
People also search for Rottweiler, Siberian Husky, Labrador Retriever, Doberman Pinscher
</md-card-footer>
</md-card>
</section>

<section>
<h2>Dachshund</h2>
<p>Showing a card with title, subtitle, and avatar as header and a card image.</p>
<md-card class="example-card">
<md-card-header>
<img md-card-avatar src="a11y/card/assets/dachshund-avatar.jpg" aria-label="Dachshund avatar">
Copy link
Member

Choose a reason for hiding this comment

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

Each image should have an alt

<md-card-title>Dachshund</md-card-title>
<md-card-subtitle>Dog breed</md-card-subtitle>
</md-card-header>
<img md-card-image src="a11y/card/assets/dachshund.jpg"
aria-label="Dachshund">
<md-card-content>
The dachshund is a short-legged, long-bodied, hound-type dog breed.
</md-card-content>
</md-card>
</section>

<section>
<h2>Shiba Inu</h2>
<p>Showing a card with header, content, image, and two action buttons: "share" and "like".</p>
<md-card class="example-card">
<md-card-header>
<img md-card-avatar src="a11y/card/assets/shiba-inu-avatar.jpg" aria-label="Shiba Inu avatar">
<md-card-title>Shiba Inu</md-card-title>
<md-card-subtitle>Dog Breed</md-card-subtitle>
</md-card-header>
<img md-card-image src="a11y/card/assets/shiba-inu.jpg" aria-label="Shiba Inu">
<md-card-content>
The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog from Japan.
A small, agile dog that copes very well with mountainous terrain, the Shiba Inu was originally
bred for hunting.
</md-card-content>
<md-card-actions align="end">
<button md-button (click)="openSnackbar('Liked Shiba Inu')">like</button>
<button md-button (click)="openSnackbar('Shared Shiba Inu')">share</button>
</md-card-actions>
</md-card>
</section>
7 changes: 7 additions & 0 deletions src/demo-app/a11y/card/card-a11y.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.example-card button {
text-transform: uppercase;
}

.example-card {
max-width: 450px;
}
18 changes: 18 additions & 0 deletions src/demo-app/a11y/card/card-a11y.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {Component} from '@angular/core';
import {MdSnackBar} from '@angular/material';

@Component({
moduleId: module.id,
selector: 'card-a11y',
templateUrl: 'card-a11y.html',
styleUrls: ['card-a11y.css'],
})
export class CardAccessibilityDemo {
showProgress: boolean = false;

constructor(private snackBar: MdSnackBar) {}

openSnackbar(message: string) {
this.snackBar.open(message, '', {duration: 2000});
}
}
2 changes: 2 additions & 0 deletions src/demo-app/a11y/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Routes} from '@angular/router';
import {AutocompleteAccessibilityDemo} from './autocomplete/autocomplete-a11y';
import {ButtonAccessibilityDemo} from './button/button-a11y';
import {ButtonToggleAccessibilityDemo} from './button-toggle/button-toggle-a11y';
import {CardAccessibilityDemo} from './card/card-a11y';
import {CheckboxAccessibilityDemo} from './checkbox/checkbox-a11y';
import {ChipsAccessibilityDemo} from './chips/chips-a11y';
import {GridListAccessibilityDemo} from './grid-list/grid-list-a11y';
Expand All @@ -19,6 +20,7 @@ export const ACCESSIBILITY_DEMO_ROUTES: Routes = [
{path: 'autocomplete', component: AutocompleteAccessibilityDemo},
{path: 'button', component: ButtonAccessibilityDemo},
{path: 'button-toggle', component: ButtonToggleAccessibilityDemo},
{path: 'card', component: CardAccessibilityDemo},
{path: 'checkbox', component: CheckboxAccessibilityDemo},
{path: 'chips', component: ChipsAccessibilityDemo},
{path: 'datepicker', component: DatepickerAccessibilityDemo},
Expand Down