Skip to content
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

feat(paginator): allow form field color to be customized #12834

Merged
merged 1 commit into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/paginator/paginator.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<mat-form-field
*ngIf="_displayedPageSizeOptions.length > 1"
[color]="color"
class="mat-paginator-page-size-select">
<mat-select
[value]="pageSize"
Expand Down
15 changes: 15 additions & 0 deletions src/lib/paginator/paginator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Component, ViewChild} from '@angular/core';
import {MatPaginatorIntl} from './paginator-intl';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {dispatchMouseEvent} from '@angular/cdk/testing';
import {ThemePalette} from '@angular/material/core';


describe('MatPaginator', () => {
Expand Down Expand Up @@ -167,6 +168,18 @@ describe('MatPaginator', () => {
expect(paginator.pageIndex).toBeGreaterThanOrEqual(0);
});

it('should be able to set the color of the form field', () => {
const formField: HTMLElement = fixture.nativeElement.querySelector('.mat-form-field');

expect(formField.classList).toContain('mat-primary');

component.color = 'accent';
fixture.detectChanges();

expect(formField.classList).not.toContain('mat-primary');
expect(formField.classList).toContain('mat-accent');
});

describe('when showing the first and last button', () => {

beforeEach(() => {
Expand Down Expand Up @@ -387,6 +400,7 @@ function getLastButton(fixture: ComponentFixture<any>) {
[hidePageSize]="hidePageSize"
[showFirstLastButtons]="showFirstLastButtons"
[length]="length"
[color]="color"
(page)="pageEvent($event)">
</mat-paginator>
`,
Expand All @@ -399,6 +413,7 @@ class MatPaginatorApp {
showFirstLastButtons = false;
length = 100;
pageEvent = jasmine.createSpy('page event');
color: ThemePalette;

@ViewChild(MatPaginator) paginator: MatPaginator;

Expand Down
5 changes: 4 additions & 1 deletion src/lib/paginator/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '@angular/core';
import {Subscription} from 'rxjs';
import {MatPaginatorIntl} from './paginator-intl';
import {HasInitialized, mixinInitialized} from '@angular/material/core';
import {HasInitialized, mixinInitialized, ThemePalette} from '@angular/material/core';

/** The default page size if there is no page size and there are no provided page size options. */
const DEFAULT_PAGE_SIZE = 50;
Expand Down Expand Up @@ -72,6 +72,9 @@ export class MatPaginator extends _MatPaginatorBase implements OnInit, OnDestroy
private _initialized: boolean;
private _intlChanges: Subscription;

/** Theme color to be used for the underlying form controls. */
@Input() color: ThemePalette;

/** The zero-based page index of the displayed list of items. Defaulted to 0. */
@Input()
get pageIndex(): number { return this._pageIndex; }
Expand Down