Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin committed Jun 23, 2017
1 parent 4137961 commit cad5349
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/lib/sort/sort-header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="mat-sort-header-container"
<div class="mat-sort-header-container" type="button"
[class.mat-sort-header-position-before]="arrowPosition == 'before'">
<button class="mat-sort-header-button"
[attr.aria-label]="_intl.sortButtonLabel(id)">
Expand Down
11 changes: 4 additions & 7 deletions src/lib/sort/sort-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ $mat-sort-header-arrow-container-size: 10px;
$mat-sort-header-arrow-pointer-length: 8px;
$mat-sort-header-arrow-thickness: 2px;

:host {
cursor: pointer;
}

.mat-sort-header-container {
display: flex;
cursor: pointer;
}

.mat-sort-header-position-before {
Expand Down Expand Up @@ -51,15 +48,15 @@ $mat-sort-header-arrow-thickness: 2px;
}

.mat-sort-header-stem {
background: black;
background: currentColor;
transform: rotate(135deg);
height: $mat-sort-header-arrow-container-size;
width: $mat-sort-header-arrow-thickness;
margin: auto;
}

.mat-sort-header-pointer-left {
background: black;
background: currentColor;
width: $mat-sort-header-arrow-thickness;
height: $mat-sort-header-arrow-pointer-length;
position: absolute;
Expand All @@ -68,7 +65,7 @@ $mat-sort-header-arrow-thickness: 2px;
}

.mat-sort-header-pointer-right {
background: black;
background: currentColor;
width: $mat-sort-header-arrow-pointer-length;
height: $mat-sort-header-arrow-thickness;
position: absolute;
Expand Down
18 changes: 13 additions & 5 deletions src/lib/sort/sort-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Component, Input, Optional} from '@angular/core';
import {
ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, Optional,
ViewEncapsulation
} from '@angular/core';
import {MdSort, MdSortable} from './sort';
import {MdSortIntl} from './sort-intl';
import {CdkColumnDef} from '../core/data-table/cell';
Expand All @@ -31,7 +34,9 @@ import {getMdSortHeaderNotContainedWithinMdSortError} from './sort-errors';
host: {
'(click)': '_sort.sort(this)',
'[class.mat-sort-header-sorted]': '_isSorted()',
}
},
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MdSortHeader implements MdSortable {
/**
Expand Down Expand Up @@ -62,12 +67,15 @@ export class MdSortHeader implements MdSortable {
get _id() { return this.id; }
set _id(v: string) { this.id = v; }

constructor(@Optional() public _sort: MdSort,
public _intl: MdSortIntl,
constructor(private _intl: MdSortIntl,
private _changeDetectorRef: ChangeDetectorRef,
@Optional() public _sort: MdSort,
@Optional() public _cdkColumnDef: CdkColumnDef) {
if (!_sort) {
throw getMdSortHeaderNotContainedWithinMdSortError();
}

_sort.mdSortChange.subscribe(() => _changeDetectorRef.markForCheck());
}

ngOnInit() {
Expand All @@ -84,6 +92,6 @@ export class MdSortHeader implements MdSortable {

/** Whether this MdSortHeader is currently sorted in either ascending or descending order. */
_isSorted() {
return this._sort.active == this.id && this._sort.direction != '';
return this._sort.active == this.id && this._sort.direction;
}
}
2 changes: 0 additions & 2 deletions src/lib/sort/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export class MdSort {
/**
* Register function to be used by the contained MdSortables. Adds the MdSortable to the
* collection of MdSortables.
* @docs-private
*/
register(sortable: MdSortable) {
if (!sortable.id) {
Expand All @@ -83,7 +82,6 @@ export class MdSort {
/**
* Unregister function to be used by the contained MdSortables. Removes the MdSortable from the
* collection of contained MdSortables.
* @docs-private
*/
unregister(sortable: MdSortable) {
this.sortables.delete(sortable.id);
Expand Down

0 comments on commit cad5349

Please sign in to comment.