-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(sort): add ability to manage and display sorting #5307
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 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
12ec1fb
feat(sort): add sortable
andrewseguin 4eea9a6
checkin
andrewseguin c5244b3
checkin
andrewseguin af0df28
feat(sort): add sort header
andrewseguin 29ef808
overrides, tests
andrewseguin 45a06af
format demo html
andrewseguin 1644763
add ngif to screenready label
andrewseguin 06adfc7
add new line to scss
andrewseguin 9cee02b
fix tests
andrewseguin efe57aa
fix types
andrewseguin d3ff9f8
fix types
andrewseguin cf272ce
shorten coerce import
andrewseguin 1684996
comments
andrewseguin 9240dd3
comments
andrewseguin 7b32a05
rebase
andrewseguin 3341fee
specialize intl to header; make public
andrewseguin 6e11c41
remove reverse
andrewseguin 25b4fd6
button type and onpush
andrewseguin ec18696
rename sort directions (shorten)
andrewseguin cdeba41
small changes
andrewseguin eb3556e
remove consolelog
andrewseguin ea51206
screenreader
andrewseguin 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
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,26 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {NgModule} from '@angular/core'; | ||
import {MdSortHeader} from './sort-header'; | ||
import {MdSort} from './sort'; | ||
import {MdSortHeaderIntl} from './sort-header-intl'; | ||
import {CommonModule} from '@angular/common'; | ||
|
||
export * from './sort-direction'; | ||
export * from './sort-header'; | ||
export * from './sort-header-intl'; | ||
export * from './sort'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule], | ||
exports: [MdSort, MdSortHeader], | ||
declarations: [MdSort, MdSortHeader], | ||
providers: [MdSortHeaderIntl] | ||
}) | ||
export class MdSortModule {} |
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,9 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
export type SortDirection = 'asc' | 'desc' | ''; |
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,22 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
/** @docs-private */ | ||
export function getMdSortDuplicateMdSortableIdError(id: string): Error { | ||
return Error(`Cannot have two MdSortables with the same id (${id}).`); | ||
} | ||
|
||
/** @docs-private */ | ||
export function getMdSortHeaderNotContainedWithinMdSortError(): Error { | ||
return Error(`MdSortHeader must be placed within a parent element with the MdSort directive.`); | ||
} | ||
|
||
/** @docs-private */ | ||
export function getMdSortHeaderMissingIdError(): Error { | ||
return Error(`MdSortHeader must be provided with a unique id.`); | ||
} |
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,26 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {Injectable} from '@angular/core'; | ||
import {SortDirection} from './sort-direction'; | ||
|
||
/** | ||
* To modify the labels and text displayed, create a new instance of MdSortHeaderIntl and | ||
* include it in a custom provider. | ||
*/ | ||
@Injectable() | ||
export class MdSortHeaderIntl { | ||
sortButtonLabel = (id: string) => { | ||
return `Change sorting for ${id}`; | ||
} | ||
|
||
/** A label to describe the current sort (visible only to screenreaders). */ | ||
sortDescriptionLabel = (id: string, direction: SortDirection) => { | ||
return `Sorted by ${id} ${direction}`; | ||
} | ||
} |
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 @@ | ||
<div class="mat-sort-header-container" | ||
[class.mat-sort-header-position-before]="arrowPosition == 'before'"> | ||
<button class="mat-sort-header-button" type="button" | ||
[attr.aria-label]="_intl.sortButtonLabel(id)"> | ||
<ng-content></ng-content> | ||
</button> | ||
|
||
<div *ngIf="_isSorted()" | ||
class="mat-sort-header-arrow" | ||
[class.mat-sort-header-asc]="_sort.direction == 'asc'" | ||
[class.mat-sort-header-desc]="_sort.direction == 'desc'"> | ||
<div class="mat-sort-header-stem"></div> | ||
<div class="mat-sort-header-pointer-left"></div> | ||
<div class="mat-sort-header-pointer-right"></div> | ||
</div> | ||
</div> | ||
|
||
<span class="cdk-visually-hidden" *ngIf="_isSorted()"> | ||
{{_intl.sortDescriptionLabel(id, _sort.direction)}} | ||
</span> |
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.
If direction is 'asc' | 'desc', won't that sound strange with a screenreader? I wonder if you want to override it to be a real word, but I'm not super familiar with what the standards are here.
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.
Good catch, I'll add a check for this