Skip to content

Commit

Permalink
feat: adjust theming mechanism, add bootstrap for grid, static module…
Browse files Browse the repository at this point in the history
… for static content
  • Loading branch information
tomastrajan committed May 13, 2017
1 parent 43a177f commit b1753ad
Show file tree
Hide file tree
Showing 30 changed files with 253 additions and 82 deletions.
3 changes: 3 additions & 0 deletions .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"styles": [
"styles.scss"
],
"stylePreprocessorOptions": {
"includePaths": ["./themes"]
},
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Angular, ngrx & Material Starter by [@tomastrajan](https://twitter.com/tomastrajan) [![Build Status](https://travis-ci.org/tomastrajan/angular-ngrx-material-starter.svg?branch=master)](https://travis-ci.org/tomastrajan/angular-ngrx-material-starter)
# Angular, ngrx and Angular Material Starter by [@tomastrajan](https://twitter.com/tomastrajan) [![Build Status](https://travis-ci.org/tomastrajan/angular-ngrx-material-starter.svg?branch=master)](https://travis-ci.org/tomastrajan/angular-ngrx-material-starter)
Check out [Demo & Documentation](http://tomastrajan.github.io/angular-ngrx-material-starter/)
Check out [Demo & Documentation](http://tomastrajan.github.io/angular-ngrx-material-starter/)

## Features

* Angular
* ngrx
* Angular Material
* Bootstrap 4 (only reset and grids)

## Build

Built with [Angular CLI](https://github.com/angular/angular-cli)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"@ngrx/core": "^1.2.0",
"@ngrx/effects": "^2.0.3",
"@ngrx/store": "^2.2.2",
"classlist.js": "^1.1.20150312",
"bootstrap": "^4.0.0-alpha.6",
"classlist.js": "^1.1",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"intl": "^1.2.5",
Expand Down
3 changes: 2 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { SettingsComponent } from './settings';
const routes: Routes = [
{
path: '',
children: []
redirectTo: 'about',
pathMatch: 'full'
}, {
path: 'settings',
component: SettingsComponent
Expand Down
58 changes: 30 additions & 28 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<div [class]="themeClass">
<md-toolbar color="primary" class="toolbar">
<span>Angular NGrx Material Starter</span>
<span class="spacer"></span>
<button md-button>About</button>
<button md-button>Features</button>
<button md-button>Examples</button>
<button md-icon-button [mdMenuTriggerFor]="toolbarMenu">
<md-icon>more_vert</md-icon>
</button>
<md-menu #toolbarMenu="mdMenu">
<button md-menu-item>
<md-icon>person</md-icon>
<span>Manage account</span>
<md-toolbar color="primary" class="toolbar">
<span>Angular NGrx Material Starter</span>
<span class="spacer"></span>
<button md-button routerLink="about" routerLinkActive="active">About</button>
<button md-button routerLink="features" routerLinkActive="active">Features</button>
<button md-button>Examples</button>
<button md-icon-button [mdMenuTriggerFor]="toolbarMenu">
<md-icon>more_vert</md-icon>
</button>
<button md-menu-item routerLink="settings">
<md-icon>settings</md-icon>
<span>Settings</span>
</button>
<button md-menu-item>
<md-icon>power_settings_new</md-icon>
<span>Logout</span>
</button>
</md-menu>
</md-toolbar>
<h1>
{{title}}
</h1>

<router-outlet></router-outlet>
<md-menu #toolbarMenu="mdMenu">
<button md-menu-item disabled>
<md-icon>person</md-icon>
<span>Manage account</span>
</button>
<button md-menu-item routerLink="settings">
<md-icon>settings</md-icon>
<span>Settings</span>
</button>
<button md-menu-item disabled>
<md-icon>power_settings_new</md-icon>
<span>Logout</span>
</button>
</md-menu>
</md-toolbar>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<router-outlet></router-outlet>
</div>
</div>
</div>
</div>
2 changes: 0 additions & 2 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


.toolbar{

button {
Expand Down
24 changes: 24 additions & 0 deletions src/app/app.component.scss-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import '~@angular/material/theming';
@import 'default-theme.scss';
@import 'alternative-theme.scss';

@mixin app-component-theme($theme) {
$accent: map-get($theme, accent);

.toolbar{
button {
&.active {
background-color: mat-color($accent);
}
}
}
}

.default-theme {
@include app-component-theme($anms-theme);
}

.alternative-theme {
@include app-component-theme($anms-alternative-theme);
}

12 changes: 0 additions & 12 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,4 @@ describe('AppComponent', () => {
expect(app).toBeTruthy();
}));

it(`should have as title 'anms works!'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('anms works!');
}));

it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('anms works!');
}));
});
16 changes: 8 additions & 8 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ import { OverlayContainer } from '@angular/material';
import { Store } from '@ngrx/store';
import { Subject } from 'rxjs/Subject';
import 'rxjs/add/operator/takeUntil';
import 'rxjs/add/operator/map';

@Component({
selector: 'anms-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
styleUrls: ['./app.component.scss', './app.component.scss-theme.scss']
})
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')
store
.select('settings')
.takeUntil(this.unsubscribe$)
.subscribe(({ theme }) => {
const themeClass = theme.toLowerCase();
overlayContainer.themeClass = themeClass;
this.themeClass = themeClass;
.map(({ theme }) => theme.toLowerCase())
.subscribe(theme => {
this.themeClass = theme;
overlayContainer.themeClass = theme;
});
}

Expand Down
11 changes: 9 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@ import { SharedModule } from './shared/shared.module';

import { CoreModule } from './core';
import { SettingsModule } from './settings';
import { StaticModule } from './static';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
imports: [
// angular
BrowserAnimationsModule,
BrowserModule,
HttpModule,
AppRoutingModule,

// core & shared
CoreModule,
SharedModule,

SettingsModule
// features
StaticModule,
SettingsModule,

// app
AppRoutingModule
],
declarations: [
AppComponent
Expand Down
2 changes: 1 addition & 1 deletion src/app/settings/settings.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Action } from '@ngrx/store';
export const SETTINGS_THEME = 'SETTINGS_THEME';

export const initialState = {
theme: 'default'
theme: 'DEFAULT-THEME'
};

export function settingsReducer(state = initialState, action: Action) {
Expand Down
17 changes: 12 additions & 5 deletions src/app/settings/settings/settings.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<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>
<div class="row">
<div class="col-sm-12"><h1>Settings</h1></div>
</div>
<br>
<div class="row">
<md-select class="col-md-4" placeholder="Select theme" name="theme"
[ngModel]="theme" (change)="onThemeSelect($event)">
<md-option *ngFor="let t of themes" [value]="t.value">
{{t.label}}
</md-option>
</md-select>
</div>
2 changes: 1 addition & 1 deletion src/app/settings/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class SettingsComponent implements OnInit, OnDestroy {

themes = [
{ value: 'DEFAULT-THEME', label: 'Default' },
{ value: 'DARK-THEME', label: 'Dark' }
{ value: 'ALTERNATIVE-THEME', label: 'Alternative' }
];

constructor(private store: Store<any>) {
Expand Down
3 changes: 3 additions & 0 deletions src/app/static/about/about.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
about works!
</p>
Empty file.
25 changes: 25 additions & 0 deletions src/app/static/about/about.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { AboutComponent } from './about.component';

describe('AboutComponent', () => {
let component: AboutComponent;
let fixture: ComponentFixture<AboutComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AboutComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AboutComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/static/about/about.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'anms-about',
templateUrl: './about.component.html',
styleUrls: ['./about.component.scss']
})
export class AboutComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
3 changes: 3 additions & 0 deletions src/app/static/features/features.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
features works!
</p>
Empty file.
25 changes: 25 additions & 0 deletions src/app/static/features/features.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { FeaturesComponent } from './features.component';

describe('FeaturesComponent', () => {
let component: FeaturesComponent;
let fixture: ComponentFixture<FeaturesComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FeaturesComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(FeaturesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/static/features/features.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'anms-features',
templateUrl: './features.component.html',
styleUrls: ['./features.component.scss']
})
export class FeaturesComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
3 changes: 3 additions & 0 deletions src/app/static/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './static-routing.module';
export * from './static.module';
export * from './about/about.component';
16 changes: 16 additions & 0 deletions src/app/static/static-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { AboutComponent } from './about/about.component';
import { FeaturesComponent } from './features/features.component';

const routes: Routes = [
{ path: 'about', component: AboutComponent },
{ path: 'features', component: FeaturesComponent }
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class StaticRoutingModule { }
21 changes: 21 additions & 0 deletions src/app/static/static.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { SharedModule } from '../shared';

import { StaticRoutingModule } from './static-routing.module';
import { AboutComponent } from './about/about.component';
import { FeaturesComponent } from './features/features.component';

@NgModule({
imports: [
CommonModule,
SharedModule,
StaticRoutingModule
],
declarations: [
AboutComponent,
FeaturesComponent
]
})
export class StaticModule { }

0 comments on commit b1753ad

Please sign in to comment.