Skip to content
This repository was archived by the owner on May 7, 2018. It is now read-only.

Commit 5192916

Browse files
committed
feat: app bootstrap
1 parent 511809f commit 5192916

7 files changed

+62
-24
lines changed

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"license": "MIT",
55
"scripts": {
66
"ng": "ng",
7-
"start": "ng serve",
7+
"start": "yarn run serve:dev",
8+
"serve": "ng serve",
9+
"serve:dev": "yarn run serve -- --dev",
10+
"serve:prod": "yarn run serve -- --prod --aot --extract-css",
811
"build": "ng build",
912
"test": "ng test",
1013
"lint": "ng lint",
@@ -21,6 +24,8 @@
2124
"@angular/platform-browser-dynamic": "^4.0.0",
2225
"@angular/router": "^4.0.0",
2326
"core-js": "^2.4.1",
27+
"milligram": "^1.3.0",
28+
"normalize.css": "^6.0.0",
2429
"rxjs": "^5.1.0",
2530
"zone.js": "^0.8.4"
2631
},
@@ -35,9 +40,9 @@
3540
"karma": "~1.4.1",
3641
"karma-chrome-launcher": "~2.0.0",
3742
"karma-cli": "~1.0.1",
43+
"karma-coverage-istanbul-reporter": "^0.2.0",
3844
"karma-jasmine": "~1.1.0",
3945
"karma-jasmine-html-reporter": "^0.2.2",
40-
"karma-coverage-istanbul-reporter": "^0.2.0",
4146
"protractor": "~5.1.0",
4247
"ts-node": "~2.0.0",
4348
"tslint": "~4.5.0",

src/app/app.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<h1>
2-
{{title}}
3-
</h1>
1+
2+
<rc-content-links [document]="index" (selected)="onNavigate($event)"></rc-content-links>
3+
<rc-content-host [document]="current"></rc-content-host>

src/app/app.component.spec.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import { TestBed, async } from '@angular/core/testing';
2+
import { HttpModule } from '@angular/http';
23

34
import { AppComponent } from './app.component';
5+
import { ContentModule } from './content/content.module';
6+
import { ReactiveModule } from './reactive/reactive.module';
47

58
describe('AppComponent', () => {
69
beforeEach(async(() => {
710
TestBed.configureTestingModule({
11+
imports: [
12+
ContentModule.forRoot(),
13+
ReactiveModule.forRoot(),
14+
HttpModule
15+
],
816
declarations: [
917
AppComponent
1018
],
@@ -17,16 +25,4 @@ describe('AppComponent', () => {
1725
expect(app).toBeTruthy();
1826
}));
1927

20-
it(`should have as title 'app works!'`, async(() => {
21-
const fixture = TestBed.createComponent(AppComponent);
22-
const app = fixture.debugElement.componentInstance;
23-
expect(app.title).toEqual('app works!');
24-
}));
25-
26-
it('should render title in a h1 tag', async(() => {
27-
const fixture = TestBed.createComponent(AppComponent);
28-
fixture.detectChanges();
29-
const compiled = fixture.debugElement.nativeElement;
30-
expect(compiled.querySelector('h1').textContent).toContain('app works!');
31-
}));
3228
});

src/app/app.component.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
1-
import { Component } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
2+
import { ContentSourceService, ContentDocument, LinkWithRel } from './reactive-content';
23

34
@Component({
4-
selector: 'app-root',
5+
selector: 'rc-root',
56
templateUrl: './app.component.html',
67
styleUrls: ['./app.component.css']
78
})
8-
export class AppComponent {
9-
title = 'app works!';
9+
export class AppComponent implements OnInit {
10+
11+
public index: ContentDocument;
12+
public current: ContentDocument;
13+
14+
constructor(
15+
private content: ContentSourceService
16+
) {}
17+
18+
ngOnInit() {
19+
20+
this.content.index()
21+
.subscribe((index: ContentDocument) => {
22+
this.index = index;
23+
this.current = index;
24+
});
25+
26+
}
27+
28+
onNavigate(link: LinkWithRel) {
29+
30+
this.content.fetchLink(this.index, link.rel)
31+
.subscribe((doc: ContentDocument) => {
32+
this.current = doc;
33+
});
34+
35+
}
36+
1037
}

src/app/app.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { FormsModule } from '@angular/forms';
44
import { HttpModule } from '@angular/http';
55

66
import { AppComponent } from './app.component';
7+
import { ContentModule } from './content/content.module';
8+
import { ReactiveContentModule } from './reactive-content';
79

810
@NgModule({
911
declarations: [
@@ -12,7 +14,9 @@ import { AppComponent } from './app.component';
1214
imports: [
1315
BrowserModule,
1416
FormsModule,
15-
HttpModule
17+
HttpModule,
18+
ContentModule.forRoot(),
19+
ReactiveContentModule.forRoot()
1620
],
1721
providers: [],
1822
bootstrap: [AppComponent]

src/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>DynamicContentShowcase</title>
5+
<title>...Angular...</title>
66
<base href="/">
77

88
<meta name="viewport" content="width=device-width, initial-scale=1">
99
<link rel="icon" type="image/x-icon" href="favicon.ico">
10+
<!-- Google Fonts -->
11+
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
12+
1013
</head>
1114
<body>
12-
<app-root>Loading...</app-root>
15+
<rc-root></rc-root>
1316
</body>
1417
</html>

src/styles.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/* You can add global styles to this file, and also import other style files */
2+
3+
@import "../node_modules/normalize.css/normalize.css";
4+
@import "../node_modules/milligram/dist/milligram.css";

0 commit comments

Comments
 (0)