-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0314346
commit 43a177f
Showing
20 changed files
with
195 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnDestroy } from '@angular/core'; | ||
import { OverlayContainer } from '@angular/material'; | ||
import { Store } from '@ngrx/store'; | ||
import { Subject } from 'rxjs/Subject'; | ||
import 'rxjs/add/operator/takeUntil'; | ||
|
||
@Component({ | ||
selector: 'anms-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.scss'] | ||
}) | ||
export class AppComponent { | ||
export class AppComponent implements OnDestroy { | ||
|
||
private unsubscribe$: Subject<void> = new Subject<void>(); | ||
|
||
themeClass: string; | ||
|
||
title = 'anms works!'; | ||
|
||
constructor( | ||
overlayContainer: OverlayContainer, | ||
private store: Store<any> | ||
) { | ||
store.select('settings') | ||
.takeUntil(this.unsubscribe$) | ||
.subscribe(({ theme }) => { | ||
const themeClass = theme.toLowerCase(); | ||
overlayContainer.themeClass = themeClass; | ||
this.themeClass = themeClass; | ||
}); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.unsubscribe$.next(); | ||
this.unsubscribe$.complete(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './core.module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './settings.module'; | ||
export * from './settings.reducer'; | ||
export * from './settings/settings.component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
import { SharedModule } from '../shared'; | ||
|
||
import { SettingsComponent } from './settings/settings.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
SharedModule | ||
], | ||
declarations: [SettingsComponent] | ||
}) | ||
export class SettingsModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Action } from '@ngrx/store'; | ||
|
||
export const SETTINGS_THEME = 'SETTINGS_THEME'; | ||
|
||
export const initialState = { | ||
theme: 'default' | ||
}; | ||
|
||
export function settingsReducer(state = initialState, action: Action) { | ||
switch (action.type) { | ||
case SETTINGS_THEME: | ||
return { theme: action.payload }; | ||
|
||
default: | ||
return state; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<md-select placeholder="Select theme" [ngModel]="theme" (change)="onThemeSelect($event)" name="theme"> | ||
<md-option *ngFor="let t of themes" [value]="t.value"> | ||
{{t.label}} | ||
</md-option> | ||
</md-select> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { CoreModule } from '../../core'; | ||
import { SharedModule } from '../../shared'; | ||
|
||
import { SettingsComponent } from './settings.component'; | ||
|
||
describe('SettingsComponent', () => { | ||
let component: SettingsComponent; | ||
let fixture: ComponentFixture<SettingsComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NoopAnimationsModule, | ||
CoreModule, | ||
SharedModule | ||
], | ||
declarations: [ SettingsComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SettingsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Component, OnInit, OnDestroy } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
import { Subject } from 'rxjs/Subject'; | ||
import 'rxjs/add/operator/takeUntil'; | ||
import { SETTINGS_THEME } from '../settings.reducer'; | ||
|
||
@Component({ | ||
selector: 'anms-settings', | ||
templateUrl: './settings.component.html', | ||
styleUrls: ['./settings.component.scss'] | ||
}) | ||
export class SettingsComponent implements OnInit, OnDestroy { | ||
|
||
private unsubscribe$: Subject<void> = new Subject<void>(); | ||
theme: string; | ||
|
||
themes = [ | ||
{ value: 'DEFAULT-THEME', label: 'Default' }, | ||
{ value: 'DARK-THEME', label: 'Dark' } | ||
]; | ||
|
||
constructor(private store: Store<any>) { | ||
store.select('settings') | ||
.takeUntil(this.unsubscribe$) | ||
.subscribe(({ theme }) => this.theme = theme); | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.unsubscribe$.next(); | ||
this.unsubscribe$.complete(); | ||
} | ||
|
||
onThemeSelect({ value }) { | ||
this.store.dispatch({ type: SETTINGS_THEME, payload: value }); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './shared.module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$anms-dark-primary: mat-palette($mat-indigo, 900); | ||
$anms-dark-accent: mat-palette($mat-amber, A200, A100, A400); | ||
$anms-dark-warn: mat-palette($mat-deep-orange); | ||
$anms-dark-theme: mat-dark-theme($anms-dark-primary, $anms-dark-accent, $anms-dark-warn); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$anms-primary: mat-palette($mat-amber); | ||
$anms-accent: mat-palette($mat-pink, A200, A100, A400); | ||
$anms-warn: mat-palette($mat-red); | ||
|
||
$anms-theme: mat-light-theme($anms-primary, $anms-accent, $anms-warn); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,14 @@ | ||
@import 'reset.scss'; | ||
|
||
@import '~@angular/material/theming'; | ||
// Plus imports for other components in your app. | ||
|
||
// Include the common styles for Angular Material. We include this here so that you only | ||
// have to load a single css file for Angular Material in your app. | ||
// Be sure that you only ever include this mixin once! | ||
@include mat-core(); | ||
|
||
// Define the palettes for your theme using the Material Design palettes available in palette.scss | ||
// (imported above). For each palette, you can optionally specify a default, lighter, and darker | ||
// hue. | ||
$anms-primary: mat-palette($mat-amber); | ||
$anms-accent: mat-palette($mat-pink, A200, A100, A400); | ||
@import 'styles-theme-default.scss'; | ||
@import 'styles-theme-dark.scss'; | ||
|
||
// The warn palette is optional (defaults to red). | ||
$anms-warn: mat-palette($mat-red); | ||
|
||
// Create the theme object (a Sass map containing all of the palettes). | ||
$anms-theme: mat-light-theme($anms-primary, $anms-accent, $anms-warn); | ||
|
||
// Include theme styles for core and each component used in your app. | ||
// Alternatively, you can import and @include the theme mixins for each component | ||
// that you are using. | ||
@include angular-material-theme($anms-theme); | ||
|
||
.dark-theme { | ||
@include angular-material-theme($anms-dark-theme); | ||
} |