-
Notifications
You must be signed in to change notification settings - Fork 6.8k
demo(sidenav): add accessibility demo pages #7498
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
10 commits
Select commit
Hold shift + click to select a range
3129b4d
change sidenav demo to drawer
mmalerba 153fbfa
create sidenav demo
mmalerba 13fd624
create sidenav example shells
mmalerba b519312
basic example
mmalerba 53a573c
mobile example
mmalerba b0ecb4b
dual demo
mmalerba 03c842c
some cleanup
mmalerba a3669f5
cleanup after rebase
mmalerba c545db6
fix minor issues
mmalerba e7a2ff3
auto-focus first playlist element
mmalerba 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
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,24 @@ | ||
<mat-toolbar color="primary" role="header" aria-label="Basic sidenav app"> | ||
<button mat-icon-button aria-label="Navigation menu" (click)="snav.toggle()"> | ||
<mat-icon aria-hidden="true">menu</mat-icon> | ||
</button> | ||
<h1 class="a11y-demo-sidenav-app-name">Basic Sidenav App</h1> | ||
</mat-toolbar> | ||
|
||
<mat-sidenav-container class="a11y-demo-sidenav-container"> | ||
<mat-sidenav #snav mode="side" role="navigation"> | ||
<mat-nav-list> | ||
<a mat-list-item routerLink="..">Home</a> | ||
<a mat-list-item routerLink="../basic">Basic sidenav example</a> | ||
<a mat-list-item routerLink="../mobile">Responsive sidenav example</a> | ||
<a mat-list-item routerLink="../dual">Dual sidenavs example</a> | ||
</mat-nav-list> | ||
</mat-sidenav> | ||
|
||
<mat-sidenav-content role="region"> | ||
<button mat-raised-button aria-label="Close basic sidenav example" color="primary" | ||
class="a11y-demo-sidenav-close" routerLink=".."> | ||
Close example | ||
</button> | ||
</mat-sidenav-content> | ||
</mat-sidenav-container> |
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,13 @@ | ||
import {Component, ViewEncapsulation} from '@angular/core'; | ||
|
||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'basic-sidenav-a11y', | ||
templateUrl: 'basic-sidenav-a11y.html', | ||
styleUrls: ['shared.css'], | ||
host: {'class': 'a11y-demo-sidenav-app'}, | ||
encapsulation: ViewEncapsulation.None, | ||
preserveWhitespaces: false, | ||
}) | ||
export class SidenavBasicAccessibilityDemo {} |
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,43 @@ | ||
<mat-toolbar color="primary" role="header" aria-label="Dual sidenav app"> | ||
<button mat-icon-button aria-label="Navigation menu" (click)="startSnav.toggle()"> | ||
<mat-icon aria-hidden="true">menu</mat-icon> | ||
</button> | ||
<h1 class="a11y-demo-sidenav-app-name">Dual Sidenav App</h1> | ||
<span class="a11y-demo-sidenav-spacer" aria-hidden="true"></span> | ||
<button mat-icon-button aria-label="Playlist menu" (click)="endSnav.toggle()"> | ||
<mat-icon aria-hidden="true">playlist_play</mat-icon> | ||
</button> | ||
</mat-toolbar> | ||
|
||
<mat-sidenav-container class="a11y-demo-sidenav-container"> | ||
<mat-sidenav #startSnav mode="side" role="navigation"> | ||
<mat-nav-list> | ||
<a mat-list-item routerLink="..">Home</a> | ||
<a mat-list-item routerLink="../basic">Basic sidenav example</a> | ||
<a mat-list-item routerLink="../mobile">Responsive sidenav example</a> | ||
<a mat-list-item routerLink="../dual">Dual sidenavs example</a> | ||
</mat-nav-list> | ||
</mat-sidenav> | ||
|
||
<mat-sidenav-content role="region"> | ||
<button mat-raised-button aria-label="Close dual sidenav example" color="primary" | ||
class="a11y-demo-sidenav-close" routerLink=".."> | ||
Close example | ||
</button> | ||
</mat-sidenav-content> | ||
|
||
<mat-sidenav #endSnav mode="side" position="end" class="a11y-demo-sidenav-playlist" role="region" | ||
(open)="playlist1.focus()"> | ||
<h2 class="a11y-demo-sidenav-playlist-header">Playlists</h2> | ||
<button #playlist1 mat-button aria-label="Thumbs up playlist" (click)="play('Thumbs up')"> | ||
Thumbs up | ||
</button> | ||
<button mat-button aria-label="Last added playlist" (click)="play('Last added')"> | ||
Last added | ||
</button> | ||
<button mat-button aria-label="Free and purchased playlist" | ||
(click)="play('Free and purchased')"> | ||
Free and purchased | ||
</button> | ||
</mat-sidenav> | ||
</mat-sidenav-container> |
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,13 @@ | ||
.a11y-demo-sidenav-spacer { | ||
flex: 1; | ||
} | ||
|
||
mat-sidenav.a11y-demo-sidenav-playlist { | ||
display: flex; | ||
flex-direction: column; | ||
width: 200px; | ||
} | ||
|
||
.a11y-demo-sidenav-playlist-header { | ||
text-align: center; | ||
} |
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,20 @@ | ||
import {Component, ViewEncapsulation} from '@angular/core'; | ||
import {MatSnackBar} from '@angular/material/snack-bar'; | ||
|
||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'dual-sidenav-a11y', | ||
templateUrl: 'dual-sidenav-a11y.html', | ||
styleUrls: ['shared.css', 'dual-sidenav-a11y.css'], | ||
host: {'class': 'a11y-demo-sidenav-app'}, | ||
encapsulation: ViewEncapsulation.None, | ||
preserveWhitespaces: false, | ||
}) | ||
export class SidenavDualAccessibilityDemo { | ||
constructor(private _snackbar: MatSnackBar) {} | ||
|
||
play(list: string) { | ||
this._snackbar.open(`Playing "${list}"`, '', {duration: 1000}); | ||
} | ||
} |
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,34 @@ | ||
<mat-toolbar color="primary" role="header" aria-label="Responsive sidenav app" | ||
[class.a11y-demo-sidenav-header-fixed]="mobileQuery.matches"> | ||
<button mat-icon-button aria-label="Navigation menu" (click)="snav.toggle()"> | ||
<mat-icon aria-hidden="true">menu</mat-icon> | ||
</button> | ||
<h1 class="a11y-demo-sidenav-app-name">Responsive Sidenav App</h1> | ||
</mat-toolbar> | ||
|
||
<mat-sidenav-container | ||
class="a11y-demo-sidenav-container" | ||
[class.a11y-demo-sidenav-container-fixed]="mobileQuery.matches" | ||
[style.marginTop.px]="mobileQuery.matches ? 56 : 0"> | ||
<mat-sidenav | ||
#snav | ||
role="navigation" | ||
[mode]="mobileQuery.matches ? 'over' : 'side'" | ||
[fixedInViewport]="mobileQuery.matches"> | ||
<mat-nav-list> | ||
<a mat-list-item routerLink="..">Home</a> | ||
<a mat-list-item routerLink="../basic">Basic sidenav example</a> | ||
<a mat-list-item routerLink="../mobile">Responsive sidenav example</a> | ||
<a mat-list-item routerLink="../dual">Dual sidenavs example</a> | ||
</mat-nav-list> | ||
<p class="a11y-demo-sidenav-filler" *ngFor="let f of filler">Filler content</p> | ||
</mat-sidenav> | ||
|
||
<mat-sidenav-content role="region"> | ||
<button mat-raised-button aria-label="Close responsive sidenav example" color="primary" | ||
class="a11y-demo-sidenav-close" routerLink=".."> | ||
Close example | ||
</button> | ||
<p class="a11y-demo-sidenav-filler" *ngFor="let f of filler">Filler content</p> | ||
</mat-sidenav-content> | ||
</mat-sidenav-container> |
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,4 @@ | ||
.a11y-demo-sidenav-header-fixed { | ||
position: fixed; | ||
z-index: 2; | ||
} |
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,28 @@ | ||
import {ChangeDetectorRef, Component, OnDestroy, ViewEncapsulation} from '@angular/core'; | ||
|
||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'mobile-sidenav-a11y', | ||
templateUrl: 'mobile-sidenav-a11y.html', | ||
styleUrls: ['shared.css', 'mobile-sidenav-a11y.css'], | ||
host: {'class': 'a11y-demo-sidenav-app'}, | ||
encapsulation: ViewEncapsulation.None, | ||
preserveWhitespaces: false, | ||
}) | ||
export class SidenavMobileAccessibilityDemo implements OnDestroy { | ||
mobileQuery = matchMedia('(max-width: 600px)'); | ||
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. Looks like this is breaking internal build, where is this imported? |
||
|
||
filler = Array(20).fill(0); | ||
|
||
_mobileQueryListener: () => void; | ||
|
||
constructor(changeDetectorRef: ChangeDetectorRef) { | ||
this._mobileQueryListener = () => changeDetectorRef.detectChanges(); | ||
this.mobileQuery.addListener(this._mobileQueryListener); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.mobileQuery.removeListener(this._mobileQueryListener); | ||
} | ||
} |
Oops, something went wrong.
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.
Is there a way to focus on the playlist items when toggle sidenav? The focus stays in the toggle icon button, and user need to go through the left sidenav to reach the second sidenav.