Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
feat(core): MdcThemeModule moved into MdcCoreModule (#277)
Browse files Browse the repository at this point in the history
Remove requirement for developers to import `MdcThemeModule` separately.

BREAKING CHANGE: Remove `MdcThemeModule` import from your code, and replace it with `MdcCoreModule` if not already imported.

Closes #243
  • Loading branch information
trimox authored Oct 13, 2017
1 parent 2437511 commit 68bb43c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 17 deletions.
6 changes: 0 additions & 6 deletions src/demo-app/demo-material.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
MdcCheckboxModule,
MdcDialogModule,
MdcDrawerModule,
MdcElevationModule,
MdcFabModule,
MdcFormFieldModule,
MdcIconToggleModule,
Expand All @@ -19,9 +18,7 @@ import {
MdcSwitchModule,
MdcTabModule,
MdcTextfieldModule,
MdcThemeModule,
MdcToolbarModule,
MdcRippleModule,
// } from '@angular-mdc/web';
} from '../lib/public_api';

Expand All @@ -32,7 +29,6 @@ import {
MdcCheckboxModule,
MdcDialogModule,
MdcDrawerModule,
MdcElevationModule,
MdcFabModule,
MdcFormFieldModule,
MdcIconToggleModule,
Expand All @@ -46,9 +42,7 @@ import {
MdcSwitchModule,
MdcTabModule,
MdcTextfieldModule,
MdcThemeModule,
MdcToolbarModule,
MdcRippleModule,
]
})
export class DemoMaterialModule { }
2 changes: 2 additions & 0 deletions src/lib/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { MdcRippleModule } from './ripple/index';
import { MdcMaterialIconModule } from './material-icon/index';
import { MdcTypographyModule } from './typography/index';
import { MdcElevationModule } from './elevation/index';
import { MdcThemeModule } from './theme/index';

const CORE_DIRECTIVES = [
MdcElevationModule,
MdcMaterialIconModule,
MdcTypographyModule,
MdcRippleModule,
MdcThemeModule,
];

@NgModule({
Expand Down
1 change: 1 addition & 0 deletions src/lib/core/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './elevation/index';
export * from './material-icon/index';
export * from './typography/index';
export * from './ripple/index';
export * from './theme/index';
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,28 @@ import {
Renderer2,
SimpleChange,
} from '@angular/core';
import { toBoolean } from '../common';
import { toBoolean } from '../../common';

@Directive({
selector: '[mdc-theme-dark]'
})
export class MdcThemeDark implements OnChanges {
private nativeEl: ElementRef;
private _mdcThemeDark: boolean;
private mdcThemeDark_: boolean;

@Input('mdc-theme-dark') mdcThemeDark: boolean;

constructor(
private _renderer: Renderer2,
private _root: ElementRef) {
this.nativeEl = this._root.nativeElement;
private renderer_: Renderer2,
public elementRef: ElementRef) {
}

ngOnChanges(changes: { [key: string]: SimpleChange }) {
let change = changes['mdcThemeDark'];

if (!toBoolean(change.currentValue)) {
this._renderer.removeClass(this.nativeEl, 'mdc-theme--dark');
this.renderer_.removeClass(this.elementRef.nativeElement, 'mdc-theme--dark');
} else {
this._renderer.addClass(this.nativeEl, 'mdc-theme--dark');
this.renderer_.addClass(this.elementRef.nativeElement, 'mdc-theme--dark');
}
}
}
4 changes: 2 additions & 2 deletions src/lib/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MdcDialogModule } from './dialog/index';
import { MdcDrawerModule } from './drawer/index';
import { MdcFabModule } from './fab/index';
import { MdcFormFieldModule } from './form-field/index';
import { MdcIconModule } from './icon/index';
import { MdcIconToggleModule } from './icon-toggle/index';
import { MdcLinearProgressModule } from './linear-progress/index';
import { MdcListModule } from './list/index';
Expand All @@ -18,7 +19,6 @@ import { MdcSnackbarModule } from './snackbar/index';
import { MdcSwitchModule } from './switch/index';
import { MdcTabModule } from './tabs/index';
import { MdcTextfieldModule } from './textfield/index';
import { MdcThemeModule } from './theme/index';
import { MdcToolbarModule } from './toolbar/index';

const MATERIAL_MODULES = [
Expand All @@ -30,6 +30,7 @@ const MATERIAL_MODULES = [
MdcDrawerModule,
MdcFabModule,
MdcFormFieldModule,
MdcIconModule,
MdcIconToggleModule,
MdcLinearProgressModule,
MdcListModule,
Expand All @@ -40,7 +41,6 @@ const MATERIAL_MODULES = [
MdcSwitchModule,
MdcTabModule,
MdcTextfieldModule,
MdcThemeModule,
MdcToolbarModule,
];

Expand Down
1 change: 0 additions & 1 deletion src/lib/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export * from './snackbar/index';
export * from './switch/index';
export * from './tabs/index';
export * from './textfield/index';
export * from './theme/index';
export * from './toolbar/index';

export * from './cdk/overlay/index';
Expand Down

0 comments on commit 68bb43c

Please sign in to comment.