-
Notifications
You must be signed in to change notification settings - Fork 4
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
ea5f918
commit 3877b28
Showing
26 changed files
with
308 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
<div [classList]="themeName + ' theme-wrapper'"> | ||
|
||
<mc-navbar> | ||
<mc-navbar-container position="left"> | ||
<mc-navbar-item> | ||
<i mc-icon="mc-hamburger_16"></i> | ||
</mc-navbar-item> | ||
<mc-navbar-brand> | ||
<mc-navbar-logo> | ||
<svg class="logo" height="32" viewBox="0 0 32 32" width="32" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="m0 32h32v-32h-32z" fill="#c00"/><path d="m11.7013126 2.13713398h3.4056699v5.22500971c.0083884 1.2815534 1.0494758 2.31984466 2.3304078 2.32543689v-1.89825242c-.2370486-.00528156-.4296699-.19231068-.432466-.42718447v-5.22500971h3.4050485v-1.89794175h-8.7086602zm-3.29065629-1.89806602h-5.95976699-.0167767c-1.28062136.00590291-2.3192233 1.04978641-2.32481553 2.33351456h1.89794174c.00590292-.23735922.19262136-.42407767.42687379-.43557281h5.97654369c.24295146 0 .44054369.19821359.44054369.44427184v.97646602c0 .23735923-.19759223.43867961-.44054369.43867961l-5.97654369.00248544c-1.28062136.01118447-2.3192233 1.04667961-2.32481553 2.33071845v3.35782524h1.89794174v-3.35782524c.00590292-.23207767.19262136-.42438835.42687379-.42718447h5.97654369c1.28932039 0 2.34190289-1.05227184 2.34190289-2.34469903v-.97646602c0-1.29242718-1.0525825-2.34221359-2.34190289-2.34221359" fill="#fff" transform="translate(5.592 10.889)"/></g></svg> | ||
</mc-navbar-logo> | ||
<mc-navbar-title>PT Brand</mc-navbar-title> | ||
</mc-navbar-brand> | ||
</mc-navbar-container> | ||
<mc-navbar-container position="right"> | ||
<mc-navbar-item> | ||
<select name="theme" [(ngModel)]="themeName"> | ||
<option value="theme-default">theme-default</option> | ||
<option value="theme-dark">theme-dark</option> | ||
<option value="theme-green">theme-green</option> | ||
</select> | ||
</mc-navbar-item> | ||
<mc-navbar> | ||
<mc-navbar-container position="left"> | ||
<mc-navbar-item> | ||
<i mc-icon="mc-hamburger_16"></i> | ||
</mc-navbar-item> | ||
<mc-navbar-brand> | ||
<mc-navbar-logo> | ||
<svg class="logo" height="32" viewBox="0 0 32 32" width="32" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="m0 32h32v-32h-32z" fill="#c00"/><path d="m11.7013126 2.13713398h3.4056699v5.22500971c.0083884 1.2815534 1.0494758 2.31984466 2.3304078 2.32543689v-1.89825242c-.2370486-.00528156-.4296699-.19231068-.432466-.42718447v-5.22500971h3.4050485v-1.89794175h-8.7086602zm-3.29065629-1.89806602h-5.95976699-.0167767c-1.28062136.00590291-2.3192233 1.04978641-2.32481553 2.33351456h1.89794174c.00590292-.23735922.19262136-.42407767.42687379-.43557281h5.97654369c.24295146 0 .44054369.19821359.44054369.44427184v.97646602c0 .23735923-.19759223.43867961-.44054369.43867961l-5.97654369.00248544c-1.28062136.01118447-2.3192233 1.04667961-2.32481553 2.33071845v3.35782524h1.89794174v-3.35782524c.00590292-.23207767.19262136-.42438835.42687379-.42718447h5.97654369c1.28932039 0 2.34190289-1.05227184 2.34190289-2.34469903v-.97646602c0-1.29242718-1.0525825-2.34221359-2.34190289-2.34221359" fill="#fff" transform="translate(5.592 10.889)"/></g></svg> | ||
</mc-navbar-logo> | ||
<mc-navbar-title>PT Brand</mc-navbar-title> | ||
</mc-navbar-brand> | ||
</mc-navbar-container> | ||
<mc-navbar-container position="right"> | ||
<mc-navbar-item> | ||
<select name="theme" [(ngModel)]="currentModelTheme" (ngModelChange)="themeChange($event)"> | ||
<option value="default">theme-default</option> | ||
<option value="dark">theme-dark</option> | ||
<option value="green">theme-green</option> | ||
</select> | ||
</mc-navbar-item> | ||
|
||
</mc-navbar-container> | ||
</mc-navbar> | ||
|
||
<router-outlet></router-outlet> | ||
</div> | ||
</mc-navbar-container> | ||
</mc-navbar> | ||
|
||
<router-outlet></router-outlet> |
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,37 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit, Renderer2 } from '@angular/core'; | ||
import { AppTheme } from '@libs/api-models'; | ||
import { LayoutFacade } from '@libs/store/layout'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html' | ||
}) | ||
export class AppComponent { | ||
themeName = 'theme-default'; | ||
export class AppComponent implements OnInit { | ||
|
||
currentModelTheme: AppTheme; | ||
currentTheme: AppTheme; | ||
|
||
constructor( | ||
private renderer: Renderer2, | ||
private layoutFacade: LayoutFacade | ||
) {} | ||
|
||
ngOnInit() { | ||
this.layoutFacade.getTheme().subscribe((theme) => { | ||
this.changeThemeOnBody(theme); | ||
}); | ||
} | ||
|
||
themeChange(newTheme: AppTheme) { | ||
this.layoutFacade.setTheme(newTheme); | ||
} | ||
|
||
private changeThemeOnBody(theme) { | ||
if (theme) { | ||
this.renderer.removeClass(document.body, `theme-${this.currentTheme}`); | ||
this.currentTheme = this.currentModelTheme = theme; | ||
this.renderer.addClass(document.body, `theme-${theme}`); | ||
} | ||
} | ||
} |
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
Empty file.
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 './lib/layout.model'; |
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,2 @@ | ||
|
||
export type AppTheme = 'default' | 'dark' | 'green' ; |
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,28 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc/libs/api-models", | ||
"target": "es2015", | ||
"module": "es2015", | ||
"moduleResolution": "node", | ||
"declaration": true, | ||
"sourceMap": true, | ||
"inlineSources": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"importHelpers": true, | ||
"types": [], | ||
"lib": [ | ||
"dom", | ||
"es2015" | ||
] | ||
}, | ||
"angularCompilerOptions": { | ||
"annotateForClosureCompiler": true, | ||
"skipTemplateCodegen": true, | ||
"strictMetadataEmit": true, | ||
"fullTemplateTypeCheck": true, | ||
"strictInjectionParameters": true, | ||
"enableResourceInlining": true | ||
} | ||
} |
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 @@ | ||
{ | ||
"extends": "../../tslint.json" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './lib/state-layout.module'; | ||
export * from './lib/state/facade'; |
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,23 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { StoreRouterConnectingModule } from '@ngrx/router-store'; | ||
import { StoreModule } from '@ngrx/store'; | ||
|
||
import { reducer } from './state/reducers'; | ||
|
||
|
||
export const ROUTING_FEATURE = 'layout'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
|
||
StoreRouterConnectingModule.forRoot({ | ||
stateKey: ROUTING_FEATURE | ||
}), | ||
|
||
StoreModule.forFeature(ROUTING_FEATURE, reducer) | ||
] | ||
}) | ||
export class StateLayoutModule { | ||
} |
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 @@ | ||
import { AppTheme } from '@libs/api-models'; | ||
import { createAction, props } from '@ngrx/store'; | ||
|
||
|
||
export const setAppTheme = createAction('[Layout] Set App Theme', props<{ theme: AppTheme }>()); |
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,27 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { AppTheme } from '@libs/api-models'; | ||
import { select, Store } from '@ngrx/store'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { setAppTheme } from './actions'; | ||
import { IState } from './reducers'; | ||
import { getSelectorTheme } from './selectors'; | ||
|
||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class LayoutFacade { | ||
|
||
constructor( | ||
private store: Store<IState> | ||
) {} | ||
|
||
getTheme(): Observable<AppTheme> { | ||
return this.store.pipe(select(getSelectorTheme)); | ||
} | ||
|
||
setTheme(theme: AppTheme) { | ||
this.store.dispatch(setAppTheme({ theme })); | ||
} | ||
} |
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,25 @@ | ||
import { AppTheme } from '@libs/api-models'; | ||
import { Action, createReducer, on } from '@ngrx/store'; | ||
|
||
import * as LayoutActions from './actions'; | ||
|
||
|
||
export interface IState { | ||
theme: AppTheme; | ||
} | ||
|
||
const initialState: IState = { | ||
theme: 'default' | ||
}; | ||
|
||
const layoutReducer = createReducer( | ||
initialState, | ||
on(LayoutActions.setAppTheme, (state, action) => ({ | ||
...state, | ||
theme: action.theme | ||
})) | ||
); | ||
|
||
export function reducer(state: IState | undefined, action: Action) { | ||
return layoutReducer(state, action); | ||
} |
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,14 @@ | ||
import { createFeatureSelector, createSelector } from '@ngrx/store'; | ||
|
||
import { IState } from './reducers'; | ||
|
||
|
||
const getTheme = (state: IState) => state.theme; | ||
|
||
const selectLayoutState = createFeatureSelector<IState>('layout'); | ||
|
||
|
||
export const getSelectorTheme = createSelector( | ||
selectLayoutState, | ||
getTheme | ||
); |
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 @@ | ||
{ | ||
"extends": "../../../tsconfig.json" | ||
} |
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,32 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../dist/out-tsc/libs/store/layout", | ||
"target": "es2015", | ||
"module": "es2015", | ||
"moduleResolution": "node", | ||
"declaration": true, | ||
"sourceMap": true, | ||
"inlineSources": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"importHelpers": true, | ||
"types": [], | ||
"lib": [ | ||
"dom", | ||
"es2018" | ||
] | ||
}, | ||
"angularCompilerOptions": { | ||
"annotateForClosureCompiler": true, | ||
"skipTemplateCodegen": true, | ||
"strictMetadataEmit": true, | ||
"fullTemplateTypeCheck": true, | ||
"strictInjectionParameters": true, | ||
"enableResourceInlining": true | ||
}, | ||
"exclude": [ | ||
"src/test.ts", | ||
"**/*.spec.ts" | ||
] | ||
} |
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 @@ | ||
{ | ||
"extends": "../../../tslint.json" | ||
} |
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 './lib/state-root.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,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { EffectsModule } from '@ngrx/effects'; | ||
import { StoreModule } from '@ngrx/store'; | ||
|
||
|
||
@NgModule({ | ||
imports: [ | ||
StoreModule.forRoot({}), | ||
EffectsModule.forRoot([]) | ||
] | ||
}) | ||
export class StoreRootModule { | ||
} |
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 @@ | ||
{ | ||
"extends": "../../../tsconfig.json" | ||
} |
Oops, something went wrong.