Skip to content

Commit 3cf25a0

Browse files
crisbetojelbourn
authored andcommitted
refactor: change the toolkit directive prefixes and remove Md prefix from toolkit classes (#2258)
* refactor: change the toolkit directive prefixes and remove Md prefix from toolkit classes Renames the the component toolkit to use the `cdk-` prefix, in addition to removing the `Md` prefix from classes associated with the toolkit. The following CSS classes have been renamed as well: * `md-global-overlay-wrapper` -> `cdk-global-overlay-wrapper` * `md-overlay-container` -> `cdk-overlay-container` * `md-overlay-pane` -> `cdk-overlay-pane` * `md-overlay-backdrop-showing` -> `cdk-overlay-backdrop-showing` * `md-overlay-dark-backdrop` -> `cdk-overlay-dark-backdrop` * `md-overlay-backdrop` -> `cdk-overlay-backdrop` * `md-visually-hidden` -> `cdk-visually-hidden` * Re-export Md prefixed classes as deprecated * Fix linter errors. * Change the overlay variable prefixes to `cdk-` and remove dependency on theming. * Add backwards compatible selectors for core directives
1 parent 1b2db73 commit 3cf25a0

File tree

77 files changed

+267
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+267
-248
lines changed

e2e/components/dialog/dialog.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('dialog', () => {
9191
browser.actions()
9292
// We need to move the cursor to the top left so
9393
// the dialog doesn't receive the click accidentally.
94-
.mouseMove(element(by.css('.md-overlay-backdrop')).getWebElement(), { x: 0, y: 0 })
94+
.mouseMove(element(by.css('.cdk-overlay-backdrop')).getWebElement(), { x: 0, y: 0 })
9595
.click()
9696
.perform();
9797
}

e2e/components/menu/menu-page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class MenuPage {
1414

1515
triggerTwo() { return element(by.id('trigger-two')); }
1616

17-
backdrop() { return element(by.css('.md-overlay-backdrop')); }
17+
backdrop() { return element(by.css('.cdk-overlay-backdrop')); }
1818

1919
items(index: number) { return element.all(by.css('[md-menu-item]')).get(index); }
2020

src/demo-app/button-toggle/button-toggle-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {Component} from '@angular/core';
2-
import {MdUniqueSelectionDispatcher} from '@angular/material';
2+
import {UniqueSelectionDispatcher} from '@angular/material';
33

44
@Component({
55
moduleId: module.id,
66
selector: 'button-toggle-demo',
77
templateUrl: 'button-toggle-demo.html',
8-
providers: [MdUniqueSelectionDispatcher],
8+
providers: [UniqueSelectionDispatcher],
99
})
1010
export class ButtonToggleDemo {
1111
isVertical = false;

src/demo-app/live-announcer/live-announcer-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {MdLiveAnnouncer} from '@angular/material';
2+
import {LiveAnnouncer} from '@angular/material';
33

44
@Component({
55
moduleId: module.id,
@@ -8,7 +8,7 @@ import {MdLiveAnnouncer} from '@angular/material';
88
})
99
export class LiveAnnouncerDemo {
1010

11-
constructor(private live: MdLiveAnnouncer) {}
11+
constructor(private live: LiveAnnouncer) {}
1212

1313
announceText(message: string) {
1414
this.live.announce(message);

src/demo-app/overlay/overlay-demo.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
Pasta 2
77
</button>
88

9-
<button overlay-origin (click)="openSpaghettiPanel()">
9+
<button cdk-overlay-origin (click)="openSpaghettiPanel()">
1010
Pasta 3
1111
</button>
1212

1313

14-
<button overlay-origin #trigger="overlayOrigin" (click)="isMenuOpen = !isMenuOpen">
14+
<button cdk-overlay-origin #trigger="cdkOverlayOrigin" (click)="isMenuOpen = !isMenuOpen">
1515
Open menu
1616
</button>
1717

18-
<template connected-overlay [origin]="trigger" [width]="500" hasBackdrop [open]="isMenuOpen"
18+
<template cdk-connected-overlay [origin]="trigger" [width]="500" hasBackdrop [open]="isMenuOpen"
1919
(backdropClick)="isMenuOpen=false">
2020
<div style="background-color: mediumpurple" >
2121
This is the menu panel.
2222
</div>
2323
</template>
2424

2525
<!-- Template to load into an overlay. -->
26-
<template portal>
26+
<template cdk-portal>
2727
<p class="demo-fusilli"> Fusilli </p>
2828
</template>
2929

30-
<button (click)="openPanelWithBackdrop()">Backdrop panel</button>
30+
<button (click)="openPanelWithBackdrop()">Backdrop panel</button>

src/demo-app/overlay/overlay-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class OverlayDemo {
8282
.global()
8383
.centerHorizontally();
8484
config.hasBackdrop = true;
85-
config.backdropClass = 'md-overlay-transparent-backdrop';
85+
config.backdropClass = 'cdk-overlay-transparent-backdrop';
8686

8787
let overlayRef = this.overlay.create(config);
8888
overlayRef.attach(this.templatePortals.first);

src/demo-app/platform/platform-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {MdPlatform, getSupportedInputTypes} from '@angular/material';
2+
import {Platform, getSupportedInputTypes} from '@angular/material';
33

44

55
@Component({
@@ -10,5 +10,5 @@ import {MdPlatform, getSupportedInputTypes} from '@angular/material';
1010
export class PlatformDemo {
1111
supportedInputTypes = getSupportedInputTypes();
1212

13-
constructor(public platform: MdPlatform) {}
13+
constructor(public platform: Platform) {}
1414
}

src/demo-app/portal/portal-demo.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h2> The portal host is here: </h2>
22
<div class="demo-portal-host">
3-
<template [portalHost]="selectedPortal"></template>
3+
<template [cdkPortalHost]="selectedPortal"></template>
44
</div>
55

66
<button type="button" (click)="selectedPortal = programmingJoke">
@@ -20,12 +20,12 @@ <h2> The portal host is here: </h2>
2020
referring to something *in* the template (such as #item in ngFor). As such, the component
2121
has to use @ViewChild / @ViewChildren to get these references.
2222
See https://github.com/angular/angular/issues/7158 -->
23-
<template portal>
23+
<template cdk-portal>
2424
<p> - Why don't jokes work in octal?</p>
2525
<p> - Because 7 10 11.</p>
2626
</template>
2727

28-
<div *portal>
28+
<div *cdk-portal>
2929
<p> - Did you hear about this year's Fibonacci Conference? </p>
3030
<p> - It's going to be as big as the last two put together. </p>
3131
</div>

src/demo-app/projection/projection-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {DomProjectionHost, DomProjection} from '@angular/material';
77
template: `
88
<div class="demo-outer {{cssClass}}">
99
Before
10-
<dom-projection-host><ng-content></ng-content></dom-projection-host>
10+
<cdk-dom-projection-host><ng-content></ng-content></cdk-dom-projection-host>
1111
After
1212
</div>
1313
`,

src/lib/button-toggle/button-toggle.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<label [attr.for]="inputId" class="md-button-toggle-label">
2-
<input #input class="md-button-toggle-input md-visually-hidden"
2+
<input #input class="md-button-toggle-input cdk-visually-hidden"
33
[type]="_type"
44
[id]="inputId"
55
[checked]="checked"

src/lib/button-toggle/button-toggle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
import {NG_VALUE_ACCESSOR, ControlValueAccessor, FormsModule} from '@angular/forms';
2222
import {Observable} from 'rxjs/Observable';
2323
import {
24-
MdUniqueSelectionDispatcher,
24+
UniqueSelectionDispatcher,
2525
coerceBooleanProperty,
2626
DefaultStyleCompatibilityModeModule,
2727
} from '../core';
@@ -298,7 +298,7 @@ export class MdButtonToggle implements OnInit {
298298

299299
constructor(@Optional() toggleGroup: MdButtonToggleGroup,
300300
@Optional() toggleGroupMultiple: MdButtonToggleGroupMultiple,
301-
public buttonToggleDispatcher: MdUniqueSelectionDispatcher,
301+
public buttonToggleDispatcher: UniqueSelectionDispatcher,
302302
private _renderer: Renderer) {
303303
this.buttonToggleGroup = toggleGroup;
304304

@@ -445,7 +445,7 @@ export class MdButtonToggleModule {
445445
static forRoot(): ModuleWithProviders {
446446
return {
447447
ngModule: MdButtonToggleModule,
448-
providers: [MdUniqueSelectionDispatcher]
448+
providers: [UniqueSelectionDispatcher]
449449
};
450450
}
451451
}

src/lib/button/button.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
pointer-events: none;
8282
opacity: 0;
8383

84-
@include md-high-contrast {
84+
@include cdk-high-contrast {
8585
// Note that IE will render this in the same way, no
8686
// matter whether the theme is light or dark. This helps
8787
// with the readability of focused buttons.
@@ -98,7 +98,7 @@
9898
}
9999

100100
// Add an outline to make it more visible in high contrast mode.
101-
@include md-high-contrast {
101+
@include cdk-high-contrast {
102102
[md-button], [md-raised-button], [md-icon-button], [md-fab], [md-mini-fab] {
103103
outline: solid 1px;
104104
}

src/lib/card/card.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ md-card {
1717
border-radius: $md-card-border-radius;
1818
font-family: $md-font-family;
1919

20-
@include md-high-contrast {
20+
@include cdk-high-contrast {
2121
outline: solid 1px;
2222
}
2323
}

src/lib/checkbox/checkbox.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<label class="md-checkbox-layout">
22
<div class="md-checkbox-inner-container">
33
<input #input
4-
class="md-checkbox-input md-visually-hidden" type="checkbox"
4+
class="md-checkbox-input cdk-visually-hidden" type="checkbox"
55
[id]="inputId"
66
[required]="required"
77
[checked]="checked"

src/lib/chips/chip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Renderer
1010
} from '@angular/core';
1111

12-
import {MdFocusable} from '../core/a11y/list-key-manager';
12+
import {Focusable} from '../core/a11y/list-key-manager';
1313
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
1414

1515
export interface MdChipEvent {
@@ -32,7 +32,7 @@ export interface MdChipEvent {
3232
'(click)': '_handleClick($event)'
3333
}
3434
})
35-
export class MdChip implements MdFocusable, OnInit, OnDestroy {
35+
export class MdChip implements Focusable, OnInit, OnDestroy {
3636

3737
/* Whether or not the chip is disabled. */
3838
protected _disabled: boolean = null;

src/lib/core/_core.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
}
1818

1919
@include md-ripple();
20-
@include md-a11y();
21-
@include md-overlay();
20+
@include cdk-a11y();
21+
@include cdk-overlay();
2222
}
2323

2424
// Mixin that renders all of the core styles that depend on the theme.

src/lib/core/a11y/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# MdLiveAnnouncer
2-
`MdLiveAnnouncer` is a service, which announces messages to several screenreaders.
1+
# LiveAnnouncer
2+
`LiveAnnouncer` is a service, which announces messages to several screenreaders.
33

44
### Methods
55

@@ -12,11 +12,11 @@ The service can be injected in a component.
1212
```ts
1313
@Component({
1414
selector: 'my-component'
15-
providers: [MdLiveAnnouncer]
15+
providers: [LiveAnnouncer]
1616
})
1717
export class MyComponent {
1818

19-
constructor(live: MdLiveAnnouncer) {
19+
constructor(live: LiveAnnouncer) {
2020
live.announce("Hey Google");
2121
}
2222

src/lib/core/a11y/_a11y.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@mixin md-a11y {
2-
.md-visually-hidden {
1+
@mixin cdk-a11y {
2+
.cdk-visually-hidden {
33
border: 0;
44
clip: rect(0 0 0 0);
55
height: 1px;
@@ -17,7 +17,7 @@
1717
* to Microsoft browsers. Chrome can be included by checking for the `html[hc]`
1818
* attribute, however Chrome handles high contrast differently.
1919
*/
20-
@mixin md-high-contrast {
20+
@mixin cdk-high-contrast {
2121
@media screen and (-ms-high-contrast: active) {
2222
@content;
2323
}

src/lib/core/a11y/focus-trap.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {By} from '@angular/platform-browser';
33
import {Component} from '@angular/core';
44
import {FocusTrap} from './focus-trap';
55
import {InteractivityChecker} from './interactivity-checker';
6-
import {MdPlatform} from '../platform/platform';
6+
import {Platform} from '../platform/platform';
77

88

99
describe('FocusTrap', () => {
@@ -12,12 +12,12 @@ describe('FocusTrap', () => {
1212

1313
let fixture: ComponentFixture<FocusTrapTestApp>;
1414
let focusTrapInstance: FocusTrap;
15-
let platform: MdPlatform = new MdPlatform();
15+
let platform: Platform = new Platform();
1616

1717
beforeEach(async(() => {
1818
TestBed.configureTestingModule({
1919
declarations: [FocusTrap, FocusTrapTestApp],
20-
providers: [InteractivityChecker, MdPlatform]
20+
providers: [InteractivityChecker, Platform]
2121
});
2222

2323
TestBed.compileComponents();
@@ -57,7 +57,7 @@ describe('FocusTrap', () => {
5757
beforeEach(async(() => {
5858
TestBed.configureTestingModule({
5959
declarations: [FocusTrap, FocusTrapTargetTestApp],
60-
providers: [InteractivityChecker, MdPlatform]
60+
providers: [InteractivityChecker, Platform]
6161
});
6262

6363
TestBed.compileComponents();
@@ -87,23 +87,23 @@ describe('FocusTrap', () => {
8787

8888
@Component({
8989
template: `
90-
<focus-trap>
90+
<cdk-focus-trap>
9191
<input>
9292
<button>SAVE</button>
93-
</focus-trap>
93+
</cdk-focus-trap>
9494
`
9595
})
9696
class FocusTrapTestApp { }
9797

9898

9999
@Component({
100100
template: `
101-
<focus-trap>
101+
<cdk-focus-trap>
102102
<input>
103-
<button id="last" md-focus-end></button>
104-
<button id="first" md-focus-start>SAVE</button>
103+
<button id="last" cdk-focus-end></button>
104+
<button id="first" cdk-focus-start>SAVE</button>
105105
<input>
106-
</focus-trap>
106+
</cdk-focus-trap>
107107
`
108108
})
109109
class FocusTrapTargetTestApp { }

src/lib/core/a11y/focus-trap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {coerceBooleanProperty} from '../coercion/boolean-property';
1313
*/
1414
@Component({
1515
moduleId: module.id,
16-
selector: 'focus-trap',
16+
selector: 'cdk-focus-trap, focus-trap',
1717
templateUrl: 'focus-trap.html',
1818
encapsulation: ViewEncapsulation.None,
1919
})
@@ -51,7 +51,7 @@ export class FocusTrap {
5151
/** Focuses the first tabbable element within the focus trap region. */
5252
focusFirstTabbableElement() {
5353
let rootElement = this.trappedContent.nativeElement;
54-
let redirectToElement = rootElement.querySelector('[md-focus-start]') as HTMLElement ||
54+
let redirectToElement = rootElement.querySelector('[cdk-focus-start]') as HTMLElement ||
5555
this._getFirstTabbableElement(rootElement);
5656

5757
if (redirectToElement) {
@@ -62,7 +62,7 @@ export class FocusTrap {
6262
/** Focuses the last tabbable element within the focus trap region. */
6363
focusLastTabbableElement() {
6464
let rootElement = this.trappedContent.nativeElement;
65-
let focusTargets = rootElement.querySelectorAll('[md-focus-end]');
65+
let focusTargets = rootElement.querySelectorAll('[cdk-focus-end]');
6666
let redirectToElement: HTMLElement = null;
6767

6868
if (focusTargets.length) {

src/lib/core/a11y/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {NgModule, ModuleWithProviders} from '@angular/core';
22
import {FocusTrap} from './focus-trap';
3-
import {MdLiveAnnouncer} from './live-announcer';
3+
import {LiveAnnouncer} from './live-announcer';
44
import {InteractivityChecker} from './interactivity-checker';
55
import {CommonModule} from '@angular/common';
66
import {PlatformModule} from '../platform/index';
77

8-
export const A11Y_PROVIDERS = [MdLiveAnnouncer, InteractivityChecker];
8+
export const A11Y_PROVIDERS = [LiveAnnouncer, InteractivityChecker];
99

1010
@NgModule({
1111
imports: [CommonModule, PlatformModule],

0 commit comments

Comments
 (0)