Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit bbd7d79

Browse files
johnpapawardbell
authored andcommitted
docs(style-guide): add style-guide - v.6
1 parent f4223c7 commit bbd7d79

File tree

15 files changed

+358
-171
lines changed

15 files changed

+358
-171
lines changed

public/docs/_examples/style-guide/ts/03-05/app/+heroes/shared/hero.service.avoid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Injectable} from 'angular2/core';
66
import {Http, Response} from 'angular2/http';
77

88
import {Hero} from './hero.model';
9-
import {ExceptionService, SpinnerService, ToastService} from '../../../app/shared';
9+
import {ExceptionService, SpinnerService, ToastService} from '../../shared';
1010
// #enddocregion example
1111

1212
@Injectable()

public/docs/_examples/style-guide/ts/03-05/app/+heroes/shared/hero.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import { Injectable } from 'angular2/core';
44
import { Http, Response } from 'angular2/http';
55

66
import { Hero } from './hero.model';
7-
import { ExceptionService, SpinnerService, ToastService } from '../../../app/shared';
7+
import { ExceptionService, SpinnerService, ToastService } from '../../shared';
88
// #enddocregion example
99

1010
@Injectable()
1111
export class HeroService {
12+
cachedHeroes: Hero[];
1213

1314
constructor(
1415
private exceptionService: ExceptionService,

public/docs/_examples/style-guide/ts/03-06/app/+heroes/shared/hero.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ExceptionService, SpinnerService, ToastService } from '../../../app/sha
99

1010
@Injectable()
1111
export class HeroService {
12+
cachedHeroes: Hero[];
1213

1314
constructor(
1415
private exceptionService: ExceptionService,

public/docs/_examples/style-guide/ts/04-10/app/+heroes/heroes.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docplaster
12
// #docregion
23
// #docregion example
34
import { Component, OnInit } from 'angular2/core';
@@ -10,13 +11,21 @@ import {
1011
InitCapsPipe,
1112
SpinnerService,
1213
ToastService
13-
} from '../../app/shared';
14+
} from '../shared';
1415

1516
@Component({
17+
// #enddocregion example
18+
providers: [EntityService, ExceptionService, SpinnerService, ToastService],
19+
directives: [FilterTextComponent],
20+
pipes: [InitCapsPipe],
21+
// #docregion example
1622
selector: 'toh-heroes',
1723
templateUrl: 'app/+heroes/heroes.component.html'
1824
})
1925
export class HeroesComponent implements OnInit {
26+
// #enddocregion example
27+
urls = CONFIG.baseUrls;
28+
// #docregion example
2029
constructor() { }
2130

2231
ngOnInit() { }

public/docs/_examples/style-guide/ts/04-10/app/app.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { HeroesComponent } from './+heroes/index';
77

88
@Component({
99
selector: 'toh-app',
10-
template: '<div>app</div>'
10+
template: '<div>app</div>',
11+
directives: [HeroesComponent]
1112
})
1213
export class AppComponent { }

public/docs/_examples/style-guide/ts/04-14/app/heroes/heroes.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { Logger } from '../shared/logger.service';
99
@Component({
1010
selector: 'toh-heroes',
1111
templateUrl: 'heroes.component.html',
12-
styleUrls: ['heroes.component.css']
12+
styleUrls: ['heroes.component.css'],
13+
providers: [Logger]
1314
})
1415
export class HeroesComponent implements OnInit {
1516
heroes: Hero[];

public/docs/_examples/style-guide/ts/05-14/app/shared/toast/toast.component.avoid.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export class ToastComponent implements OnInit {
1212
title: string;
1313
private toastElement: any;
1414

15-
1615
ngOnInit() {
1716
this.toastElement = document.getElementById('toh-toast');
1817
}

public/docs/_examples/style-guide/ts/05-14/app/shared/toast/toast.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@ export class ToastComponent implements OnInit {
1010
// public properties
1111
message: string;
1212
title: string;
13+
1314
// private fields
1415
private defaults = {
1516
title: '',
1617
message: 'May the Force be with You'
1718
};
1819
private toastElement: any;
20+
1921
// public methods
2022
activate(message = this.defaults.message, title = this.defaults.title) {
2123
this.title = title;
2224
this.message = message;
2325
this.show();
2426
}
27+
2528
ngOnInit() {
2629
this.toastElement = document.getElementById('toh-toast');
2730
}
31+
2832
// private methods
2933
private hide() {
3034
this.toastElement.style.opacity = 0;
3135
window.setTimeout(() => this.toastElement.style.zIndex = 0, 400);
3236
}
37+
3338
private show() {
3439
console.log(this.message);
3540
this.toastElement.style.opacity = 1;

public/docs/_examples/style-guide/ts/05-17/app/heroes/hero-list/heroes-list.component.avoid.ts renamed to public/docs/_examples/style-guide/ts/05-17/app/heroes/hero-list/hero-list.component.avoid.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Hero } from '../shared/hero.model';
66
/* avoid */
77

88
@Component({
9-
selector: 'toh-heroes-list',
9+
selector: 'toh-hero-list',
1010
template: `
1111
<section>
1212
Our list of heroes:
@@ -17,7 +17,7 @@ import { Hero } from '../shared/hero.model';
1717
</section>
1818
`
1919
})
20-
export class HeroesListComponent {
20+
export class HeroListComponent {
2121
heroes: Hero[];
2222
totalPowers: number;
2323
}

public/docs/_examples/style-guide/ts/05-17/app/heroes/hero-list/heroes-list.component.ts renamed to public/docs/_examples/style-guide/ts/05-17/app/heroes/hero-list/hero-list.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Hero } from '../shared/hero.model.ts';
55

66
// #docregion example
77
@Component({
8-
selector: 'toh-heroes-list',
8+
selector: 'toh-hero-list',
99
template: `
1010
<section>
1111
Our list of heroes:
@@ -16,9 +16,12 @@ import { Hero } from '../shared/hero.model.ts';
1616
</section>
1717
`
1818
})
19-
export class HeroesListComponent {
19+
export class HeroListComponent {
2020
heroes: Hero[];
2121
totalPowers: number;
22-
avgPower: number;
22+
23+
get avgPower() {
24+
return this.totalPowers / this.heroes.length;
25+
}
2326
}
2427
// #enddocregion example

public/docs/_examples/style-guide/ts/06-03/app/shared/validate.directive.avoid.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
import { Directive, HostBinding, HostListener } from 'angular2/core';
33

44
// #docregion example
5+
/* avoid */
6+
57
@Directive({
6-
selector: '[tohValidator]'
8+
selector: '[tohValidator]',
9+
host: {
10+
'(mouseenter)': 'onMouseEnter()',
11+
'attr.role': 'button'
12+
}
713
})
814
export class ValidatorDirective {
9-
@HostBinding('attr.role') role = 'button';
10-
@HostListener('mouseenter') onMouseEnter() {
15+
role = 'button';
16+
onMouseEnter() {
1117
// do work
1218
}
1319
}
1420
export class ValidateDirective { }
1521
// #enddocregion example
16-

public/docs/_examples/style-guide/ts/06-03/app/shared/validate.directive.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22
import { Directive, HostBinding, HostListener } from 'angular2/core';
33

44
// #docregion example
5-
/* avoid */
6-
75
@Directive({
8-
selector: '[tohValidator]',
9-
host: {
10-
'(mouseenter)': 'onMouseEnter()',
11-
'attr.role': 'button'
12-
}
6+
selector: '[tohValidator]'
137
})
148
export class ValidatorDirective {
15-
role = 'button';
16-
onMouseEnter() {
9+
@HostBinding('attr.role') role = 'button';
10+
@HostListener('mouseenter') onMouseEnter() {
1711
// do work
1812
}
1913
}

0 commit comments

Comments
 (0)