Skip to content

Commit

Permalink
feat: add share module, add header toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
tomastrajan committed May 12, 2017
1 parent 3ea3e3f commit 0314346
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"prefix": "anms",
"styles": [
"styles.scss"
],
Expand Down
15 changes: 15 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
children: []
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
27 changes: 25 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<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>
</button>
<button md-menu-item>
<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}}

<button md-raised-button>Raised button</button>
</h1>
<router-outlet></router-outlet>
12 changes: 12 additions & 0 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


.toolbar{

button {
margin: 0 10px 0 0;
}

.spacer {
flex: 1 1 auto;
}
}
12 changes: 9 additions & 3 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';

import { SharedModule } from './shared/shared.module';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
SharedModule
],
declarations: [
AppComponent
],
Expand All @@ -17,16 +23,16 @@ describe('AppComponent', () => {
expect(app).toBeTruthy();
}));

it(`should have as title 'app works!'`, async(() => {
it(`should have as title 'anms works!'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
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('app works!');
expect(compiled.querySelector('h1').textContent).toContain('anms works!');
}));
});
4 changes: 2 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-root',
selector: 'anms-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'app works!';
title = 'anms works!';
}
13 changes: 6 additions & 7 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import 'hammerjs';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MdButtonModule } from '@angular/material';

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

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

@NgModule({
imports: [
BrowserAnimationsModule,
BrowserModule,
FormsModule,
HttpModule,
BrowserAnimationsModule,
MdButtonModule
AppRoutingModule,
SharedModule
],
declarations: [
AppComponent
Expand Down
10 changes: 10 additions & 0 deletions src/app/core/core.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

@NgModule({
imports: [
CommonModule
],
declarations: []
})
export class CoreModule { }
32 changes: 32 additions & 0 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {
MdButtonModule,
MdToolbarModule,
MdMenuModule,
MdIconModule
} from '@angular/material';

@NgModule({
imports: [
CommonModule,
FormsModule,

MdButtonModule,
MdToolbarModule,
MdMenuModule,
MdIconModule
],
declarations: [],
exports: [
CommonModule,
FormsModule,

MdButtonModule,
MdMenuModule,
MdToolbarModule,
MdIconModule
]
})
export class SharedModule { }
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root>Loading...</app-root>
<anms-root>Loading...</anms-root>
</body>
</html>
4 changes: 4 additions & 0 deletions src/reset.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
margin: 0;
padding: 0;
}
Empty file added src/styles-theme.scss
Empty file.
28 changes: 26 additions & 2 deletions src/styles.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
/* You can add global styles to this file, and also import other style files */
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
@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);

// 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);
4 changes: 2 additions & 2 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@
"directive-selector": [
true,
"attribute",
"app",
"anms",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"anms",
"kebab-case"
],
"use-input-property-decorator": true,
Expand Down

4 comments on commit 0314346

@keymanjacob
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Tom, Can you please help me understand how you set up the mappings for the label branding? like how you map 'project-prefix.title.long' to the particular property defined in the en,json files under /i18n folder. Thanks

@tomastrajan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keymanjacob am not sure I understand the question? Also based on the question location ?

@keymanjacob
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomastrajan Sorry about the confusion. My question was that in en.json file (angular-ngrx-material-starter/projects/angular-ngrx-material-starter/src/assets/i18n/en.json) we can find properties like "anms.title.long": "Angular NgRx Material Starter". And they are used pretty much everywhere in html and ts files. I want to understand what was done to be able to map them so that we can use these props directly.

@tomastrajan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keymanjacob the project uses ngx-translate to transform keys into real translations based on selected language, hope that helps!

Please sign in to comment.