Skip to content

Commit 53fe355

Browse files
committed
shorten inputs, fix scss, other comments
1 parent 7bf7082 commit 53fe355

File tree

13 files changed

+280
-249
lines changed

13 files changed

+280
-249
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/demo-app/data-table/data-table-demo.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
</cdk-table>
4949

5050
<md-paginator #paginator
51-
[listLength]="_peopleDatabase.data.length"
52-
[currentPageIndex]="0"
53-
[pageLength]="10"
54-
[pageLengthOptions]="[5, 10, 25, 100]">
51+
[length]="_peopleDatabase.data.length"
52+
[pageIndex]="0"
53+
[pageSize]="10"
54+
[pageSizeOptions]="[5, 10, 25, 100]">
5555
</md-paginator>
5656
</div>

src/demo-app/data-table/person-data-source.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {CollectionViewer, DataSource, MdPaginator, PageChangeEvent} from '@angular/material';
1+
import {CollectionViewer, DataSource, MdPaginator, PageEvent} from '@angular/material';
22
import {Observable} from 'rxjs/Observable';
33
import {PeopleDatabase, UserData} from './people-database';
44
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
@@ -16,7 +16,7 @@ export class PersonDataSource extends DataSource<any> {
1616

1717
// Subscribe to page changes by clearing the cached data and
1818
// determining the updated display data.
19-
this._paginator.pageChange.subscribe(() => {
19+
this._paginator.page.subscribe(() => {
2020
this._renderedData = [];
2121
this.updateDisplayData();
2222
});
@@ -50,8 +50,8 @@ export class PersonDataSource extends DataSource<any> {
5050
const data = this._peopleDatabase.data.slice();
5151

5252
// Grab the page's slice of data.
53-
const startIndex = this._paginator.currentPageIndex * this._paginator.pageLength;
54-
const paginatedData = data.splice(startIndex, this._paginator.pageLength);
53+
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
54+
const paginatedData = data.splice(startIndex, this._paginator.pageSize);
5555

5656
this._displayData.next(paginatedData);
5757
}

src/lib/paginator/_paginator-theme.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
border-right: 2px solid mat-color($foreground, 'icon');
1818
}
1919

20-
.mat-icon-button[disabled] .mat-paginator-increment,
21-
.mat-icon-button[disabled] .mat-paginator-decrement {
22-
border-color: mat-color($foreground, 'disabled');
20+
.mat-icon-button[disabled] {
21+
.mat-paginator-increment,
22+
.mat-paginator-decrement {
23+
border-color: mat-color($foreground, 'disabled');
24+
}
2325
}
2426
}
2527

src/lib/paginator/paginator-intl.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ export class MdPaginatorIntl {
2424
previousPageLabel = 'Previous page';
2525

2626
/** A label for the range of items within the current page and the length of the whole list. */
27-
getRangeLabel(currentPage: number, pageSize: number, listLength: number) {
28-
if (listLength == 0 || pageSize == 0) { return `0 of ${listLength}`; }
27+
getRangeLabel(pageIndex: number, pageSize: number, length: number) {
28+
if (length == 0 || pageSize == 0) { return `0 of ${length}`; }
2929

30-
listLength = Math.max(listLength, 0);
30+
length = Math.max(length, 0);
3131

32-
const startIndex = currentPage * pageSize;
32+
const startIndex = pageIndex * pageSize;
3333

3434
// If the start index exceeds the list length, do not try and fix the end index to the end.
35-
const endIndex = startIndex < listLength ?
36-
Math.min(startIndex + pageSize, listLength) :
35+
const endIndex = startIndex < length ?
36+
Math.min(startIndex + pageSize, length) :
3737
startIndex + pageSize;
3838

39-
return `${startIndex + 1} - ${endIndex} of ${listLength}`;
39+
return `${startIndex + 1} - ${endIndex} of ${length}`;
4040
}
4141
}

src/lib/paginator/paginator.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@
33
{{_intl.itemsPerPageLabel}}
44
</div>
55

6-
<md-select *ngIf="_displayedPageLengthOptions.length > 1"
7-
[ngModel]="pageLength"
6+
<md-select *ngIf="_displayedPageSizeOptions.length > 1"
7+
[ngModel]="pageSize"
88
[aria-label]="_intl.itemsPerPageLabel"
9-
(change)="_changePageLength($event.value)">
10-
<md-option *ngFor="let pageLengthOption of _displayedPageLengthOptions" [value]="pageLengthOption">
11-
{{pageLengthOption}}
9+
(change)="_changePageSize($event.value)">
10+
<md-option *ngFor="let pageSizeOption of _displayedPageSizeOptions" [value]="pageSizeOption">
11+
{{pageSizeOption}}
1212
</md-option>
1313
</md-select>
1414

15-
<div *ngIf="_displayedPageLengthOptions.length <= 1">{{pageLength}}</div>
15+
<div *ngIf="_displayedPageSizeOptions.length <= 1">{{pageSize}}</div>
1616
</div>
1717

1818
<div class="mat-paginator-range-label">
19-
{{_intl.getRangeLabel(currentPageIndex, pageLength, listLength)}}
19+
{{_intl.getRangeLabel(pageIndex, pageSize, length)}}
2020
</div>
2121

2222
<button md-icon-button
23-
class="mat-paginator-navigation-button mat-paginator-navigation-previous"
24-
(click)="navigateToPreviousPage()"
23+
class="mat-paginator-navigation-previous"
24+
(click)="previousPage()"
2525
[attr.aria-label]="_intl.previousPageLabel"
2626
[mdTooltip]="_intl.previousPageLabel"
2727
[mdTooltipPosition]="'above'"
28-
[disabled]="!canNavigateToPreviousPage(-1)">
28+
[disabled]="!hasPreviousPage()">
2929
<div class="mat-paginator-increment"></div>
3030
</button>
3131
<button md-icon-button
32-
class="mat-paginator-navigation-button mat-paginator-navigation-next"
33-
(click)="navigateToNextPage()"
32+
class="mat-paginator-navigation-next"
33+
(click)="nextPage()"
3434
[attr.aria-label]="_intl.nextPageLabel"
3535
[mdTooltip]="_intl.nextPageLabel"
3636
[mdTooltipPosition]="'above'"
37-
[disabled]="!canNavigateToNextPage(1)">
37+
[disabled]="!hasNextPage()">
3838
<div class="mat-paginator-decrement"></div>
3939
</button>

src/lib/paginator/paginator.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
`<md-paginator>` is a component that provides navigation between paged information. It supports
2-
the changing of page length as well as giving the user buttons to navigate to the previous or next
3-
page.
1+
`<md-paginator>` is a navigation for pages information, typically used with a data-table.
42

53
<!-- example(pagination-overview) -->
64

7-
To use the paginator, you must provide the total length of the pagination information list and
8-
the length of each page. To allow the end-user to change the page length list, you may optionally
9-
input an array of numbers that the user may select from.
5+
### Basic use
6+
Each paginator instance requires:
7+
* The current page index
8+
* The number of items per page
9+
* The total number of items being paged
1010

11-
Additionally you may provide an input of what the current page index should be. Note that
12-
a non-zero index will be interpretted to display the first page, whereas if the page index is beyond
13-
the max number of pages, then this will be reflected to the user (e.g. `140 - 149 of 100 items`).
11+
When the user interacts with the paginator, a `PageEvent` will be fired that can be used to update
12+
any associated data view.
1413

15-
When the user changes the page length, or navigates between pages, the paginator will output a
16-
`PageChangeEvent` that contains the paginator's context, including the list length,
14+
### Page size options
15+
The paginator displays a dropdown of page sizes for the user to choose from. The options for this
16+
dropdown can be set via `pageSizeOptions`
1717

1818
### Internationalization
19-
In order to support internationalization or customization of the displayed text, the paginator
20-
supports an injection of a custom class that extends `MdPaginatorIntl`. This will allow you to
21-
change the following:
19+
The labels for the paginator can be customized by providing your own instance of `MdPaginatorIntl`.
20+
This will allow you to change the following:
2221
1. The label for the length of each page.
2322
2. The range text displayed to the user.
2423
3. The tooltip messages on the navigation buttons.

src/lib/paginator/paginator.scss

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,60 @@
1+
$mat-paginator-height: 56px;
2+
$mat-paginator-padding: 0 8px;
3+
4+
$mat-paginator-items-per-page-label-margin: 0 4px;
5+
$mat-paginator-selector-margin: 0 4px;
6+
$mat-paginator-selector-trigger-min-width: 56px;
7+
8+
$mat-paginator-range-label-margin: 0 32px;
9+
10+
$mat-paginator-button-margin: 8px;
11+
$mat-paginator-button-icon-height: 8px;
12+
$mat-paginator-button-icon-width: 8px;
13+
14+
$mat-paginator-button-decrement-icon-margin: 12px;
15+
$mat-paginator-button-increment-icon-margin: 16px;
16+
117
.mat-paginator {
218
display: flex;
319
align-items: center;
420
justify-content: flex-end;
5-
min-height: 56px;
6-
padding: 0 8px;
21+
min-height: $mat-paginator-height;
22+
padding: $mat-paginator-padding;
723
}
824

925
.mat-paginator-items-per-page-label {
10-
margin: 0 4px;
26+
margin: $mat-paginator-items-per-page-label-margin;
1127
}
1228

1329
.mat-paginator-page-length-select {
1430
display: flex;
1531
align-items: center;
1632

1733
.mat-select {
18-
margin: 0 4px;
34+
margin: $mat-paginator-selector-margin;
1935
}
2036

2137
.mat-select-trigger {
22-
min-width: 56px;
38+
min-width: $mat-paginator-selector-trigger-min-width;
2339
}
2440
}
2541

2642
.mat-paginator-range-label {
27-
margin: 0 32px;
43+
margin: $mat-paginator-range-label-margin;
2844
}
2945

3046
.mat-paginator-increment-button + .mat-paginator-increment-button {
31-
margin: 0 0 0 8px;
47+
margin: 0 0 0 $mat-paginator-button-margin;
3248

3349
[dir='rtl'] & {
34-
margin: 0 8px 0 0;
50+
margin: 0 $mat-paginator-button-margin 0 0;
3551
}
3652
}
3753

3854
.mat-paginator-increment,
3955
.mat-paginator-decrement {
40-
width: 8px;
41-
height: 8px;
56+
width: $mat-paginator-button-icon-width;
57+
height: $mat-paginator-button-icon-height;
4258
}
4359

4460
.mat-paginator-decrement,
@@ -51,15 +67,15 @@
5167
}
5268

5369
.mat-paginator-decrement {
54-
margin-left: 12px;
70+
margin-left: $mat-paginator-button-decrement-icon-margin;
5571
[dir='rtl'] & {
56-
margin-right: 12px;
72+
margin-right: $mat-paginator-button-decrement-icon-margin;
5773
}
5874
}
5975

6076
.mat-paginator-increment {
61-
margin-left: 16px;
77+
margin-left: $mat-paginator-button-increment-icon-margin;
6278
[dir='rtl'] & {
63-
margin-right: 16px;
79+
margin-right: $mat-paginator-button-increment-icon-margin;
6480
}
6581
}

0 commit comments

Comments
 (0)