Skip to content

Commit

Permalink
compat: use mat in internal templates
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin committed Sep 21, 2017
1 parent 3025b30 commit a1d5596
Show file tree
Hide file tree
Showing 45 changed files with 132 additions and 126 deletions.
8 changes: 4 additions & 4 deletions src/lib/button/button.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<span class="mat-button-wrapper"><ng-content></ng-content></span>
<div md-ripple class="mat-button-ripple"
<div mat-ripple class="mat-button-ripple"
[class.mat-button-ripple-round]="_isRoundButton || _isIconButton"
[mdRippleDisabled]="_isRippleDisabled()"
[mdRippleCentered]="_isIconButton"
[mdRippleTrigger]="_getHostElement()"></div>
[matRippleDisabled]="_isRippleDisabled()"
[matRippleCentered]="_isIconButton"
[matRippleTrigger]="_getHostElement()"></div>
<div class="mat-button-focus-overlay"></div>
2 changes: 2 additions & 0 deletions src/lib/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
CanColor,
CanDisable,
CanDisableRipple,
MATERIAL_COMPATIBILITY_MODE,
mixinColor,
mixinDisabled,
mixinDisableRipple
Expand Down Expand Up @@ -130,6 +131,7 @@ export const _MdButtonMixinBase = mixinColor(mixinDisabled(mixinDisableRipple(Md
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
})
export class MdButton extends _MdButtonMixinBase
implements OnDestroy, CanDisable, CanColor, CanDisableRipple {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/checkbox/checkbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
[attr.aria-labelledby]="ariaLabelledby"
(change)="_onInteractionEvent($event)"
(click)="_onInputClick($event)">
<div md-ripple class="mat-checkbox-ripple"
[mdRippleTrigger]="label"
[mdRippleDisabled]="_isRippleDisabled()"
[mdRippleCentered]="true"></div>
<div mat-ripple class="mat-checkbox-ripple"
[matRippleTrigger]="label"
[matRippleDisabled]="_isRippleDisabled()"
[matRippleCentered]="true"></div>
<div class="mat-checkbox-frame"></div>
<div class="mat-checkbox-background">
<svg version="1.1"
Expand Down
3 changes: 2 additions & 1 deletion src/lib/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {
CanColor,
CanDisable,
CanDisableRipple,
CanDisableRipple, MATERIAL_COMPATIBILITY_MODE,
MdRipple,
mixinColor,
mixinDisabled,
Expand Down Expand Up @@ -104,6 +104,7 @@ export const _MdCheckboxMixinBase =
'[class.mat-checkbox-label-before]': 'labelPosition == "before"',
},
providers: [MD_CHECKBOX_CONTROL_VALUE_ACCESSOR],
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
inputs: ['disabled', 'disableRipple', 'color'],
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
Expand Down
12 changes: 5 additions & 7 deletions src/lib/core/option/option.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<span [ngSwitch]="_isCompatibilityMode" *ngIf="multiple">
<mat-pseudo-checkbox class="mat-option-pseudo-checkbox" *ngSwitchCase="true"
<span *ngIf="multiple">
<mat-pseudo-checkbox class="mat-option-pseudo-checkbox"
[state]="selected ? 'checked' : ''" [disabled]="disabled"></mat-pseudo-checkbox>
<md-pseudo-checkbox class="mat-option-pseudo-checkbox" *ngSwitchDefault
[state]="selected ? 'checked' : ''" [disabled]="disabled"></md-pseudo-checkbox>
</span>

<ng-content></ng-content>
<div class="mat-option-ripple" md-ripple
[mdRippleTrigger]="_getHostElement()"
[mdRippleDisabled]="disabled || disableRipple">
<div class="mat-option-ripple" mat-ripple
[matRippleTrigger]="_getHostElement()"
[matRippleDisabled]="disabled || disableRipple">
</div>
4 changes: 2 additions & 2 deletions src/lib/core/option/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class MdOptionSelectionChange {
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
})
export class MdOption {
private _selected: boolean = false;
Expand Down Expand Up @@ -107,8 +108,7 @@ export class MdOption {
constructor(
private _element: ElementRef,
private _changeDetectorRef: ChangeDetectorRef,
@Optional() public readonly group: MdOptgroup,
@Optional() @Inject(MATERIAL_COMPATIBILITY_MODE) public _isCompatibilityMode: boolean) {}
@Optional() public readonly group: MdOptgroup) {}

/**
* Whether or not the option is currently active and ready to be selected.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/ripple/ripple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class MdRipple implements OnChanges, OnDestroy {
}

ngOnChanges(changes: SimpleChanges) {
if (changes['trigger'] && this.trigger) {
if ((changes['trigger'] || changes['_matRippleTrigger']) && this.trigger) {
this._rippleRenderer.setTriggerElement(this.trigger);
}

Expand Down
31 changes: 5 additions & 26 deletions src/lib/datepicker/calendar.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
<div class="mat-calendar-header">
<div class="mat-calendar-controls">
<!--
TODO(mmalerba): Clean up duplicated compatibility mode code when we have a better way to do
this.
-->

<!-- Check for compatibility mode and use correct prefix for md-button. -->
<button *ngIf="!_isCompatibilityMode" md-button class="mat-calendar-period-button"
(click)="_currentPeriodClicked()" [attr.aria-label]="_periodButtonLabel">
{{_periodButtonText}}
<div class="mat-calendar-arrow" [class.mat-calendar-invert]="!_monthView"></div>
</button>
<button *ngIf="_isCompatibilityMode" mat-button class="mat-calendar-period-button"
<button mat-button class="mat-calendar-period-button"
(click)="_currentPeriodClicked()" [attr.aria-label]="_periodButtonLabel">
{{_periodButtonText}}
<div class="mat-calendar-arrow" [class.mat-calendar-invert]="!_monthView"></div>
</button>

<div class="mat-calendar-spacer"></div>

<!-- Check for compatibility mode and use correct prefix for md-icon-button. -->
<button *ngIf="!_isCompatibilityMode" md-icon-button class="mat-calendar-previous-button"
[disabled]="!_previousEnabled()" (click)="_previousClicked()"
[attr.aria-label]="_prevButtonLabel">
</button>
<button *ngIf="_isCompatibilityMode" mat-icon-button class="mat-calendar-previous-button"
<button mat-icon-button class="mat-calendar-previous-button"
[disabled]="!_previousEnabled()" (click)="_previousClicked()"
[attr.aria-label]="_prevButtonLabel">
</button>

<!-- Check for compatibility mode and use correct prefix for md-icon-button. -->
<button *ngIf="!_isCompatibilityMode" md-icon-button class="mat-calendar-next-button"
[disabled]="!_nextEnabled()" (click)="_nextClicked()"
[attr.aria-label]="_nextButtonLabel">
</button>
<button *ngIf="_isCompatibilityMode" mat-icon-button class="mat-calendar-next-button"
<button mat-icon-button class="mat-calendar-next-button"
[disabled]="!_nextEnabled()" (click)="_nextClicked()"
[attr.aria-label]="_nextButtonLabel">
</button>
Expand All @@ -52,11 +31,11 @@
(userSelection)="_userSelected()">
</md-month-view>

<md-year-view
<mat-year-view
*ngSwitchDefault
[activeDate]="_activeDate"
[selected]="selected"
[dateFilter]="_dateFilterForViews"
(selectedChange)="_monthSelected($event)">
</md-year-view>
</mat-year-view>
</div>
2 changes: 1 addition & 1 deletion src/lib/datepicker/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {MdDatepickerIntl} from './datepicker-intl';
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
})
export class MdCalendar<D> implements AfterContentInit, OnDestroy {
private _intlChanges: Subscription;
Expand Down Expand Up @@ -146,7 +147,6 @@ export class MdCalendar<D> implements AfterContentInit, OnDestroy {
constructor(private _elementRef: ElementRef,
private _intl: MdDatepickerIntl,
private _ngZone: NgZone,
@Optional() @Inject(MATERIAL_COMPATIBILITY_MODE) public _isCompatibilityMode: boolean,
@Optional() private _dateAdapter: DateAdapter<D>,
@Optional() @Inject(MD_DATE_FORMATS) private _dateFormats: MdDateFormats,
changeDetectorRef: ChangeDetectorRef) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/datepicker/datepicker-content.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<md-calendar cdkTrapFocus
<mat-calendar cdkTrapFocus
[id]="datepicker.id"
[startAt]="datepicker.startAt"
[startView]="datepicker.startView"
Expand All @@ -8,4 +8,4 @@
[selected]="datepicker._selected"
(selectedChange)="datepicker._select($event)"
(userSelection)="datepicker.close()">
</md-calendar>
</mat-calendar>
6 changes: 3 additions & 3 deletions src/lib/datepicker/datepicker-toggle.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<button md-icon-button type="button" [attr.aria-label]="_intl.openCalendarLabel"
<button mat-icon-button type="button" [attr.aria-label]="_intl.openCalendarLabel"
[disabled]="disabled" (click)="_open($event)">
<md-icon>
<mat-icon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="100%" height="100%"
fill="currentColor" style="vertical-align: top" focusable="false">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z"/>
</svg>
</md-icon>
</mat-icon>
</button>
2 changes: 2 additions & 0 deletions src/lib/datepicker/datepicker-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {Subscription} from 'rxjs/Subscription';
import {merge} from 'rxjs/observable/merge';
import {of as observableOf} from 'rxjs/observable/of';
import {MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core';


@Component({
Expand All @@ -34,6 +35,7 @@ import {of as observableOf} from 'rxjs/observable/of';
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
})
export class MdDatepickerToggle<D> implements OnChanges, OnDestroy {
private _stateChanges = Subscription.EMPTY;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/datepicker/datepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('MdDatepicker', () => {

let ownedElement = document.getElementById(ownedElementId);
expect(ownedElement).not.toBeNull();
expect((ownedElement as Element).tagName.toLowerCase()).toBe('md-calendar');
expect((ownedElement as Element).tagName.toLowerCase()).toBe('mat-calendar');
});

it('input should aria-owns calendar after opened in touch mode', () => {
Expand All @@ -267,7 +267,7 @@ describe('MdDatepicker', () => {

let ownedElement = document.getElementById(ownedElementId);
expect(ownedElement).not.toBeNull();
expect((ownedElement as Element).tagName.toLowerCase()).toBe('md-calendar');
expect((ownedElement as Element).tagName.toLowerCase()).toBe('mat-calendar');
});

it('should throw when given wrong data type', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
ViewContainerRef,
ViewEncapsulation,
} from '@angular/core';
import {DateAdapter} from '@angular/material/core';
import {DateAdapter, MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core';
import {MdDialog, MdDialogRef} from '@angular/material/dialog';
import {DOCUMENT} from '@angular/platform-browser';
import {Subject} from 'rxjs/Subject';
Expand Down Expand Up @@ -88,6 +88,7 @@ export const MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER = {
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
})
export class MdDatepickerContent<D> implements AfterContentInit {
datepicker: MdDatepicker<D>;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/datepicker/month-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<tr><th *ngFor="let day of _weekdays" [attr.aria-label]="day.long">{{day.narrow}}</th></tr>
<tr><th class="mat-calendar-table-header-divider" colspan="7" aria-hidden="true"></th></tr>
</thead>
<tbody md-calendar-body
<tbody mat-calendar-body
role="grid"
[label]="_monthLabel"
[rows]="_weeks"
Expand Down
6 changes: 5 additions & 1 deletion src/lib/datepicker/month-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import {
Output,
ViewEncapsulation,
} from '@angular/core';
import {DateAdapter, MD_DATE_FORMATS, MdDateFormats} from '@angular/material/core';
import {
DateAdapter, MATERIAL_COMPATIBILITY_MODE, MD_DATE_FORMATS,
MdDateFormats
} from '@angular/material/core';
import {MdCalendarCell} from './calendar-body';
import {coerceDateProperty} from './coerce-date-property';
import {createMissingDateImplError} from './datepicker-errors';
Expand All @@ -37,6 +40,7 @@ const DAYS_PER_WEEK = 7;
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
})
export class MdMonthView<D> implements AfterContentInit {
/**
Expand Down
6 changes: 3 additions & 3 deletions src/lib/list/list-item.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="mat-list-item-content">
<div class="mat-list-item-ripple" md-ripple
[mdRippleTrigger]="_getHostElement()"
[mdRippleDisabled]="_isRippleDisabled()">
<div class="mat-list-item-ripple" mat-ripple
[matRippleTrigger]="_getHostElement()"
[matRippleDisabled]="_isRippleDisabled()">
</div>

<ng-content
Expand Down
10 changes: 5 additions & 5 deletions src/lib/list/list-option.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
[class.mat-list-item-content-reverse]="checkboxPosition == 'after'"
[class.mat-list-item-disabled]="disabled">

<div md-ripple
<div mat-ripple
class="mat-list-item-ripple"
[mdRippleTrigger]="_getHostElement()"
[mdRippleDisabled]="_isRippleDisabled()"></div>
[matRippleTrigger]="_getHostElement()"
[matRippleDisabled]="_isRippleDisabled()"></div>

<md-pseudo-checkbox #autocheckbox
<mat-pseudo-checkbox #autocheckbox
[state]="selected ? 'checked' : 'unchecked'"
[disabled]="disabled"></md-pseudo-checkbox>
[disabled]="disabled"></mat-pseudo-checkbox>

<div class="mat-list-text"><ng-content></ng-content></div>

Expand Down
3 changes: 2 additions & 1 deletion src/lib/list/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
ViewEncapsulation,
ChangeDetectionStrategy,
} from '@angular/core';
import {MdLine, MdLineSetter} from '@angular/material/core';
import {MATERIAL_COMPATIBILITY_MODE, MdLine, MdLineSetter} from '@angular/material/core';
import {CanDisableRipple, mixinDisableRipple} from '@angular/material/core';

// Boilerplate for applying mixins to MdList.
Expand Down Expand Up @@ -132,6 +132,7 @@ export class MdListSubheaderCssMatStyler {}
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
})
export class MdListItem extends _MdListItemMixinBase implements AfterContentInit, CanDisableRipple {
private _lineSetter: MdLineSetter;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/list/selection-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus';
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: false}],
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
})
export class MdListOption extends _MdListOptionMixinBase
implements AfterContentInit, OnDestroy, FocusableOption, CanDisableRipple {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/menu/menu-item.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ng-content></ng-content>
<div class="mat-menu-ripple" *ngIf="!disabled" md-ripple [mdRippleTrigger]="_getHostElement()">
<div class="mat-menu-ripple" *ngIf="!disabled" mat-ripple [matRippleTrigger]="_getHostElement()">
</div>
3 changes: 2 additions & 1 deletion src/lib/menu/menu-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
OnDestroy,
ViewEncapsulation,
} from '@angular/core';
import {CanDisable, mixinDisabled} from '@angular/material/core';
import {CanDisable, MATERIAL_COMPATIBILITY_MODE, mixinDisabled} from '@angular/material/core';
import {Subject} from 'rxjs/Subject';

// Boilerplate for applying mixins to MdMenuItem.
Expand Down Expand Up @@ -46,6 +46,7 @@ export const _MdMenuItemMixinBase = mixinDisabled(MdMenuItemBase);
preserveWhitespaces: false,
templateUrl: 'menu-item.html',
exportAs: 'mdMenuItem, matMenuItem',
viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}],
})
export class MdMenuItem extends _MdMenuItemMixinBase implements FocusableOption, CanDisable,
OnDestroy {
Expand Down
Loading

0 comments on commit a1d5596

Please sign in to comment.