-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sort): add ability to manage and display sorting (#5307)
* feat(sort): add sortable * checkin * checkin * feat(sort): add sort header * overrides, tests * format demo html * add ngif to screenready label * add new line to scss * fix tests * fix types * fix types * shorten coerce import * comments * comments * rebase * specialize intl to header; make public * remove reverse * button type and onpush * rename sort directions (shorten) * small changes * remove consolelog * screenreader
- Loading branch information
1 parent
24b8064
commit b328d36
Showing
18 changed files
with
721 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 == 'asc' ? 'ascending' : 'descending'}`; | ||
} | ||
} |
This file contains 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.